slight change to the infraction constructors

This commit is contained in:
Erik 2022-04-30 22:05:51 +03:00
parent 7a2fa4df3c
commit 3bc2a900e4
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
14 changed files with 188 additions and 158 deletions

View File

@ -8,27 +8,30 @@ class AddroleInfraction extends Infraction {
constructor(client, opts = {}) {
super(client, {
targetType: 'USER',
type: opts.type,
guild: opts.guild,
channel: opts.channel,
invoker: opts.invoker,
target: opts.target.user,
executor: opts.executor.user,
reason: opts.reason,
arguments: opts.arguments,
silent: opts.silent,
duration: opts.duration,
points: opts.points,
expiration: opts.expiration,
data: opts.data,
hyperlink: opts.hyperlink
});
if (opts.fetched) super(client, opts);
else {
super(client, {
targetType: 'USER',
type: opts.type,
guild: opts.guild,
channel: opts.channel,
invoker: opts.invoker,
target: opts.target.user,
executor: opts.executor.user,
reason: opts.reason,
arguments: opts.arguments,
silent: opts.silent,
duration: opts.duration,
points: opts.points,
expiration: opts.expiration,
data: opts.data,
hyperlink: opts.hyperlink
});
if (!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
this.member = opts.target;
this.executorMember = opts.executor;
if (!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
this.member = opts.target;
this.executorMember = opts.executor;
}
}

View File

@ -7,25 +7,28 @@ class KickInfraction extends Infraction {
constructor(client, opts = {}) {
super(client, {
targetType: 'USER',
type: opts.type,
invoker: opts.invoker,
executor: opts.executor.user,
target: opts.target.user,
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
});
if (opts.fetched) super(client, opts);
else {
super(client, {
targetType: 'USER',
type: opts.type,
invoker: opts.invoker,
executor: opts.executor.user,
target: opts.target.user,
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
});
if (!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
this.member = opts.target;
if (!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
this.member = opts.target;
}
}

View File

@ -8,7 +8,8 @@ class LockdownInfraction extends Infraction {
constructor(client, opts = {}) {
super(client, {
if (opts.fetched) super(client, opts);
else super(client, {
targetType: 'CHANNEL',
type: opts.type,
invoker: opts.invoker,

View File

@ -16,24 +16,27 @@ class NicknameInfraction extends Infraction {
constructor(client, opts = {}) {
super(client, {
targetType: 'USER',
type: opts.type,
executor: opts.executor.user,
target: opts.target.user,
reason: opts.reason,
guild: opts.guild,
arguments: opts.arguments,
channel: opts.channel,
silent: opts.silent,
points: opts.points,
expiration: opts.expiration,
data: opts.data,
hyperlink: opts.hyperlink
});
if (opts.fetched) super(client, opts);
else {
super(client, {
targetType: 'USER',
type: opts.type,
executor: opts.executor.user,
target: opts.target.user,
reason: opts.reason,
guild: opts.guild,
arguments: opts.arguments,
channel: opts.channel,
silent: opts.silent,
points: opts.points,
expiration: opts.expiration,
data: opts.data,
hyperlink: opts.hyperlink
});
if (!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
this.member = opts.target;
if (!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
this.member = opts.target;
}
}

View File

@ -5,8 +5,9 @@ class NoteInfraction extends Infraction {
static type = 'NOTE';
constructor(client, opts = {}) {
super(client, {
if (opts.fetched) super(client, opts);
else super(client, {
targetType: 'USER',
arguments: opts.arguments,
type: opts.type,
@ -22,9 +23,6 @@ class NoteInfraction extends Infraction {
hyperlink: opts.hyperlink
});
// if (!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
// this.member = opts.target;
}
async execute() {

View File

@ -9,24 +9,27 @@ class PruneInfraction extends Infraction {
constructor(client, opts = {}) {
super(client, {
targetType: 'CHANNEL',
type: opts.type,
invoker: opts.invoker,
arguments: opts.arguments,
executor: opts.executor.user,
target: opts.target,
reason: opts.reason,
guild: opts.guild,
channel: opts.channel,
silent: opts.silent,
points: opts.points,
expiration: opts.expiration,
data: opts.data,
hyperlink: opts.hyperlink
});
if (opts.fetched) super(client, opts);
else {
super(client, {
targetType: 'CHANNEL',
type: opts.type,
invoker: opts.invoker,
arguments: opts.arguments,
executor: opts.executor.user,
target: opts.target,
reason: opts.reason,
guild: opts.guild,
channel: opts.channel,
silent: opts.silent,
points: opts.points,
expiration: opts.expiration,
data: opts.data,
hyperlink: opts.hyperlink
});
this.channel = opts.target;
this.channel = opts.target;
}
}

View File

@ -8,27 +8,30 @@ class RemoveroleInfraction extends Infraction {
constructor(client, opts = {}) {
super(client, {
targetType: 'USER',
type: opts.type,
invoker: opts.invoker,
executor: opts.executor.user,
target: opts.target.user,
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,
hyperlink: opts.hyperlink
});
if (opts.fetched) super(client, opts);
else {
super(client, {
targetType: 'USER',
type: opts.type,
invoker: opts.invoker,
executor: opts.executor.user,
target: opts.target.user,
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,
hyperlink: opts.hyperlink
});
if (!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
this.member = opts.target;
this.executorMember = opts.executor;
if (!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
this.member = opts.target;
this.executorMember = opts.executor;
}
}

View File

@ -7,7 +7,8 @@ class SlowmodeInfraction extends Infraction {
constructor(client, opts = {}) {
super(client, {
if (opts.fetched) super(client, opts);
else super(client, {
targetType: 'CHANNEL',
type: opts.type,
invoker: opts.invoker,

View File

@ -7,7 +7,8 @@ class SoftbanInfraction extends Infraction {
constructor(client, opts = {}) {
super(client, {
if (opts.fetched) super(client, opts);
else super(client, {
targetType: 'USER',
type: opts.type,
invoker: opts.invoker,

View File

@ -7,7 +7,8 @@ class UnbanInfraction extends Infraction {
constructor(client, opts = {}) {
super(client, {
if (opts.fetched) super(client, opts);
else super(client, {
targetType: 'USER',
type: opts.type,
invoker: opts.invoker,

View File

@ -6,7 +6,8 @@ class UnlockdownInfraction extends Infraction {
constructor(client, opts = {}) {
super(client, {
if (opts.fetched) super(client, opts);
else super(client, {
targetType: 'CHANNEL',
type: opts.type,
invoker: opts.invoker,
@ -20,6 +21,7 @@ class UnlockdownInfraction extends Infraction {
data: opts.data,
hyperlink: opts.hyperlink
});
}

View File

@ -8,26 +8,29 @@ class UnmuteInfraction extends Infraction {
constructor(client, opts = {}) {
super(client, {
targetType: 'USER',
type: opts.type,
invoker: opts.invoker,
executor: opts.executor.user,
target: opts.target.user,
reason: opts.reason,
guild: opts.guild,
channel: opts.channel,
arguments: opts.arguments,
silent: opts.silent,
duration: opts.duration,
hyperlink: opts.hyperlink,
points: opts.points,
expiration: opts.expiration,
data: opts.data
});
if (opts.fetched) super(client, opts);
else {
super(client, {
targetType: 'USER',
type: opts.type,
invoker: opts.invoker,
executor: opts.executor.user,
target: opts.target.user,
reason: opts.reason,
guild: opts.guild,
channel: opts.channel,
arguments: opts.arguments,
silent: opts.silent,
duration: opts.duration,
hyperlink: opts.hyperlink,
points: opts.points,
expiration: opts.expiration,
data: opts.data
});
if (!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
this.member = opts.target;
if (!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
this.member = opts.target;
}
}

View File

@ -7,25 +7,28 @@ class VckickInfraction extends Infraction {
constructor(client, opts = {}) {
super(client, {
targetType: 'USER',
type: opts.type,
invoker: opts.invoker,
executor: opts.executor.user,
target: opts.target.user,
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
});
if (opts.fetched) super(client, opts);
else {
super(client, {
targetType: 'USER',
type: opts.type,
invoker: opts.invoker,
executor: opts.executor.user,
target: opts.target.user,
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
});
if (!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
this.member = opts.target;
if (!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
this.member = opts.target;
}
}

View File

@ -7,25 +7,30 @@ class WarnInfraction extends Infraction {
constructor(client, opts = {}) {
super(client, {
targetType: 'USER',
type: opts.type,
invoker: opts.invoker,
arguments: opts.arguments,
executor: opts.executor.user,
target: opts.target.user,
reason: opts.reason,
guild: opts.guild,
channel: opts.channel,
silent: opts.silent,
points: opts.points,
expiration: opts.expiration,
data: opts.data,
hyperlink: opts.hyperlink
});
if (opts.fetched) super(client, opts);
else {
if(!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
this.member = opts.target;
super(client, {
targetType: 'USER',
type: opts.type,
invoker: opts.invoker,
arguments: opts.arguments,
executor: opts.executor.user,
target: opts.target.user,
reason: opts.reason,
guild: opts.guild,
channel: opts.channel,
silent: opts.silent,
points: opts.points,
expiration: opts.expiration,
data: opts.data,
hyperlink: opts.hyperlink
});
if (!(opts.target instanceof GuildMember)) throw new Error('Guild member required');
this.member = opts.target;
}
}
@ -38,7 +43,7 @@ class WarnInfraction extends Infraction {
// NOTE: If I want to readd permission checking for escalations.
// const permissions = await this.client.permissions.execute(this.message, this.message.command);
// if(permissions.error) return super._fail('C_WARN_INSUFFICIENTPERMISSIONS');
// if(permissions.error) return super._fail('COMMAND_WARN_INSUFFICIENTPERMISSIONS');
return super._verify();