3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-11 04:45:02 +00:00

Ugly workaround/hotfix for message fetching

This commit is contained in:
Dragory 2021-08-19 00:49:06 +03:00
parent 499511f79d
commit 8da47e53e6
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
9 changed files with 31 additions and 14 deletions

View file

@ -4,6 +4,7 @@ import { allStarboardsLock } from "../../../utils/lockNameHelpers";
import { starboardEvt } from "../types";
import { saveMessageToStarboard } from "../util/saveMessageToStarboard";
import { updateStarboardMessageStarCount } from "../util/updateStarboardMessageStarCount";
import { hotfixMessageFetch } from "../../../utils/hotfixMessageFetch";
export const StarboardReactionAddEvt = starboardEvt({
event: "messageReactionAdd",
@ -18,7 +19,7 @@ export const StarboardReactionAddEvt = starboardEvt({
if (!msg.author) {
// Message is not cached, fetch it
try {
msg = await msg.channel.messages.fetch(msg.id);
msg = await hotfixMessageFetch(msg.channel as TextChannel, msg.id);
} catch {
// Sometimes we get this event for messages we can't fetch with getMessage; ignore silently
return;
@ -79,9 +80,7 @@ export const StarboardReactionAddEvt = starboardEvt({
const channel = pluginData.guild.channels.cache.get(
starboardMessage.starboard_channel_id as Snowflake,
) as TextChannel;
const realStarboardMessage = await channel.messages.fetch(
starboardMessage.starboard_message_id as Snowflake,
);
const realStarboardMessage = await hotfixMessageFetch(channel, starboardMessage.starboard_message_id);
await updateStarboardMessageStarCount(
starboard,
msg,