Player state changes to "playing" when resource ends

Whenever I play a resource, I need to be able to detect when said resource stops playing in the player I play it with. However, whenever the resource ends, the player rattles off "playing" status.
4 Replies
d.js toolkit
d.js toolkit2w ago
- What are your intents? GuildVoiceStates is required to receive voice data! - Show what dependencies you are using -- generateDependencyReport() is exported from @discordjs/voice. - Try looking at common examples: https://github.com/discordjs/voice-examples. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
bert
bertOP2w ago
Here's code
player.on('stateChange', listener => {
console.log(listener.status);

if (listener.status == voice.AudioPlayerStatus.Idle) {
this.playing = false;
this.textChannel = null;

if (this.queue.length !== 0) {
let next = this.queue.shift();

this.bot.emit('queuePlay', next, channel);

this.play(next, channel);
} else {
console.log("Done");
}
}
})
player.on('stateChange', listener => {
console.log(listener.status);

if (listener.status == voice.AudioPlayerStatus.Idle) {
this.playing = false;
this.textChannel = null;

if (this.queue.length !== 0) {
let next = this.queue.shift();

this.bot.emit('queuePlay', next, channel);

this.play(next, channel);
} else {
console.log("Done");
}
}
})
Every time a resource ends, "playing" is logged even though it is supposed to log "stopped" or something to that effect It logs "buffering" when the player starts playing, and "playing" when the resource ends
d.js docs
d.js docs2w ago
:class: AudioPlayer @0.17.0 Used to play audio resources (i.e. tracks, streams) to voice connections.
bert
bertOP2w ago
Ah I just discovered that digging thru the code Thanks
Want results from more Discord servers?
Add your server