Haha-Yes/commands/admin/slowmode.js

51 lines
1.7 KiB
JavaScript
Raw Permalink Normal View History

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',
},
{
key: 'realtime',
prompt: 'How long shoud it remain',
default: '',
type: 'integer',
2018-12-28 00:43:33 +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);
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 (){
message.channel.setRateLimitPerUser(0);
2018-12-28 01:16:45 +01:00
return message.say("Slowmode is now disabled!")
}, 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
}
};