diff options
Diffstat (limited to 'server/src/commands/mod/Slowmode.ts')
| -rw-r--r-- | server/src/commands/mod/Slowmode.ts | 61 |
1 files changed, 61 insertions, 0 deletions
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 |