dodano obsłuugę linków ze spotify oraz soundcloud

This commit is contained in:
Patryk Koreń
2026-01-03 22:48:46 +01:00
parent 28b6546c25
commit 6ad7e01957
7 changed files with 1299 additions and 23 deletions

View File

@@ -1,11 +1,12 @@
// Require the necessary discord.js classes
import { Client, Events, GatewayIntentBits, MessageFlags, REST, Routes } from 'discord.js';
import dotenv from 'dotenv';
dotenv.config()
import { Client, Events, GatewayIntentBits, MessageFlags, REST, Routes } from 'discord.js';
import { commands } from "./commands";
import { AudioPlayerState, createAudioPlayer } from '@discordjs/voice';
import { connectToChannel, playSong } from './util/helpers';
import { updatePlayer } from './playback';
dotenv.config()
import SpotifyWebApi from 'spotify-web-api-node';
export const DATA_DIR = "./data";
@@ -24,6 +25,12 @@ const client = new Client({
GatewayIntentBits.GuildVoiceStates]
});
export const spotify = new SpotifyWebApi({
clientId: process.env.SPOTIFY_CLIENT_ID,
clientSecret: process.env.SPOTIFY_CLIENT_SECRET,
});
// When the client is ready, run this code (only once).
// The distinction between `client: Client<boolean>` and `readyClient: Client<true>` is important for TypeScript developers.
// It makes some properties non-nullable.
@@ -35,7 +42,7 @@ client.once(Events.ClientReady, (readyClient) => {
async function registerCommands() {
const rest = new REST().setToken(process.env.DISCORD_TOKEN!);
const registry = Object.values(commands).map((cmd) => cmd.register().toJSON())
console.log(registry)
console.log("komendy: \n", registry.map(r => `${r.name} : ${r.description}`).join("\n"))
await rest.put(Routes.applicationGuildCommands(
process.env.DISCORD_APP_ID!,
process.env.GUILD_ID!