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

fix: fix the fix

This commit is contained in:
Dragory 2022-06-01 19:49:14 +03:00
parent 058643f360
commit ba78103807
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -22,12 +22,12 @@ export const AddReactionsEvt = autoReactionsEvt({
} }
let autoReaction: AutoReaction | null = null; let autoReaction: AutoReaction | null = null;
const lock = await pluginData.locks.acquire(`auto-reactions-${message.channel.id}`); const lock = await pluginData.locks.acquire(`auto-reactions-${channel.id}`);
if (pluginData.state.cache.has(message.channel.id)) { if (pluginData.state.cache.has(channel.id)) {
autoReaction = pluginData.state.cache.get(message.channel.id) ?? null; autoReaction = pluginData.state.cache.get(channel.id) ?? null;
} else { } else {
autoReaction = (await pluginData.state.autoReactions.getForChannel(message.channel.id)) ?? null; autoReaction = (await pluginData.state.autoReactions.getForChannel(channel.id)) ?? null;
pluginData.state.cache.set(message.channel.id, autoReaction); pluginData.state.cache.set(channel.id, autoReaction);
} }
lock.unlock(); lock.unlock();
@ -39,15 +39,13 @@ export const AddReactionsEvt = autoReactionsEvt({
if (me) { if (me) {
const missingPermissions = getMissingChannelPermissions( const missingPermissions = getMissingChannelPermissions(
me, me,
message.channel as GuildChannel, channel as GuildChannel,
readChannelPermissions | p.ADD_REACTIONS, readChannelPermissions | p.ADD_REACTIONS,
); );
if (missingPermissions) { if (missingPermissions) {
const logs = pluginData.getPlugin(LogsPlugin); const logs = pluginData.getPlugin(LogsPlugin);
logs.logBotAlert({ logs.logBotAlert({
body: `Cannot apply auto-reactions in <#${message.channel.id}>. ${missingPermissionError( body: `Cannot apply auto-reactions in <#${channel.id}>. ${missingPermissionError(missingPermissions)}`,
missingPermissions,
)}`,
}); });
return; return;
} }
@ -61,11 +59,11 @@ export const AddReactionsEvt = autoReactionsEvt({
const logs = pluginData.getPlugin(LogsPlugin); const logs = pluginData.getPlugin(LogsPlugin);
if (e.code === 10008) { if (e.code === 10008) {
logs.logBotAlert({ 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 { } else {
logs.logBotAlert({ 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}.`,
}); });
} }