This is probably a nub question, but I can't seem to figure it out. I'm trying to make my bot check if it has a permission, and send a message if does not. I'm guessing it like this code to check it a member has a permission:
message.member.hasPermission("MUTE_MEMBERS")
Is it like that to get a bots permissions? Any help would be appreciated!
This is probably a nub question, but I can't seem to figure it out. I'm trying to make my bot check if it has a permission, and send a message if does not. I'm guessing it like this code to check it a member has a permission:
message.member.hasPermission("MUTE_MEMBERS")
Is it like that to get a bots permissions? Any help would be appreciated!
Share Improve this question asked Jun 6, 2018 at 22:57 swoodsswoods 3732 gold badges5 silver badges12 bronze badges5 Answers
Reset to default 9message.member
gets the GuildMember object of the author who sent the message. Looks like you actually want to get the GuildMember object of the client instead. You can do this by doing <Client>.guild.me
and then call .hasPermission(...) on this.
If you want to check if the bot has a permission you can do something like:
if(message.guild.me.hasPermission("MUTE_MEMBERS"))
console.log("I can mute members!!")
else
console.log("I CAN'T mute members!")
F.M.
message.guild.me.hasPermission("MUTE_MEMBERS")
In discord.js V13 you can check for permissions this way:
if (message.member.permissions.has("MUTE_MEMBERS")){
// ....
} else {
//....
}
if(!message.member.hasPermission("PERMISSION") return message.channel.send("You don't have permission to use this command")
Embeds:
const embed = new MessageEmbed()
.setTitle("No Permission")
.setDescription("You don't have permission to use this command")
if(!message.member.hasPermission("PERMISSION") return message.channel.send(embed)