3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Change DiscordRESTError to DiscordAPIError

This commit is contained in:
Dark 2021-06-30 23:06:02 +02:00
parent be71357ff9
commit 1ad70ffe1a
No known key found for this signature in database
GPG key ID: 384C4B4F5B1E25A8
18 changed files with 50 additions and 50 deletions

View file

@ -1,7 +1,7 @@
import { GuildPluginData } from "knub";
import { LogType } from "../data/LogType";
import { LogsPlugin } from "../plugins/Logs/LogsPlugin";
import { findRelevantAuditLogEntry, isDiscordRESTError } from "../utils";
import { findRelevantAuditLogEntry, isDiscordAPIError } from "../utils";
/**
* Wrapper for findRelevantAuditLogEntry() that handles permission errors gracefully.
@ -17,7 +17,7 @@ export async function safeFindRelevantAuditLogEntry(
try {
return await findRelevantAuditLogEntry(pluginData.guild, actionType, userId, attempts, attemptDelay);
} catch (e) {
if (isDiscordRESTError(e) && e.code === 50013) {
if (isDiscordAPIError(e) && e.code === 50013) {
const logs = pluginData.getPlugin(LogsPlugin);
logs.log(LogType.BOT_ALERT, {
body: "Missing permissions to read audit log",

View file

@ -1,6 +1,6 @@
import { MessagePayload, User } from "discord.js";
import { logger } from "../logger";
import { createChunkedMessage, HOURS, isDiscordRESTError } from "../utils";
import { createChunkedMessage, HOURS, isDiscordAPIError } from "../utils";
import Timeout = NodeJS.Timeout;
let dmsDisabled = false;
@ -30,7 +30,7 @@ export async function sendDM(user: User, content: string | MessagePayload, sourc
await user.send(content);
}
} catch (e) {
if (isDiscordRESTError(e) && e.code === 20026) {
if (isDiscordAPIError(e) && e.code === 20026) {
logger.warn(`Received error code 20026: ${e.message}`);
logger.warn("Disabling attempts to send DMs for 1 hour");
disableDMs(1 * HOURS);