diff --git a/examples/music-bot/package.json b/examples/music-bot/package.json index 59fe4992..8c203764 100644 --- a/examples/music-bot/package.json +++ b/examples/music-bot/package.json @@ -18,11 +18,11 @@ "discord-api-types": "^0.19.0", "discord.js": "^13.0.0-dev.328501b.1626912223", "libsodium-wrappers": "^0.7.9", - "youtube-dl-exec": "^1.2.4", + "youtube-dl-exec": "^2.0.0", "ytdl-core": "^4.8.3" }, "devDependencies": { "tsconfig-paths": "^3.9.0", - "typescript": "~4.2.2" + "typescript": "^4.5.2" } } diff --git a/examples/music-bot/src/bot.ts b/examples/music-bot/src/bot.ts index 5bdd0155..6f509f3a 100644 --- a/examples/music-bot/src/bot.ts +++ b/examples/music-bot/src/bot.ts @@ -72,7 +72,7 @@ client.on('interactionCreate', async (interaction: Interaction) => { let subscription = subscriptions.get(interaction.guildId); if (interaction.commandName === 'play') { - await interaction.defer(); + await interaction.deferReply(); // Extract the video URL from the command const url = interaction.options.get('song')!.value! as string; diff --git a/examples/music-bot/src/music/subscription.ts b/examples/music-bot/src/music/subscription.ts index cf36eacb..677f461a 100644 --- a/examples/music-bot/src/music/subscription.ts +++ b/examples/music-bot/src/music/subscription.ts @@ -1,11 +1,13 @@ import { AudioPlayer, + AudioPlayerState, AudioPlayerStatus, AudioResource, createAudioPlayer, entersState, VoiceConnection, VoiceConnectionDisconnectReason, + VoiceConnectionState, VoiceConnectionStatus, } from '@discordjs/voice'; import type { Track } from './track'; @@ -29,7 +31,7 @@ export class MusicSubscription { this.audioPlayer = createAudioPlayer(); this.queue = []; - this.voiceConnection.on('stateChange', async (_: any, newState: { status: any; reason: any; closeCode: number; }) => { + this.voiceConnection.on('stateChange', async (_: any, newState: VoiceConnectionState) => { if (newState.status === VoiceConnectionStatus.Disconnected) { if (newState.reason === VoiceConnectionDisconnectReason.WebSocketClose && newState.closeCode === 4014) { /** @@ -84,7 +86,7 @@ export class MusicSubscription { }); // Configure audio player - this.audioPlayer.on('stateChange', (oldState: { status: any; resource: any; }, newState: { status: any; resource: any; }) => { + this.audioPlayer.on('stateChange', (oldState: AudioPlayerState, newState: AudioPlayerState) => { if (newState.status === AudioPlayerStatus.Idle && oldState.status !== AudioPlayerStatus.Idle) { // If the Idle state is entered from a non-Idle state, it means that an audio resource has finished playing. // The queue is then processed to start playing the next track, if one is available. @@ -96,7 +98,7 @@ export class MusicSubscription { } }); - this.audioPlayer.on('error', (error: { resource: any; }) => (error.resource as AudioResource).metadata.onError(error)); + this.audioPlayer.on('error', (error: { message: string; name: string; resource: any; }) => (error.resource as AudioResource).metadata.onError(error)); voiceConnection.subscribe(this.audioPlayer); } diff --git a/examples/music-bot/src/music/track.ts b/examples/music-bot/src/music/track.ts index 32e7393a..7f527c60 100644 --- a/examples/music-bot/src/music/track.ts +++ b/examples/music-bot/src/music/track.ts @@ -1,6 +1,6 @@ import { getInfo } from 'ytdl-core'; import { AudioResource, createAudioResource, demuxProbe } from '@discordjs/voice'; -import { raw as ytdl } from 'youtube-dl-exec'; +import { exec as ytdl } from 'youtube-dl-exec'; /** * This is the data required to create a Track object. @@ -48,10 +48,10 @@ export class Track implements TrackData { const process = ytdl( this.url, { - o: '-', - q: '', - f: 'bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio', - r: '100K', + output: '-', + quiet: true, + format: 'bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio', + limitRate: '100K', }, { stdio: ['ignore', 'pipe', 'ignore'] }, ); diff --git a/examples/music-bot/tsconfig.json b/examples/music-bot/tsconfig.json index 97782611..95ce4307 100644 --- a/examples/music-bot/tsconfig.json +++ b/examples/music-bot/tsconfig.json @@ -2,7 +2,6 @@ "extends": "../../tsconfig.json", "compilerOptions": { "baseUrl": ".", - "outDir": "dist", "rootDir": "src", "paths": { "@discordjs/voice": ["../../"],