Haha-Yes/commands/admin/slowmode.js

59 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-12-30 01:20:24 +01:00
const { Command } = require('discord-akairo');
2018-12-28 00:43:33 +01:00
2019-01-12 21:05:42 +01:00
class SlowmodeCommand extends Command {
2019-01-02 08:09:45 +01:00
constructor() {
super('Slowmode', {
aliases: ['slowmode', 'slow'],
category: 'admin',
args: [
{
id: 'slowmodeNumber',
type: 'integer'
},
{
id: 'realtime',
type: 'integer',
optional: true,
}
],
clientPermissions: ['MANAGE_CHANNELS'],
2019-01-14 20:07:15 +01:00
userPermissions: ['MANAGE_MESSAGES'],
2019-01-02 08:09:45 +01:00
channelRestriction: 'guild',
description: {
content: 'Put a channel in slowmode',
usage: '[1-120 slowmode] [time it stays on]',
examples: ['267065637183029248']
}
});
}
2018-12-28 00:43:33 +01:00
2019-01-02 08:09:45 +01:00
async exec(message,args) {
try {
let slowmodeNumber = args.slowmodeNumber;
let realtime = args.realtime;
if (slowmodeNumber > 120)
return message.channel.send('Slowmode can only be set to 120 seconds or lower!');
message.channel.setRateLimitPerUser(slowmodeNumber);
if (realtime) {
let time = 60000 * realtime;
message.channel.send(`Slowmode have been set to ${slowmodeNumber} seconds and will end in ${realtime} minutes!`);
setTimeout (function (){
message.channel.setRateLimitPerUser(0);
return message.channel.send('Slowmode is now disabled!');
}, time);
} else {
if (slowmodeNumber == 0)
return message.channel.send('Slowmode have been disabled!');
return message.channel.send(`Slowmode have been set to ${slowmodeNumber} seconds!`);
}
} catch (err) {
console.error(err);
2019-01-02 08:09:45 +01:00
}
2019-01-02 08:09:45 +01:00
}
2018-12-30 01:20:24 +01:00
}
2019-01-12 21:05:42 +01:00
module.exports = SlowmodeCommand;