From 4f8dc4f0ae3478610b74469cb5f9535e58a77c5b Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Mon, 5 Aug 2019 01:39:11 +0300 Subject: [PATCH] ModActions: ignore server errors when getting bans --- src/plugins/ModActions.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/plugins/ModActions.ts b/src/plugins/ModActions.ts index dca53619..a3006bd7 100644 --- a/src/plugins/ModActions.ts +++ b/src/plugins/ModActions.ts @@ -1,6 +1,7 @@ import { decorators as d, IPluginOptions, logger, waitForReaction, waitForReply } from "knub"; import { Attachment, Constants as ErisConstants, Guild, Member, Message, TextChannel, User } from "eris"; import DiscordRESTError from "eris/lib/errors/DiscordRESTError"; // tslint:disable-line +import DiscordHTTPError from "eris/lib/errors/DiscordHTTPError"; // tslint:disable-line import humanizeDuration from "humanize-duration"; import { GuildCases } from "../data/GuildCases"; import { @@ -161,8 +162,16 @@ export class ModActionsPlugin extends ZeppelinPlugin { } async isBanned(userId): Promise { - const bans = (await this.guild.getBans()) as any; - return bans.some(b => b.user.id === userId); + try { + const bans = (await this.guild.getBans()) as any; + return bans.some(b => b.user.id === userId); + } catch (e) { + if (e instanceof DiscordHTTPError && e.code === 500) { + return false; + } + + throw e; + } } async findRelevantAuditLogEntry(actionType: number, userId: string, attempts?: number, attemptDelay?: number) {