3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Ignore request timeouts when getting audit logs

This commit is contained in:
Dragory 2020-08-11 02:44:54 +03:00
parent 3d1ecc8190
commit ad24d166ce
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -392,18 +392,17 @@ export async function findRelevantAuditLogEntry(
try { try {
auditLogs = await guild.getAuditLogs(5, null, actionType); auditLogs = await guild.getAuditLogs(5, null, actionType);
} catch (e) { } 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 (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); 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 : []; const entries = auditLogs ? auditLogs.entries : [];