From a5eab2f7be5c6d3ac0e4d481b301f89ed72f6cd9 Mon Sep 17 00:00:00 2001 From: Sammy Date: Tue, 13 Jun 2023 20:13:13 +0200 Subject: [PATCH] fix bug that reactions are not loaded after restart the message needed to be fetched again. Probably something with caches.. --- server/structures/client.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/structures/client.ts b/server/structures/client.ts index 3ab1e63..ce37605 100644 --- a/server/structures/client.ts +++ b/server/structures/client.ts @@ -130,7 +130,7 @@ export class ExtendedClient extends Client { const textChannel: TextChannel = this.getAnnouncementChannelForGuild(guild.id) this.announcementRoleHandlerTask.set(guild.id, schedule("*/10 * * * * *", async () => { const requestId = uuid() - const messages = (await textChannel.messages.fetchPinned()).filter(message => message.cleanContent.includes("[announcement]")) + const messages = (await textChannel.messages.fetchPinned()).filter(message => message.cleanContent.includes("[initial]")) if (messages.size > 1) { logger.error("More than one pinned announcement Messages found. Unable to know which one people react to. Please fix!", { guildId: guild.id, requestId }) @@ -138,9 +138,11 @@ export class ExtendedClient extends Client { logger.error("Could not find any pinned announcement messages. Unable to manage roles!", { guildId: guild.id, requestId }) } - const message = messages.at(0)! + const message = await messages.at(0)!.fetch() + //logger.debug(`Message: ${JSON.stringify(message, null, 2)}`, { guildId: guild.id, requestId }) - const reactions = await message.reactions.resolve("🎫") + const reactions = message.reactions.resolve("🎫") + //logger.debug(`reactions: ${JSON.stringify(reactions, null, 2)}`, { guildId: guild.id, requestId }) if (reactions) { manageAnnouncementRoles(message.guild, reactions, requestId) } else { @@ -149,6 +151,7 @@ export class ExtendedClient extends Client { })) } } + public stopAnnouncementRoleBackgroundTask(guild: string | Guild, requestId: string) { const guildId: string = guild instanceof Guild ? guild.id : guild const task: ScheduledTask | undefined = guild instanceof Guild ? this.announcementRoleHandlerTask.get(guild.id) : this.announcementRoleHandlerTask.get(guild)