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

WIP ModActions

This commit is contained in:
Dragory 2020-07-23 00:37:33 +03:00
parent aef2b4f43a
commit b72a76b27e
25 changed files with 1162 additions and 6 deletions

View file

@ -0,0 +1,27 @@
import { findRelevantAuditLogEntry, isDiscordRESTError } from "../../../utils";
import { PluginData } from "knub";
import { ModActionsPluginType } from "../types";
import { LogType } from "../../../data/LogType";
/**
* Wrapper for findRelevantAuditLogEntry() that handles permission errors gracefully
*/
export async function safeFindRelevantAuditLogEntry(
pluginData: PluginData<ModActionsPluginType>,
actionType: number,
userId: string,
attempts?: number,
attemptDelay?: number,
) {
try {
return await findRelevantAuditLogEntry(pluginData.guild, actionType, userId, attempts, attemptDelay);
} catch (e) {
if (isDiscordRESTError(e) && e.code === 50013) {
pluginData.state.serverLogs.log(LogType.BOT_ALERT, {
body: "Missing permissions to read audit log",
});
} else {
throw e;
}
}
}