我正在尝试发出不一致的bot离开命令,但我找不到要获得该bot的通道ID以及发送消息的用户进行比较以确保它们相同的用户
Crashbot.on('message', async message =>{
//creates an array called args and removes the first amount of charactors equal to the length of the prefix variable
let args = message.content.substring(PREFIX.length).split(" ");
//the switch equals true if the first word after the prefix is "leave"
switch (args[0]) {
case 'leave':
//if the message author is not in the same voice channel as the bot the bot replies and tells them that that have to be in the same channel to use that command
if (message.member.voice.channel.id != Crashbot.voice.channel.id) {
message.reply("You must be in the same channel as me to use this command");
return;
}
//if the message author is in the same voice channel as the bot it leaves the channel it is in
if (message.member.voice.channel.id === Crashbot.voice.channel.id) {
const connection = await message.member.voice.channel.leave()
message.channel.send("Successfully left the voice channel");
}
break;
}
});