2020-07-04 12:23:10 +02:00
|
|
|
const { Infraction } = require('../interfaces/');
|
|
|
|
const { Util } = require('../../../util/');
|
|
|
|
|
2020-07-30 14:41:17 +02:00
|
|
|
class SlowmodeInfraction extends Infraction {
|
2020-07-04 12:23:10 +02:00
|
|
|
|
|
|
|
constructor(client, opts = {}) {
|
|
|
|
|
|
|
|
super(client, {
|
|
|
|
type: 'SLOWMODE',
|
|
|
|
targetType: 'channel',
|
|
|
|
message: opts.message,
|
|
|
|
executor: opts.executor.user,
|
|
|
|
target: opts.target,
|
|
|
|
reason: opts.reason || 'N/A',
|
|
|
|
guild: opts.guild,
|
|
|
|
channel: opts.channel,
|
|
|
|
arguments: opts.arguments,
|
|
|
|
silent: opts.silent,
|
|
|
|
duration: opts.duration,
|
|
|
|
color: 0xff3333,
|
|
|
|
dictionary: {
|
|
|
|
past: 'set slowmode in',
|
|
|
|
present: 'slowmode'
|
|
|
|
},
|
2020-07-16 09:54:39 +02:00
|
|
|
points: opts.points,
|
|
|
|
expiration: opts.expiration,
|
2020-07-04 12:23:10 +02:00
|
|
|
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) })}`;
|
|
|
|
}
|
|
|
|
|
2020-07-20 00:42:21 +02:00
|
|
|
verify() {
|
|
|
|
|
2020-07-28 22:40:15 +02:00
|
|
|
const missing = this.guild._checkPermissions(this.message, 'command:slowmode');
|
2020-07-20 00:42:21 +02:00
|
|
|
if(missing.length > 0) {
|
|
|
|
return super._fail('C_SLOWMODE_INSUFFICIENTPERMISSIONS');
|
|
|
|
}
|
|
|
|
|
|
|
|
return super._verify();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-07-04 12:23:10 +02:00
|
|
|
}
|
|
|
|
|
2020-07-30 14:41:17 +02:00
|
|
|
module.exports = SlowmodeInfraction;
|