2020-07-04 12:23:10 +02:00
|
|
|
const { Infraction } = require('../interfaces/');
|
2020-07-16 09:54:39 +02:00
|
|
|
const { GuildMember } = require('../../extensions/');
|
2020-07-04 12:23:10 +02:00
|
|
|
|
|
|
|
class Softban extends Infraction {
|
|
|
|
|
|
|
|
constructor(client, opts = {}) {
|
|
|
|
|
|
|
|
super(client, {
|
|
|
|
type: 'SOFTBAN',
|
|
|
|
targetType: 'user',
|
|
|
|
message: opts.message,
|
|
|
|
executor: opts.executor.user,
|
2020-07-16 09:54:39 +02:00
|
|
|
target: opts.target instanceof GuildMember ? opts.target.user : opts.target,
|
2020-07-04 12:23:10 +02:00
|
|
|
reason: opts.reason || 'N/A',
|
|
|
|
guild: opts.guild,
|
|
|
|
channel: opts.channel,
|
|
|
|
arguments: opts.arguments,
|
|
|
|
silent: opts.silent,
|
|
|
|
color: 0xdb36fc,
|
|
|
|
dictionary: {
|
|
|
|
past: 'softbanned',
|
|
|
|
present: 'softban'
|
2020-07-16 09:54:39 +02:00
|
|
|
},
|
|
|
|
points: opts.points,
|
|
|
|
expiration: opts.expiration,
|
|
|
|
data: opts.data
|
2020-07-04 12:23:10 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
this.client = client;
|
|
|
|
this.member = opts.target;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
async execute() {
|
|
|
|
|
|
|
|
let days = 1;
|
|
|
|
if(this.arguments.days) days = this.arguments.days.value;
|
|
|
|
|
|
|
|
try {
|
|
|
|
await this.guild.members.ban(this.target.id, {
|
|
|
|
reason: this._reason,
|
|
|
|
days
|
|
|
|
});
|
|
|
|
await this.guild.members.unban(this.target.id, this._reason);
|
|
|
|
} catch(error) {
|
|
|
|
return this._fail('INFRACTION_ERROR');
|
|
|
|
}
|
|
|
|
|
|
|
|
await this.handle();
|
|
|
|
return this._succeed();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-07-16 09:54:39 +02:00
|
|
|
verify() {
|
|
|
|
|
|
|
|
if(this.member instanceof GuildMember) {
|
|
|
|
if(!this.member.bannable) return this._fail('C_SOFTBAN_INSUFFICIENTPERMISSIONS');
|
|
|
|
}
|
|
|
|
|
|
|
|
return super._verify();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-07-04 12:23:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Softban;
|