Reputation: 158
I want to be able to have the bot join a channel and server mute itself, and then when I want it to leave later, it should unmute itself.
Upvotes: 0
Views: 2091
Reputation: 317
So first, you need to get your bot guid member, for this do yourVoiceChannel.guild.me
, then, you need to mute him, for this is great function guildMember.edit({mute:false/true})
. So you need to put this line to place of the code where the bot will join the voice channel: voiceChannel.guild.me.edit({mute:true})
. And this line where he leaves: voiceChannel.guild.me.edit({mute:false})
. This will have one problem, when the bot will restart, he can be still muted, to solve this put this line of code into ready event: client.guilds.cache.each(guild => guild.me.edit({mute:false}))
. Also, it will be good idea to check, if the bot has permission to servermute, or use guild.me.voice.setMute(false/true)
.
Upvotes: 2