Improve companion channel error handling

This commit is contained in:
Dragory 2021-08-18 23:02:56 +03:00
parent 929716a958
commit ad800e335c
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -68,14 +68,25 @@ export async function handleCompanionPermissions(
}); });
} }
} catch (e) { } catch (e) {
if (isDiscordAPIError(e) && e.code === 50001) { if (isDiscordAPIError(e)) {
const logs = pluginData.getPlugin(LogsPlugin); const logs = pluginData.getPlugin(LogsPlugin);
if (e.code === 50001) {
logs.logBotAlert({
body: `One of the companion channels can't be accessed. Pausing companion channels for 5 minutes or until the bot is reloaded on this server.`,
});
pluginData.state.errorCooldownManager.setCooldown(ERROR_COOLDOWN_KEY, ERROR_COOLDOWN);
return;
}
if (e.code === 50013) {
logs.logBotAlert({ logs.logBotAlert({
body: `Missing permissions to handle companion channels. Pausing companion channels for 5 minutes or until the bot is reloaded on this server.`, body: `Missing permissions to handle companion channels. Pausing companion channels for 5 minutes or until the bot is reloaded on this server.`,
}); });
pluginData.state.errorCooldownManager.setCooldown(ERROR_COOLDOWN_KEY, ERROR_COOLDOWN); pluginData.state.errorCooldownManager.setCooldown(ERROR_COOLDOWN_KEY, ERROR_COOLDOWN);
return; return;
} }
}
throw e; throw e;
} }