Haha-Yes/commands/admin/slowmode.js

65 lines
1.7 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', {
2019-06-23 03:41:59 +02:00
aliases: ['slowmode', 'slow', 'cooldown'],
2019-01-02 08:09:45 +01:00
category: 'admin',
args: [
{
id: 'slowmodeNumber',
2019-06-23 03:41:59 +02:00
prompt: {
start: 'what do you want the delay to be between each message?',
},
2019-01-02 08:09:45 +01:00
type: 'integer'
},
{
id: 'realtime',
2019-06-23 03:41:59 +02:00
prompt: {
start: 'For how long should the slowmode last?',
optional: true
},
2019-01-02 08:09:45 +01:00
type: 'integer',
}
],
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;