From ad24d166cef8447c1e996ca3676559543febdabe Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Tue, 11 Aug 2020 02:44:54 +0300 Subject: [PATCH] Ignore request timeouts when getting audit logs --- backend/src/utils.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/backend/src/utils.ts b/backend/src/utils.ts index 6a86c87a..5560af60 100644 --- a/backend/src/utils.ts +++ b/backend/src/utils.ts @@ -392,17 +392,16 @@ 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) { + // If we don't have permission to read audit log, set audit log requests on cooldown auditLogNextAttemptAfterFail.set(guild.id, Date.now() + AUDIT_LOG_FAIL_COOLDOWN); + } else if (isDiscordHTTPError(e) && e.code === 500) { + // Ignore internal server errors which seem to be pretty common with audit log requests + } else if (e.message.startsWith("Request timed out")) { + // Ignore timeouts, try again next loop + } else { + throw e; } - - throw e; } const entries = auditLogs ? auditLogs.entries : [];