Home > database >  Discord JS - AudioPlayerStatus
Discord JS - AudioPlayerStatus

Time:10-20

Why does this function:

client.player.once(AudioPlayerStatus.Idle, () => {
            console.log(client.playlist);
            next.run(message, args, client);
            client.playlist.shift();
            return;
        });

is executed only when the resource already played, and not when I initialize AudioPlayer? Isn't it by default idle?

CodePudding user response:

From the @discordjs/voice documentation (reference here):

Both voice connections and audio players are stateful, and you can subscribe to changes in their state as they progress through their respective life cycles.

The AudioPlayer starts in Idle, but do not trigger this kind of event because these events are only triggered when changing states.

That's why you can see the event firing only when resource already played.

  • Related