Reputation: 35
I tried doing this:
if(!msg.author.hasPermission('MANAGE_MESSAGES')) return msg.channel.send(":x: You don't have permissions. :x:")
but it gave me this error:
TypeError: msg.author.hasPermission is not a function
Help? (Tring to check if the user has permission to manage messages when a specific code is executed.)
Upvotes: 0
Views: 2620
Reputation: 89
If you use discordjs, v13 you can do like below:
if(message.member.permissions.has(Discord.Permissions.FLAGS.ADMINISTRATOR)) {
/* logic here */
}
All Permission Flags are under this property Discord.Permissions.FLAGS
Upvotes: 4
Reputation: 1227
Users don't have permissions, guild members do
you need to get the user as a guild member with
const member = message.guild.member(message.author);
so do this
if(!message.guild.member(message.author).hasPermission('MANAGE_MESSAGES')) {
return msg.channel.send(":x: You don't have permissions. :x:")
}
Upvotes: 3