Improve audit log error handling, show BOT_ALERT in more cases

This commit is contained in:
Dragory 2020-08-05 02:25:13 +03:00
parent ffc25791ca
commit 5ea0f7eb46
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
7 changed files with 30 additions and 24 deletions

View file

@ -376,16 +376,17 @@ export async function findRelevantAuditLogEntry(
try {
auditLogs = await guild.getAuditLogs(5, null, actionType);
} catch (e) {
// Ignore internal server errors which seem to be pretty common with audit log requests
if (!isDiscordHTTPError(e) || e.code !== 500) {
// Ignore, try again next attempt
}
// If we don't have permission to read audit log, set audit log requests on cooldown
if (isDiscordRESTError(e) && e.code === 50013) {
auditLogNextAttemptAfterFail.set(guild.id, Date.now() + AUDIT_LOG_FAIL_COOLDOWN);
throw e;
}
// Ignore internal server errors which seem to be pretty common with audit log requests
if (!isDiscordHTTPError(e) || e.code !== 500) {
throw e;
}
throw e;
}
const entries = auditLogs ? auditLogs.entries : [];