From ba7810380730f5ec2917608567d61f0594101b97 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Wed, 1 Jun 2022 19:49:14 +0300 Subject: [PATCH] fix: fix the fix --- .../AutoReactions/events/AddReactionsEvt.ts | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/backend/src/plugins/AutoReactions/events/AddReactionsEvt.ts b/backend/src/plugins/AutoReactions/events/AddReactionsEvt.ts index 88dbe99e..0818953c 100644 --- a/backend/src/plugins/AutoReactions/events/AddReactionsEvt.ts +++ b/backend/src/plugins/AutoReactions/events/AddReactionsEvt.ts @@ -22,12 +22,12 @@ export const AddReactionsEvt = autoReactionsEvt({ } let autoReaction: AutoReaction | null = null; - const lock = await pluginData.locks.acquire(`auto-reactions-${message.channel.id}`); - if (pluginData.state.cache.has(message.channel.id)) { - autoReaction = pluginData.state.cache.get(message.channel.id) ?? null; + const lock = await pluginData.locks.acquire(`auto-reactions-${channel.id}`); + if (pluginData.state.cache.has(channel.id)) { + autoReaction = pluginData.state.cache.get(channel.id) ?? null; } else { - autoReaction = (await pluginData.state.autoReactions.getForChannel(message.channel.id)) ?? null; - pluginData.state.cache.set(message.channel.id, autoReaction); + autoReaction = (await pluginData.state.autoReactions.getForChannel(channel.id)) ?? null; + pluginData.state.cache.set(channel.id, autoReaction); } lock.unlock(); @@ -39,15 +39,13 @@ export const AddReactionsEvt = autoReactionsEvt({ if (me) { const missingPermissions = getMissingChannelPermissions( me, - message.channel as GuildChannel, + channel as GuildChannel, readChannelPermissions | p.ADD_REACTIONS, ); if (missingPermissions) { const logs = pluginData.getPlugin(LogsPlugin); logs.logBotAlert({ - body: `Cannot apply auto-reactions in <#${message.channel.id}>. ${missingPermissionError( - missingPermissions, - )}`, + body: `Cannot apply auto-reactions in <#${channel.id}>. ${missingPermissionError(missingPermissions)}`, }); return; } @@ -61,11 +59,11 @@ export const AddReactionsEvt = autoReactionsEvt({ const logs = pluginData.getPlugin(LogsPlugin); if (e.code === 10008) { logs.logBotAlert({ - body: `Could not apply auto-reactions in <#${message.channel.id}> for message \`${message.id}\`. Make sure nothing is deleting the message before the reactions are applied.`, + body: `Could not apply auto-reactions in <#${channel.id}> for message \`${message.id}\`. Make sure nothing is deleting the message before the reactions are applied.`, }); } else { logs.logBotAlert({ - body: `Could not apply auto-reactions in <#${message.channel.id}> for message \`${message.id}\`. Error code ${e.code}.`, + body: `Could not apply auto-reactions in <#${channel.id}> for message \`${message.id}\`. Error code ${e.code}.`, }); }