From 6419cbf6e04f97f1122250dd8f07303b09cb953e Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Tue, 7 Nov 2017 19:18:31 +0000 Subject: [PATCH] Remove moderation group --- XiaoBot.js | 1 - commands/moderation/ban.js | 60 ------------------------ commands/moderation/clear-channel.js | 28 ------------ commands/moderation/hackban.js | 57 ----------------------- commands/moderation/kick.js | 57 ----------------------- commands/moderation/lockdown.js | 43 ----------------- commands/moderation/softban.js | 61 ------------------------- commands/moderation/unban.js | 49 -------------------- commands/{moderation => other}/prune.js | 2 +- package.json | 2 +- 10 files changed, 2 insertions(+), 358 deletions(-) delete mode 100644 commands/moderation/ban.js delete mode 100644 commands/moderation/clear-channel.js delete mode 100644 commands/moderation/hackban.js delete mode 100644 commands/moderation/kick.js delete mode 100644 commands/moderation/lockdown.js delete mode 100644 commands/moderation/softban.js delete mode 100644 commands/moderation/unban.js rename commands/{moderation => other}/prune.js (97%) diff --git a/XiaoBot.js b/XiaoBot.js index d4af9e9d..eb6ccbe6 100644 --- a/XiaoBot.js +++ b/XiaoBot.js @@ -16,7 +16,6 @@ client.registry .registerGroups([ ['util', 'Utility'], ['info', 'Discord Information'], - ['moderation', 'Moderation'], ['random-res', 'Random Response'], ['single-res', 'Single Response'], ['events', 'Daily Events'], diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js deleted file mode 100644 index f07d0220..00000000 --- a/commands/moderation/ban.js +++ /dev/null @@ -1,60 +0,0 @@ -const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const { verify } = require('../../util/Util'); - -module.exports = class BanCommand extends Command { - constructor(client) { - super(client, { - name: 'ban', - aliases: ['banne'], - group: 'moderation', - memberName: 'ban', - description: 'Bans a user.', - guildOnly: true, - clientPermissions: ['BAN_MEMBERS'], - userPermissions: ['BAN_MEMBERS'], - args: [ - { - key: 'member', - prompt: 'What member do you want to ban?', - type: 'member' - }, - { - key: 'reason', - prompt: 'What do you want to set the reason as?', - type: 'string', - max: 140 - } - ] - }); - } - - async run(msg, { member, reason }) { - if (member.id === msg.author.id) return msg.reply('I don\'t think you want to ban yourself...'); - if (member.id === msg.guild.ownerID) return msg.reply('Don\'t you think that might be betraying your leader?'); - if (!member.bannable) return msg.reply('This member is not bannable. Perhaps they have a higher role than me?'); - if (member.highestRole.position > msg.member.highestRole.position - 1) { - return msg.reply('Your roles are too low to ban this member.'); - } - await msg.say(`Are you sure you want to ban ${member.user.tag} (${member.id})?`); - const verification = await verify(msg.channel, msg.author); - if (!verification) return msg.say('Aborting.'); - try { - await member.send(stripIndents` - You were banned from ${msg.guild.name} by ${msg.author.tag}! - **Reason**: ${reason} - `); - } catch (err) { - await msg.say('Failed to send DM.'); - } - try { - await member.ban({ - days: 7, - reason: `${msg.author.tag}: ${reason}` - }); - } catch (err) { - return msg.reply(`Failed to ban ${member.user.tag}: \`${err.message}\`.`); - } - return msg.say(`Successfully banned ${member.user.tag}.`); - } -}; diff --git a/commands/moderation/clear-channel.js b/commands/moderation/clear-channel.js deleted file mode 100644 index 0854f9a4..00000000 --- a/commands/moderation/clear-channel.js +++ /dev/null @@ -1,28 +0,0 @@ -const { Command } = require('discord.js-commando'); - -module.exports = class ClearChannelCommand extends Command { - constructor(client) { - super(client, { - name: 'clear-channel', - aliases: ['prune-all'], - group: 'moderation', - memberName: 'clear-channel', - description: 'Deletes all messages in a channel by cloning it and then deleting it.', - guildOnly: true, - throttling: { - usages: 1, - duration: 30 - }, - clientPermissions: ['ADMINISTRATOR'], - userPermissions: ['ADMINISTRATOR'] - }); - } - - async run(msg) { - if (!msg.channel.deletable) return msg.reply('This channel cannot be deleted.'); - const channel = await msg.channel.clone(); - if (msg.channel.parent) await channel.setParent(msg.channel.parent); - await msg.channel.delete(); - return null; - } -}; diff --git a/commands/moderation/hackban.js b/commands/moderation/hackban.js deleted file mode 100644 index 87c6f3c9..00000000 --- a/commands/moderation/hackban.js +++ /dev/null @@ -1,57 +0,0 @@ -const { Command } = require('discord.js-commando'); -const { verify } = require('../../util/Util'); - -module.exports = class HackbanCommand extends Command { - constructor(client) { - super(client, { - name: 'hackban', - aliases: ['hackbanne'], - group: 'moderation', - memberName: 'hackban', - description: 'Bans a user who doesn\'t have to be in the server.', - guildOnly: true, - clientPermissions: ['BAN_MEMBERS'], - userPermissions: ['ADMINISTRATOR'], - args: [ - { - key: 'id', - prompt: 'What is the id of the member you want to hackban?', - type: 'string', - validate: id => { - if (/^[0-9]+$/.test(id)) return true; - return 'Invalid ID.'; - } - }, - { - key: 'reason', - prompt: 'What do you want to set the reason as?', - type: 'string', - max: 140 - } - ] - }); - } - - async run(msg, { id, reason }) { - if (id === msg.author.id) return msg.reply('I don\'t think you want to ban yourself...'); - if (id === msg.guild.ownerID) return msg.reply('Don\'t you think that might be betraying your leader?'); - let user; - try { - user = await this.client.users.fetch(id); - } catch (err) { - return msg.reply('Could not resolve user.'); - } - await msg.say(`Are you sure you want to hackban ${user.tag} (${user.id})?`); - const verification = await verify(msg.channel, msg.author); - if (!verification) return msg.say('Aborting.'); - try { - await msg.guild.ban(id, { - days: 7, - reason: `${msg.author.tag}: ${reason}` - }); - } catch (err) { - return msg.reply(`Failed to hackban ${user.tag}: \`${err.message}\`.`); - } - return msg.say(`Successfully hackbanned ${user.tag}.`); - } -}; diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js deleted file mode 100644 index fc2175f7..00000000 --- a/commands/moderation/kick.js +++ /dev/null @@ -1,57 +0,0 @@ -const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const { verify } = require('../../util/Util'); - -module.exports = class KickCommand extends Command { - constructor(client) { - super(client, { - name: 'kick', - aliases: ['kickke'], - group: 'moderation', - memberName: 'kick', - description: 'Kicks a user.', - guildOnly: true, - clientPermissions: ['KICK_MEMBERS'], - userPermissions: ['KICK_MEMBERS'], - args: [ - { - key: 'member', - prompt: 'What member do you want to kick?', - type: 'member' - }, - { - key: 'reason', - prompt: 'What do you want to set the reason as?', - type: 'string', - max: 140 - } - ] - }); - } - - async run(msg, { member, reason }) { - if (member.id === msg.author.id) return msg.reply('I don\'t think you want to kick yourself...'); - if (member.id === msg.guild.ownerID) return msg.reply('Don\'t you think that might be betraying your leader?'); - if (!member.kickable) return msg.reply('This member is not kickable. Perhaps they have a higher role than me?'); - if (member.highestRole.position > msg.member.highestRole.position - 1) { - return msg.reply('Your roles are too low to kick this member.'); - } - await msg.say(`Are you sure you want to kick ${member.user.tag} (${member.id})?`); - const verification = await verify(msg.channel, msg.author); - if (!verification) return msg.say('Aborting.'); - try { - await member.send(stripIndents` - You were kicked from ${msg.guild.name} by ${msg.author.tag}! - **Reason**: ${reason} - `); - } catch (err) { - await msg.say('Failed to send DM.'); - } - try { - await member.kick(`${msg.author.tag}: ${reason}`); - } catch (err) { - return msg.reply(`Failed to kick ${member.user.tag}: \`${err.message}\`.`); - } - return msg.say(`Successfully kicked ${member.user.tag}.`); - } -}; diff --git a/commands/moderation/lockdown.js b/commands/moderation/lockdown.js deleted file mode 100644 index d229a6ab..00000000 --- a/commands/moderation/lockdown.js +++ /dev/null @@ -1,43 +0,0 @@ -const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); - -module.exports = class LockdownCommand extends Command { - constructor(client) { - super(client, { - name: 'lockdown', - group: 'moderation', - memberName: 'lockdown', - description: 'Prevents users from posting in the current channel, or removes a lockdown.', - guildOnly: true, - clientPermissions: ['ADMINISTRATOR'], - userPermissions: ['ADMINISTRATOR'], - args: [ - { - key: 'action', - prompt: 'What action should be performed? Either start or stop.', - type: 'string', - default: 'start', - validate: action => { - if (['start', 'stop'].includes(action.toLowerCase())) return true; - return 'Invalid action, please enter either start or stop.'; - }, - parse: action => action.toLowerCase() - } - ] - }); - } - - async run(msg, { action }) { // eslint-disable-line consistent-return - if (action === 'start') { - await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: false }); - return msg.say(stripIndents` - Lockdown started, users without overwrites can no longer post messages. - Please use \`lockdown stop\` to end the lockdown. - `); - } - if (action === 'stop') { - await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: null }); - return msg.say('Lockdown ended, all users can now post messages.'); - } - } -}; diff --git a/commands/moderation/softban.js b/commands/moderation/softban.js deleted file mode 100644 index cece3c9f..00000000 --- a/commands/moderation/softban.js +++ /dev/null @@ -1,61 +0,0 @@ -const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const { verify } = require('../../util/Util'); - -module.exports = class SoftbanCommand extends Command { - constructor(client) { - super(client, { - name: 'softban', - aliases: ['softbanne'], - group: 'moderation', - memberName: 'softban', - description: 'Kicks a user and deletes their messages.', - guildOnly: true, - clientPermissions: ['BAN_MEMBERS'], - userPermissions: ['KICK_MEMBERS'], - args: [ - { - key: 'member', - prompt: 'What member do you want to softban?', - type: 'member' - }, - { - key: 'reason', - prompt: 'What do you want to set the reason as?', - type: 'string', - max: 140 - } - ] - }); - } - - async run(msg, { member, reason }) { - if (member.id === msg.author.id) return msg.reply('I don\'t think you want to softban yourself...'); - if (member.id === msg.guild.ownerID) return msg.reply('Don\'t you think that might be betraying your leader?'); - if (!member.bannable) return msg.reply('This member is not softbannable. Perhaps they have a higher role than me?'); - if (member.highestRole.position > msg.member.highestRole.position - 1) { - return msg.reply('Your roles are too low to softban this member.'); - } - await msg.say(`Are you sure you want to softban ${member.user.tag} (${member.id})?`); - const verification = await verify(msg.channel, msg.author); - if (!verification) return msg.say('Aborting.'); - try { - await member.send(stripIndents` - You were softbanned from ${msg.guild.name} by ${msg.author.tag}! - **Reason**: ${reason} - `); - } catch (err) { - await msg.say('Failed to send DM.'); - } - try { - await member.ban({ - days: 7, - reason: `${msg.author.tag}: ${reason} (Softban)` - }); - await msg.guild.unban(member.user, 'Softban'); - } catch (err) { - return msg.reply(`Failed to softban ${member.user.tag}: \`${err.message}\`.`); - } - return msg.say(`Successfully softbanned ${member.user.tag}.`); - } -}; diff --git a/commands/moderation/unban.js b/commands/moderation/unban.js deleted file mode 100644 index 0a336d7a..00000000 --- a/commands/moderation/unban.js +++ /dev/null @@ -1,49 +0,0 @@ -const { Command } = require('discord.js-commando'); -const { verify } = require('../../util/Util'); - -module.exports = class UnbanCommand extends Command { - constructor(client) { - super(client, { - name: 'unban', - aliases: ['unbanne'], - group: 'moderation', - memberName: 'unban', - description: 'Unbans a user.', - guildOnly: true, - clientPermissions: ['BAN_MEMBERS'], - userPermissions: ['BAN_MEMBERS'], - args: [ - { - key: 'id', - prompt: 'What is the id of the member you want to unban?', - type: 'string', - validate: id => { - if (/^[0-9]+$/.test(id)) return true; - return 'Invalid ID.'; - } - }, - { - key: 'reason', - prompt: 'What do you want to set the reason as?', - type: 'string', - max: 140 - } - ] - }); - } - - async run(msg, { id, reason }) { - const bans = await msg.guild.fetchBans(); - if (!bans.has(id)) return msg.reply('This ID is not in the server banlist.'); - const member = bans.get(id).user; - await msg.say(`Are you sure you want to unban ${member.tag} (${member.id})?`); - const verification = await verify(msg.channel, msg.author); - if (!verification) return msg.say('Aborting.'); - try { - await msg.guild.unban(member, `${msg.author.tag}: ${reason}`); - } catch (err) { - return msg.reply(`Failed to unban ${member.tag}: \`${err.message}\`.`); - } - return msg.say(`Successfully unbanned ${member.tag}.`); - } -}; diff --git a/commands/moderation/prune.js b/commands/other/prune.js similarity index 97% rename from commands/moderation/prune.js rename to commands/other/prune.js index b1420b93..ba3e6148 100644 --- a/commands/moderation/prune.js +++ b/commands/other/prune.js @@ -5,7 +5,7 @@ module.exports = class PruneCommand extends Command { super(client, { name: 'prune', aliases: ['clear'], - group: 'moderation', + group: 'other', memberName: 'prune', description: 'Deletes up to 99 messages from the current channel.', guildOnly: true, diff --git a/package.json b/package.json index b6bd3a8b..90aabd70 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "52.2.0", + "version": "53.0.0", "description": "Your personal server companion.", "main": "XiaoBot.js", "scripts": {