From fea07b47ce012180abc39c7246228b92c01eb496 Mon Sep 17 00:00:00 2001 From: TheEssem Date: Thu, 23 Jul 2020 15:56:03 -0500 Subject: [PATCH] Merged hackban with ban --- commands/ban.js | 17 +++++++++++++---- commands/hackban.js | 20 -------------------- 2 files changed, 13 insertions(+), 24 deletions(-) delete mode 100644 commands/hackban.js diff --git a/commands/ban.js b/commands/ban.js index c41a4e4..2bbdf0c 100644 --- a/commands/ban.js +++ b/commands/ban.js @@ -1,21 +1,30 @@ const client = require("../utils/client.js"); -exports.run = async (message) => { +exports.run = async (message, args) => { if (!message.member.permission.has("banMembers")) return `${message.author.mention}, you need to have the \`Ban Members\` permission on this server to ban people!`; if (!message.channel.guild.members.get(client.user.id).permission.has("banMembers") && !message.channel.permissionsOf(client.user.id).has("banMembers")) return `${message.author.mention}, I don't have the \`Ban Members\` permission!`; const member = message.mentions[0]; if (member) { try { - await message.channel.guild.banMember(member.id, 0, `ban command used by @${message.author.username}#${message.author.discriminator}`); + await message.channel.guild.banMember(member.id, 0, `Ban command used by @${message.author.username}#${message.author.discriminator}`); return `Successfully banned ${member.mention}.`; } catch (e) { - return `${message.author.mention}, I was unable to ban the member. Have you given me permissions?`; + return `${message.author.mention}, I was unable to ban the member. They might not exist or I don't have the permissions to do so.`; + } + } else if (args[0].match(/^?$/) && args[0] >= 21154535154122752) { + try { + const id = args[0].replace("@", "").replace("#", "").replace("!", "").replace("&", "").replace("<", "").replace(">", ""); + await message.channel.guild.banMember(id, 0, `Banned by ID, command used by @${message.author.username}#${message.author.discriminator}`); + return `Successfully banned user with ID \`${id}\`.`; + } catch (e) { + return `${message.author.mention}, I was unable to ban the member. They might not exist or I don't have the permissions to do so.`; } } else { return `${message.author.mention}, you need to provide a member to ban!`; } }; +exports.aliases = ["hackban", "prevent", "preban"]; exports.category = 2; exports.help = "Bans a server member"; -exports.params = "[mention]"; \ No newline at end of file +exports.params = "[mention/id]"; \ No newline at end of file diff --git a/commands/hackban.js b/commands/hackban.js deleted file mode 100644 index 3908b76..0000000 --- a/commands/hackban.js +++ /dev/null @@ -1,20 +0,0 @@ -const client = require("../utils/client.js"); - -exports.run = async (message, args) => { - if (!message.member.permission.has("banMembers")) return `${message.author.mention}, you need to have the \`Ban Members\` permission on this server to ban people!`; - if (!message.channel.guild.members.get(client.user.id).permission.has("banMembers") && !message.channel.permissionsOf(client.user.id).has("banMembers")) return `${message.author.mention}, I don't have the \`Ban Members\` permission!`; - if (!args[0].match(/^?$/) && args[0] < 21154535154122752) return `${message.author.mention}, that's not a valid snowflake!`; - try { - const id = args[0].replace("@", "").replace("#", "").replace("!", "").replace("&", "").replace("<", "").replace(">", ""); - await message.channel.guild.banMember(id, 0, `Hackban command used by @${message.author.username}#${message.author.discriminator}`); - return `Successfully banned user with ID \`${id}\`.`; - } catch (e) { - throw e; - //return `${message.author.mention}, I was unable to ban the member. Have you given me permissions?`; - } -}; - -exports.aliases = ["prevent", "preban"]; -exports.category = 2; -exports.help = "Bans a member via user id"; -exports.params = "[id]"; \ No newline at end of file