Player Auto-Pause
I have this music bot and I want it to pause the playback if it's alone in the voice channel. I've succeeded in doing that, but rn it pauses instantly after detecting that it's alone and I want it to wait for 3 seconds before doing that, so that if anybody joins during that time interval the bot doesn't need to pause.
here's the code currently:
2 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!
- ✅
Marked as resolved by OPmy discord.js version: [email protected]
my node version: v20.1.0
can anyone help?
I tried this
and it does pause after 3 seconds but if someone joins in that 3 second interval bot still proceeds to pause and then doesn't resume playback
until a user leaves and rejoins
so do I use connection.joinConfig.channelId for that check?
can you help out? I'm out of ideas
actually nvm
thanks for the advices I did the check with connection.joinConfig.channelId to see if the event is tied to bot's VC and then made flags for player timeouts and used setTimeout/clearTimeout logic
it's working now