From ddd695084a03c48e5a619e888b4a72b064259cc0 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Fri, 8 Dec 2023 15:40:37 +0200 Subject: [PATCH] catch errors --- src/client/infractions/Ban.ts | 2 +- src/client/infractions/Softban.ts | 2 +- src/client/interfaces/CommandOption.ts | 4 ++-- src/client/interfaces/Infraction.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/infractions/Ban.ts b/src/client/infractions/Ban.ts index 87845cd..78a9866 100644 --- a/src/client/infractions/Ban.ts +++ b/src/client/infractions/Ban.ts @@ -73,7 +73,7 @@ class BanInfraction extends Infraction async verify () { - const member = await this.guild.resolveMember(this.target!.id); + const member = await this.guild.resolveMember(this.target!.id).catch(() => null); if (member && !member.bannable) return super._fail('C_BAN_CANNOTBEBANNED'); diff --git a/src/client/infractions/Softban.ts b/src/client/infractions/Softban.ts index 318758e..6e4da42 100644 --- a/src/client/infractions/Softban.ts +++ b/src/client/infractions/Softban.ts @@ -53,7 +53,7 @@ class SoftbanInfraction extends Infraction { await this.guild.members.ban(this.target!.id, { reason: this._reason, - deleteMessageDays: days + deleteMessageSeconds: days * 24 * 60 * 60 }); await this.guild.members.unban(this.target!.id, this._reason); } diff --git a/src/client/interfaces/CommandOption.ts b/src/client/interfaces/CommandOption.ts index 52f75c5..a8e1551 100644 --- a/src/client/interfaces/CommandOption.ts +++ b/src/client/interfaces/CommandOption.ts @@ -353,7 +353,7 @@ class CommandOption throw new Error('Invalid rawValue'); for (const arg of this.#rawValue) { - const member = await this.#guild.resolveMember(arg, this.strict); + const member = await this.#guild.resolveMember(arg, this.strict).catch(() => null); if (member) { members.push(member); @@ -618,7 +618,7 @@ class CommandOption throw new Error('Missing guild'); if (typeof this.#rawValue !== 'string') throw new Error('Invalid rawValue'); - const member = await this.#guild.resolveMember(this.#rawValue, this.strict); + const member = await this.#guild.resolveMember(this.#rawValue, this.strict).catch(() => null); if (!member) return { error: true }; return { value: member, removed: [ this.#rawValue ] }; diff --git a/src/client/interfaces/Infraction.ts b/src/client/interfaces/Infraction.ts index cd5db55..a65320e 100644 --- a/src/client/interfaces/Infraction.ts +++ b/src/client/interfaces/Infraction.ts @@ -874,7 +874,7 @@ class Infraction else if (type) { if (Util.isMemberResolveable(target)) - fetched = await this.#guild.memberWrapper(target); // await this.#client.resolver.resolveMember(target, this.#guild, true); + fetched = await this.#guild.memberWrapper(target).catch(() => null); // await this.#client.resolver.resolveMember(target, this.#guild, true); if (!fetched && Util.isUserResolveable(target)) fetched = await this.#client.getUserWrapper(target); // await this.#client.resolver.resolveUser(target, true);