diff --git a/example/music-bot/index.js b/example/music-bot/index.js index b707114..d02659d 100644 --- a/example/music-bot/index.js +++ b/example/music-bot/index.js @@ -19,7 +19,13 @@ client.on("error", console.error); client.on("warn", console.warn); // instantiate the player -const player = new Player(client); +const player = new Player(client, { + ytdlOptions: { + headers: { + cookie: process.env.YT_COOKIE + } + } +}); player.on("error", (queue, error) => { console.log(`[${queue.guild.name}] Error emitted from the queue: ${error.message}`); diff --git a/src/VoiceInterface/StreamDispatcher.ts b/src/VoiceInterface/StreamDispatcher.ts index 19f6050..cd4567f 100644 --- a/src/VoiceInterface/StreamDispatcher.ts +++ b/src/VoiceInterface/StreamDispatcher.ts @@ -184,6 +184,7 @@ class StreamDispatcher extends EventEmitter { */ async playStream(resource: AudioResource = this.audioResource) { if (!resource) throw new PlayerError("Audio resource is not available!", ErrorStatusCode.NO_AUDIO_RESOURCE); + if (resource.ended) return void this.emit("error", new PlayerError("Cannot play a resource that has already ended.") as unknown as AudioPlayerError); if (!this.audioResource) this.audioResource = resource; if (this.voiceConnection.state.status !== VoiceConnectionStatus.Ready) { try {