3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Properly order reaction roles

This commit is contained in:
Dark 2021-06-06 02:41:06 +02:00
parent 7124898568
commit 43c23263f0
No known key found for this signature in database
GPG key ID: 384C4B4F5B1E25A8
7 changed files with 41 additions and 9 deletions

View file

@ -71,18 +71,16 @@ export async function applyReactionRoleReactionsToMessage(
emojisToAdd.push(CLEAR_ROLES_EMOJI);
for (const rawEmoji of emojisToAdd) {
const emoji = isSnowflake(rawEmoji) ? `foo:${rawEmoji}` : rawEmoji;
try {
await targetMessage.reactions.add(emoji);
await sleep(1250); // Make sure we don't hit rate limits
await targetMessage.react(rawEmoji);
await sleep(750); // Make sure we don't hit rate limits
} catch (e) {
if (isDiscordRESTError(e)) {
if (e.code === 10014) {
pluginData.state.reactionRoles.removeFromMessage(messageId, rawEmoji);
errors.push(`Unknown emoji: ${emoji}`);
errors.push(`Unknown emoji: ${rawEmoji}`);
logs.log(LogType.BOT_ALERT, {
body: `Could not add unknown reaction role emoji ${emoji} to message ${channelId}/${messageId}`,
body: `Could not add unknown reaction role emoji ${rawEmoji} to message ${channelId}/${messageId}`,
});
continue;
} else if (e.code === 50013) {