In the program, a channel is selected (by the user via settings) for the discord bot to monitor. I need to make sure the bot has permissions to monitor that channel prior to the channel being set.
The following code doesn't work:
// Make sure bot has read permissions by checking if it's missing any
if (message.guild.me.permissionsIn(channel).missing(['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'])) {
return message.channel.send("I don't have permission in that channel.");
}
// If it isn't missing any then do stuff
console.log("do stuff");
This also doesn't work:
if (!message.guild.me.permissionsIn(channel).has(['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'])) {
return message.channel.send("I don't have permission in that channel.");
}
console.log("do stuff");
The output is ALWAYS "do stuff" (the if statement returns a channelID), rather than returning. How can I do this?