wait for bot to play audio
First time working with it,
I have a cron job running eery 5 minutes. In the callback, the bot fetches an array and loops over it. Each array has a mp3 and a channel id. Now i want to run each mp3 in its own channel.
Scenario:Bot runs the join function, a connection is created. It then listens to ready event and create a player to run audio on the connection.
Issue: when bot loops on first element, it instead of waiting for connection to be established (ready) and running the audio, just attaches the listener, then goes to next item. For next item, it again runs the join function which overrieds the previous connection according to docs.
So how would i make bot wait for connection to be ready, wait for audio to be played, since i cant even await the connection.subscribe ):
Code:
4 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- 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!you can use
entersState
for both waiting for the connection to be Ready
and waiting for the player to be Idle
i see, but the docs say the player goes to idle on error as well, how can i check if the bot has played the audio then went into idle state?
can ya look at the code and see if it's fine. Also the error handling? of stpping the player and destroying connecion.
i am really unsure about those destruction of connection