Reputation: 90
I want my bot to move a user in 1 of 2 afk channels by using a "<afk [radio]" command. But i first want to check if the user is allready in an AFK Channel. I tried:
const voiceChannel = message.member.voice.channel;
const voiceChannelID = message.member.voice.channelID;
if (!voiceChannel) {
return message.channel.send('You are not in an voice Channel so why move to AFK?');
} else if (voiceChannelID === '789186504483536937', '791444742042943548') {
return message.channel.send('You are already in an AFK channel!');
} else if (!args.length) {
return member.voice.setChannel('789186504483536937');
}
But when i try t use the "<afk" command the bot send the message:
You are already in an AFK channel!
Any ideas why it does this?
Upvotes: 2
Views: 1717
Reputation: 1581
The problem is
if (voiceChannelID === '789186504483536937', '791444742042943548')
This is not how multiple conditionals work. Seperate it with the or operator.
if (voiceChannelID === '789186504483536937' || voiceChannelID === '791444742042943548')
You can think of what you were trying to do as passing in two different conditions, f(x, y). If statements in Javascript will only check for the last one (y), and "791444742042943548" is truthy since it is non-null.
Upvotes: 2