catch errors

This commit is contained in:
Erik 2023-12-08 15:40:37 +02:00
parent 8c6ba57db4
commit ddd695084a
4 changed files with 5 additions and 5 deletions

View File

@ -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');

View File

@ -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);
}

View File

@ -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 ] };

View File

@ -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);