ModActions: ignore server errors when getting bans
This commit is contained in:
parent
a7507fa4ef
commit
4f8dc4f0ae
1 changed files with 11 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
import { decorators as d, IPluginOptions, logger, waitForReaction, waitForReply } from "knub";
|
import { decorators as d, IPluginOptions, logger, waitForReaction, waitForReply } from "knub";
|
||||||
import { Attachment, Constants as ErisConstants, Guild, Member, Message, TextChannel, User } from "eris";
|
import { Attachment, Constants as ErisConstants, Guild, Member, Message, TextChannel, User } from "eris";
|
||||||
import DiscordRESTError from "eris/lib/errors/DiscordRESTError"; // tslint:disable-line
|
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 humanizeDuration from "humanize-duration";
|
||||||
import { GuildCases } from "../data/GuildCases";
|
import { GuildCases } from "../data/GuildCases";
|
||||||
import {
|
import {
|
||||||
|
@ -161,8 +162,16 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async isBanned(userId): Promise<boolean> {
|
async isBanned(userId): Promise<boolean> {
|
||||||
const bans = (await this.guild.getBans()) as any;
|
try {
|
||||||
return bans.some(b => b.user.id === userId);
|
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) {
|
async findRelevantAuditLogEntry(actionType: number, userId: string, attempts?: number, attemptDelay?: number) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue