diff options
| author | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
| commit | bb511abc03bb66848947e37a999502b813c77269 (patch) | |
| tree | 612c010fc8317e1cdf11471a18aad0270819d33e /server/src/commands/mod | |
| parent | fix: if clear amount equal or over 100, round down to 99 (diff) | |
| download | dep-core-bb511abc03bb66848947e37a999502b813c77269.tar.xz dep-core-bb511abc03bb66848947e37a999502b813c77269.zip | |
goodbye old uwufier :cry:
Diffstat (limited to 'server/src/commands/mod')
| -rw-r--r-- | server/src/commands/mod/Ban.ts | 64 | ||||
| -rw-r--r-- | server/src/commands/mod/Kick.ts | 57 | ||||
| -rw-r--r-- | server/src/commands/mod/Prune.ts | 39 | ||||
| -rw-r--r-- | server/src/commands/mod/Slowmode.ts | 61 | ||||
| -rw-r--r-- | server/src/commands/mod/Unban.ts | 38 |
5 files changed, 259 insertions, 0 deletions
diff --git a/server/src/commands/mod/Ban.ts b/server/src/commands/mod/Ban.ts new file mode 100644 index 0000000..d91731e --- /dev/null +++ b/server/src/commands/mod/Ban.ts @@ -0,0 +1,64 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; + +export default class BanMod extends Command { + public constructor() { + super('ban', { + aliases: ['ban', 'banish'], + category: 'moderation', + description: { + content: 'Ban a specified user from the server.', + usage: '[user] [reason(s)]', + examples: [ + '@sin#1337', + '@sin#1337 too cool' + ] + }, + ratelimit: 3, + channel: 'guild', + clientPermissions: ['BAN_MEMBERS'], + userPermissions: ['BAN_MEMBERS'], + args: [ + { + id: 'user', + type: 'string', + prompt: { + start: 'Which user would you like to ban?', + retry: 'That doesn\' seem to be a user, please try again!' + } + }, + { + id: 'reason', + type: 'string', + prompt: { + start: 'For what reason would you like to ban this user?', + optional: true + }, + match: 'rest' + } + ] + }); + } + + public async exec(msg: Message, { user, reason }): Promise<Message> { + if (msg.mentions.members.first()) user = msg.mentions.members.first().id; + + if (user === this.client.user.id) return msg.channel.send('You can\'t ban me!'); + if (!reason) reason = 'No reason has been specified.'; + if (user === msg.author.id) return msg.channel.send('You can\'t ban yourself!'); + + if (msg.mentions.members.first()) { + user = msg.mentions.members.first(); + await user.send(`You have been banned from **${msg.guild.name}** for the following reason(s): "**${reason}**".`); + // .catch(() => console.log('[ERROR] Could not send message to banned user.')); + + return user.ban({ reason: `Banned by: ${msg.author.username} for the following reason(s): ${reason}.`}) + .then(() => msg.reply(`${user.user.username} was successfully banned with the following reason(s): "**${reason}**".`)) + .catch(err => console.error(err)); + } else { + msg.guild.members.ban(user, { reason: `Banned by: ${msg.author.username} for the following reason(s): ${reason}.`}) + .then(() => msg.reply(`User ID ${user} was successfully banned with the following reason(s): "**${reason}**".`)) + .catch(err => console.error(err)); + } + } +}
\ No newline at end of file diff --git a/server/src/commands/mod/Kick.ts b/server/src/commands/mod/Kick.ts new file mode 100644 index 0000000..3295c2a --- /dev/null +++ b/server/src/commands/mod/Kick.ts @@ -0,0 +1,57 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; + +export default class KickMod extends Command { + public constructor() { + super('kick', { + aliases: ['kick'], + category: 'moderation', + description: { + content: 'Kick a specified user from the server.', + usage: '[user] [reason(s)]', + examples: [ + '@sin#1337', + '@sin#1337 too cool' + ] + }, + ratelimit: 3, + channel: 'guild', + clientPermissions: ['KICK_MEMBERS'], + userPermissions: ['KICK_MEMBERS'], + args: [ + { + id: 'user', + type: 'string', + prompt: { + start: 'Which user would you like to kick?', + retry: 'That doesn\' seem to be a user, please try again!' + } + }, + { + id: 'reason', + type: 'string', + prompt: { + start: 'For what reason would you like to kick this user?', + optional: true + }, + match: 'rest' + } + ] + }); + } + + public async exec(msg: Message, { user, reason }): Promise<Message> { + if (msg.mentions.members.first()) user = msg.mentions.members.first().id; + + if (user === this.client.user.id) return msg.channel.send('You can\'t kick me!'); + if (!reason) reason = 'No reason has been specified.'; + if (user === msg.author.id) return msg.channel.send('You can\'t kick yourself!'); + + await user.send(`You have been kick from **${msg.guild.name}** for the following reason(s): "**${reason}**".`); + // .catch(() => console.log('[ERROR] Could not send message to banned user.')); + + return user.kick({ reason: `Kicked by: ${msg.author.username} for the following reason(s): ${reason}.`}) + .then(() => msg.reply(`${user.user.username} was successfully kick with the following reason(s): "**${reason}**".`)) + .catch(err => console.error(err)); + } +}
\ No newline at end of file diff --git a/server/src/commands/mod/Prune.ts b/server/src/commands/mod/Prune.ts new file mode 100644 index 0000000..bf56846 --- /dev/null +++ b/server/src/commands/mod/Prune.ts @@ -0,0 +1,39 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; +import { TextChannel } from 'discord.js'; + +export default class PruneMod extends Command { + public constructor() { + super('prune', { + aliases: ['prune', 'clear', 'purge'], + category: 'moderation', + description: { + content: 'Bulk delete a specified amount of message from the server.', + usage: '[amount]', + examples: [ + '50' + ] + }, + ratelimit: 3, + channel: 'guild', + clientPermissions: ['MANAGE_MESSAGES'], + userPermissions: ['MANAGE_MESSAGES'], + args: [ + { + id: 'amount', + type: 'integer', + prompt: { + start: 'How many messages would you like to delete?' + } + } + ] + }); + } + + public exec(msg: Message, { amount }): Promise<Message> { + if (amount <= 100) amount = 99; + (msg.channel as TextChannel).bulkDelete(amount, true); + return msg.reply('Due to Discord API limitations, the amount of messages you have specified has been rounded down to **99**. (This message will automatically be deleted in 3 seconds.)') + .then(m => m.delete({ timeout: 3000 })); + } +}
\ No newline at end of file diff --git a/server/src/commands/mod/Slowmode.ts b/server/src/commands/mod/Slowmode.ts new file mode 100644 index 0000000..1d626ec --- /dev/null +++ b/server/src/commands/mod/Slowmode.ts @@ -0,0 +1,61 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; + +export default class SlowmodeMod extends Command { + public constructor() { + super('slowmode', { + aliases: ['slowmode', 'slow', 'cooldown'], + category: 'moderation', + description: { + content: 'Add a specified amount of slowmode to the current channel.', + usage: '[amount 1-120] [time slowmode should be active for]', + examples: [ + '5 60' + ] + }, + ratelimit: 3, + channel: 'guild', + clientPermissions: ['MANAGE_CHANNELS'], + userPermissions: ['MANAGE_CHANNELS'], + args: [ + { + id: 'amount', + type: 'integer', + prompt: { + start: 'What amount of slowmode would you like to add to the channel?' + } + }, + { + id: 'realtime', + type: 'integer', + prompt: { + start: 'How long would you like the slowmode to last?', + optional: true + } + } + ] + }); + } + + public exec(msg: Message, { amount, realtime }): Promise<Message> { + try { + if (amount > 120) return msg.channel.send('Due to Discord API limitations, slow mode can only be a max of **120** seconds or less!'); + + // msg.channel.setRateLimitPerUser(amount); + + if (realtime) { + let time = 60000 * realtime; + msg.channel.send(`Slowmode has now been set to ${amount} seconds and will end in ${realtime} minutes!`); + setTimeout(() => { + // msg.channel.setRateLimitPerUser(0); + return msg.channel.send('Slowmode has now been disabled!'); + }, time); + } else { + if (amount == 0) return msg.channel.send('Slowmode has now been disabled!'); + return msg.channel.send(`Slowmode has now been set to ${amount} seconds!`); + } + } catch (err) { + console.error(err); + } + } +}
\ No newline at end of file diff --git a/server/src/commands/mod/Unban.ts b/server/src/commands/mod/Unban.ts new file mode 100644 index 0000000..7e66af1 --- /dev/null +++ b/server/src/commands/mod/Unban.ts @@ -0,0 +1,38 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; + +export default class UnbanMod extends Command { + public constructor() { + super('unban', { + aliases: ['unban'], + category: 'moderation', + description: { + content: 'Unban a specified user from the server.', + usage: '[user id]', + examples: [ + '50' + ] + }, + ratelimit: 3, + channel: 'guild', + clientPermissions: ['BAN_MEMBERS'], + userPermissions: ['BAN_MEMBERS'], + args: [ + { + id: 'user', + type: 'integer', + prompt: { + start: 'Which user would you like to unban?', + retry: 'That doesn\' seem to be a user ID, please try again!' + } + } + ] + }); + } + + public exec(msg: Message, { user }): Promise<Message> { + return msg.guild.members.unban(user.toString()) // Does this really need to be returned? + .then(() => { return msg.reply(`User ID ${user} was successfully unbanned!`)}) + .catch(() => { return msg.reply('Could not unban the specified user, are they banned in the first place?')}); + } +}
\ No newline at end of file |