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!
Checking member permissions To know if one of a member's roles has a permission enabled, you can use the .has() method on GuildMember#permissions open in new window and provide a permission flag, array, or number to check for.
You can adjust permissions of specific channels, both text and voice, through the channel settings menu by hovering over a channel and clicking on the cog icon. Select the Permissions tab on the left-hand side. By default @everyone has access to all features of a channel.
Permission HierarchyA bot can grant roles to other users that are of a lower position than its own highest role. A bot can edit roles of a lower position than its highest role, but it can only grant permissions it has to those roles. A bot can only sort roles lower than its highest role.
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.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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With