So the code below is my Kick.js but I want it so that the mod role can only use the kick command
module.exports = { name: 'kick', //command name run : async(client, message, args) => { if (!message.guild.me.hasPermission('KICK_MEMBER')) return message.channel.send('I do not have permission to use this command :joy: '); // Basically checks if the bot has permission to kick a member or not //Lets define the guildmember to kick! const Member = message.mentions.members.first() //checking for member mentions if (!Member) return message.channel.send('Please specify a member to kick.....'); // if there is no user then it will return with that message await Member.kick({ reason: args.slice(1).join(" ")}) // args.slice(1).join(" ") means it slices the Member Variable and takes the text after it. message.channel.send(`${ Member.user.tag} was kicked from the server!`) // above message will be sent when the member is kicked from the server. } }
Advertisement
Answer
Check for the message.member permissions
if(!message.member.hasPermission("KICK_MEMBERS")) return message.reply("You don't have enough permissions for kick")
If you want to check for specific role
if(!message.member.roles.cache.has(modRole)) return message.reply("You aren't a Mod")