Haha-Yes/commands/admin/slowmode.js

54 lines
1.8 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
2018-12-30 01:20:24 +01:00
class PruneCommand extends Command {
constructor() {
super('Slowmode', {
aliases: ['slowmode', 'slow'],
category: 'admin',
2018-12-28 00:43:33 +01:00
args: [
{
2018-12-30 01:20:24 +01:00
id: "slowmodeNumber",
type: "integer"
},
{
2018-12-30 01:20:24 +01:00
id: "realtime",
type: "integer",
optional: true,
2018-12-28 00:43:33 +01:00
}
2018-12-30 01:20:24 +01:00
],
clientPermissions: ['MANAGE_CHANNELS'],
userPermissions: ['MANAGE_CHANNELS'],
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
});
}
2018-12-30 01:20:24 +01:00
async exec(message,args) {
let slowmodeNumber = args.slowmodeNumber;
let realtime = args.realtime;
if (slowmodeNumber > 120)
2018-12-30 01:20:24 +01:00
return message.channel.send("Slowmode can only be set to 120 seconds or lower!");
2018-12-28 00:43:33 +01:00
message.channel.setRateLimitPerUser(slowmodeNumber);
if (realtime) {
2018-12-30 01:20:24 +01:00
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 {
2018-12-30 01:20:24 +01:00
if (slowmodeNumber == 0)
return message.channel.send("Slowmode have been disabled!")
return message.channel.send(`Slowmode have been set to ${slowmodeNumber} seconds!`);
}
2018-12-30 01:20:24 +01:00
}
}
2018-12-30 01:20:24 +01:00
module.exports = PruneCommand;