I'm working on a discord bot that plays music. I have managed to get the bot to leave the channel, but anyone in the server can disconnect it.
I have tried to add an if statement that requires the command author's voiceChannel connection to be equal to the bot's voiceChannel connection in that guild.
if(client.guildChannel.voiceChannel == message.author.voiceChannel)
{
message.guild.voiceConnection.disconnect();
}
this returns:
Property "voiceChannel" cannot be read of undefined.
I can't find anything on the documentation that defines which voice channel the bot is connected to in which guild.
guildChannel
orauthor
is undefined. – Daniel A. White