2018-12-28 00:43:33 +01:00
|
|
|
const { Command } = require('discord.js-commando');
|
|
|
|
|
|
|
|
module.exports = class CustomResponseCommand extends Command {
|
|
|
|
constructor(client) {
|
|
|
|
super(client, {
|
|
|
|
name: 'slowmode',
|
|
|
|
aliases: ['slow'],
|
|
|
|
group: 'admin',
|
|
|
|
memberName: 'slowmode',
|
|
|
|
description: `Custom auto response`,
|
|
|
|
userPermissions: ['MANAGE_CHANNELS'],
|
|
|
|
clientPermissions: ['MANAGE_CHANNELS'],
|
|
|
|
args: [
|
|
|
|
{
|
|
|
|
key: 'slowmodeNumber',
|
|
|
|
prompt: 'How many seconds should the slowmode be? ( 0 to remove it )',
|
|
|
|
type: 'integer',
|
2018-12-28 01:08:01 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'realtime',
|
|
|
|
prompt: 'How long shoud it remain',
|
|
|
|
default: '',
|
|
|
|
type: 'integer',
|
2018-12-28 00:43:33 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-12-28 01:08:01 +01:00
|
|
|
async run(message, { slowmodeNumber, realtime }) {
|
|
|
|
if (slowmodeNumber > 120)
|
|
|
|
return message.say("Slowmode can only be set to 120 seconds or lower!");
|
|
|
|
|
2018-12-28 00:43:33 +01:00
|
|
|
message.channel.setRateLimitPerUser(slowmodeNumber);
|
2018-12-28 01:08:01 +01:00
|
|
|
|
|
|
|
if (realtime) {
|
|
|
|
let time = 60000 * realtime;
|
|
|
|
message.say(`Slowmode have been set to ${slowmodeNumber} seconds and will end in ${realtime} minutes!`);
|
2018-12-28 01:16:45 +01:00
|
|
|
setTimeout (function (){
|
2018-12-28 01:08:01 +01:00
|
|
|
message.channel.setRateLimitPerUser(0);
|
2018-12-28 01:16:45 +01:00
|
|
|
return message.say("Slowmode is now disabled!")
|
2018-12-28 01:08:01 +01:00
|
|
|
}, time);
|
|
|
|
} else {
|
|
|
|
if (slowmodeNumber == 0)
|
|
|
|
return message.say("Slowmode have been disabled!")
|
|
|
|
return message.say(`Slowmode have been set to ${slowmodeNumber} seconds!`);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-12-28 00:43:33 +01:00
|
|
|
}
|
|
|
|
};
|