From 0e7dfebba6543e71a6e6d83a6780b9c657dc4410 Mon Sep 17 00:00:00 2001 From: Helixu Date: Sat, 4 Dec 2021 19:14:35 +0000 Subject: [PATCH] Fix issue #3: bot wont error if you kick/ban someone who cant be kicked/banned by the bot, and you also can no longer kick/ban yourself. --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 81a02ee..aa51165 100644 --- a/index.js +++ b/index.js @@ -183,6 +183,8 @@ client.on("interactionCreate", (int) => { var mem = int.guild.members.cache.get(int.user.id); if(!mem.permissions.has("KICK_MEMBERS")) return int.reply(":x: You do not have permissions to kick users."); var mem2 = int.guild.members.cache.get(int.options.getUser("user").id); + if(!mem.kickable) return int.reply(":x: I cannot kick this user!"); + if(mem == mem2) return int.reply(":x: You cannot kick yourself!"); mem2.kick(int.options.getString("reason")).then(() => { var reason = "No reason specified."; if(int.options.getString("reason") !== null) reason = int.options.getString("reason"); @@ -196,6 +198,8 @@ client.on("interactionCreate", (int) => { if(!mem.permissions.has("BAN_MEMBERS")) return int.reply(":x: You do not have the permissions to ban users."); var mem2 = int.guild.members.cache.get(int.options.getUser("user").id); var reason = "No reason specified."; + if(!mem.bannable) return int.reply(":x: I cannot ban this user!"); + if(mem == mem2) return int.reply(":x: You cannot ban yourself!"); if(int.options.getString("reason") !== null) reason = int.options.getString("reason"); mem2.ban({reason}).then(() => { int.reply("Successfully banned <@!" + int.options.getUser("user").id + "> with reason `" + reason + "`.");