merge conflict fix
commit
c6b665fdde
|
@ -35,6 +35,7 @@ export { default as roleinfo } from './roleinfo';
|
||||||
export { default as score } from './score';
|
export { default as score } from './score';
|
||||||
export { default as sip } from './sip';
|
export { default as sip } from './sip';
|
||||||
export { default as site } from './site';
|
export { default as site } from './site';
|
||||||
|
export { default as slowmode } from './slowmode';
|
||||||
export { default as stats } from './stats';
|
export { default as stats } from './stats';
|
||||||
export { default as storemessages } from './storemessages';
|
export { default as storemessages } from './storemessages';
|
||||||
export { default as sysinfo } from './sysinfo';
|
export { default as sysinfo } from './sysinfo';
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
import { Message, GuildTextableChannel } from 'eris';
|
||||||
|
import moment, { unitOfTime } from 'moment';
|
||||||
|
import { Client, Command } from '../class';
|
||||||
|
|
||||||
|
export default class Slowmode extends Command {
|
||||||
|
regex: RegExp;
|
||||||
|
|
||||||
|
constructor(client: Client) {
|
||||||
|
super(client);
|
||||||
|
this.name = 'slowmode';
|
||||||
|
this.description = 'Set slowmode to a channel.';
|
||||||
|
this.usage = 'slowmode <length[unit]>';
|
||||||
|
this.permissions = 1;
|
||||||
|
this.guildOnly = true;
|
||||||
|
this.enabled = true;
|
||||||
|
this.regex = /[a-z]+|[^a-z]+/gi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async run(message: Message<GuildTextableChannel>, args: string[]) {
|
||||||
|
try {
|
||||||
|
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||||
|
|
||||||
|
const [length, unit] = args[0].match(this.regex);
|
||||||
|
if (Number.isNaN(Number(length))) return this.error(message.channel, 'Could not determine the slowmode time.');
|
||||||
|
const momentSeconds: number = Math.round(moment.duration(length, unit as unitOfTime.Base || 's').asSeconds());
|
||||||
|
|
||||||
|
if (momentSeconds > 21600 || momentSeconds < 0) return this.error(message.channel, 'Slowmode must be between 0 seconds and 6 hours.');
|
||||||
|
|
||||||
|
return message.channel.edit({ rateLimitPerUser: momentSeconds }).then((c) => message.addReaction(':success:477618704155410452'));
|
||||||
|
} catch (err) {
|
||||||
|
return this.client.util.handleError(err, message, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue