54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
const { Infraction } = require('../interfaces/');
|
|
const { Util } = require('../../../util/');
|
|
|
|
class SlowmodeInfraction extends Infraction {
|
|
|
|
constructor(client, opts = {}) {
|
|
|
|
super(client, {
|
|
type: 'SLOWMODE',
|
|
targetType: 'CHANNEL',
|
|
message: opts.message,
|
|
executor: opts.executor.user,
|
|
target: opts.target,
|
|
reason: opts.reason,
|
|
guild: opts.guild,
|
|
channel: opts.channel,
|
|
arguments: opts.arguments,
|
|
silent: opts.silent,
|
|
duration: opts.duration,
|
|
points: opts.points,
|
|
expiration: opts.expiration,
|
|
data: opts.data
|
|
});
|
|
|
|
this.client = client;
|
|
|
|
}
|
|
|
|
async execute() {
|
|
|
|
if(this.target.rateLimitPerUser === this.data.seconds) {
|
|
return this._fail('C_SLOWMODE_NOCHANGE');
|
|
}
|
|
|
|
try {
|
|
this.target.edit({
|
|
rateLimitPerUser: this.data.seconds
|
|
}, this._reason);
|
|
} catch(e) {
|
|
return this._fail('INFRACTION_ERROR');
|
|
}
|
|
|
|
await this.handle();
|
|
return this._succeed();
|
|
|
|
}
|
|
|
|
description() {
|
|
return `\n${this.guild.format('INFRACTION_DESCRIPTIONDURATION', { duration: Util.duration(this.data.seconds) })}`;
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = SlowmodeInfraction; |