Way to not emit VoiceStateUpdate when bot is moving a user?

I am making a bot that will detect when a user is muted or deafened in a channel, and move them to a designated mute/deafen channel. I do this by using the voiceStateUpdate event and checking for the necessary conditions to be met. I also have it set up so that when the bot moves a user to the mute/deafen channel, it will take note of what channel that user was in, so that if the user unmutes/undeafens, the bot will be able to put them back in the channel they were in before. The issue I am having is that I guess technically when the bot moves a user, that action itself is a voiceStateUpdate, so it causes more voiceStateUpdates than there should be. For testing i was logging each time a voiceStateUpdate was detected, and when I deafen myself, the bot moves me to the deafen channel, but i see A LOT more voiceStateUpdates being logged. What can I do to minimize this or prevent it all together. Any help is appreciated. Thanks
2 Replies
d.js toolkit
d.js toolkit15mo ago
- 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 OP
Daricide
DaricideOP15mo ago
ok, although if someone is in the mute channel, and they unmute i want it to also move them back to the original channel they were in, which wouldn't be possible with what you are suggesting. I was thinking to maybe have some boolean that is true when the bot just moved someone and when the next event was emitted gets set to false. However this solution seems super hacky to me, and probably wouldn't work if multiple people mute at the same-ish time ok thanks thanks, I think I will try with the event data alone, since I think you are right about that. However I will keep in mind the collection idea. Thank you
Want results from more Discord servers?
Add your server