mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-22 01:05:02 +00:00
WIP ModActions
This commit is contained in:
parent
aef2b4f43a
commit
b72a76b27e
25 changed files with 1162 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue