forked from Galactic/galactic-bot
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
const { Infraction } = require('../interfaces/');
|
|
const { GuildMember } = require('../../extensions/');
|
|
|
|
class SoftbanInfraction extends Infraction {
|
|
|
|
static type = 'SOFTBAN';
|
|
|
|
constructor(client, opts = {}) {
|
|
|
|
super(client, {
|
|
targetType: 'USER',
|
|
type: opts.type,
|
|
message: opts.message,
|
|
executor: opts.executor.user,
|
|
target: opts.target instanceof GuildMember ? opts.target.user : opts.target,
|
|
reason: opts.reason,
|
|
guild: opts.guild,
|
|
channel: opts.channel,
|
|
arguments: opts.arguments,
|
|
silent: opts.silent,
|
|
points: opts.points,
|
|
expiration: opts.expiration,
|
|
data: opts.data,
|
|
hyperlink: opts.hyperlink
|
|
});
|
|
|
|
this.client = client;
|
|
}
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
verify() {
|
|
|
|
if(this.target instanceof GuildMember) {
|
|
if(!this.target.bannable) return this._fail('C_SOFTBAN_CANNOTBESOFTBANNED');
|
|
}
|
|
|
|
return super._verify();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = SoftbanInfraction; |