From ea7aec5e66f1eada4e04688f6dab3dd46d118cc2 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Tue, 18 Feb 2025 14:14:17 +1300 Subject: [PATCH] Ignore error when maximum reactions reached --- src/m2d/actions/add-reaction.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/m2d/actions/add-reaction.js b/src/m2d/actions/add-reaction.js index d54bf776..6eb12e0f 100644 --- a/src/m2d/actions/add-reaction.js +++ b/src/m2d/actions/add-reaction.js @@ -23,7 +23,16 @@ async function addReaction(event) { const discordPreferredEncoding = await emoji.encodeEmoji(key, event.content.shortcode) if (!discordPreferredEncoding) return - await discord.snow.channel.createReaction(channelID, messageID, discordPreferredEncoding) // acting as the discord bot itself + try { + await discord.snow.channel.createReaction(channelID, messageID, discordPreferredEncoding) // acting as the discord bot itself + } catch (e) { + if (e.message?.includes("Maximum number of reactions reached")) { + // we'll silence this particular error to avoid spamming the chat + // not adding it to the database otherwise a m->d removal would try calling the API + return + } + throw e + } db.prepare("REPLACE INTO reaction (hashed_event_id, message_id, encoded_emoji) VALUES (?, ?, ?)").run(utils.getEventIDHash(event.event_id), messageID, discordPreferredEncoding) }