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