1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
import { Command } from 'discord-akairo';
import { Message } from 'discord.js';
import { TextChannel } 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) {
amount = 120;
msg.channel.send('Due to Discord API limitations, slow mode can only be a max of **120** seconds or less! Your specified amount has been rounded down to **120** seconds. (This message will automatically be deleted in 10 seconds.)')
.then(m => m.delete({ timeout: 10000 }));
}
(msg.channel as TextChannel).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 as TextChannel).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);
}
}
}
|