Home > other >  Self Permission Check
Self Permission Check

Time:11-06

How do I check if the bot (Self) has permissions to send messages and make it an if statement? Im using discord js and I've seen forums like member.roles.cache has, but none cover the bot itself, so how do I check that?

CodePudding user response:

You can use Guild#me to get the client's GuildMember object in that guild.

// guild = message.guild or any guild object
if (guild.me.roles.cache.has(...)) {

}

CodePudding user response:

As Elitezen said, you can get GuildMember object using Guild#me but to check if your bot can send messages for example in guild where the command was executed you have to use this:

if(message.guild.me.permissions.has("SEND_MESSAGES")) { // check if bot has SEND_MESSAGES permission
// your code
}
  • Related