I'm making my own Discord Bot because I don't trust the bigger ones (Dyno, Hime, NosoBot, etc.) And my bot is pretty much done. The only problem is that my code allows all members to use these commands. I only want people to be able to use the functions they have permissions to. The code works, but how can I make it allow only people with permission to kick/ban?
if (msg.content.startsWith("$kick ")) {
if (msg.mentions.members.first()) {
msg.mentions.members.first.kick().then((member) => {
msg.channel.send(":wave: " + member.displayName + " has been successfully kicked :point_right: ");
}).catch(() => {
msg.channel.send("I do not have permissions to do this");
});
}
}else if (msg.content.startsWith("$ban ")) {
if (!message.member.hasPermission("MANAGE_MESSAGES")) return;
if (msg.mentions.members.first()) {
msg.mentions.members.first.ban().then((member) => {
msg.channel.send(":wave: " + member.displayName + " has been successfully banned :point_right: ");
}).catch(() => {
msg.channel.send("I do not have permissions to do this");
});
}
}