Fix reminder timer reading stale swept reaction cache

This commit is contained in:
2026-08-09 22:24:56 +02:00
parent afdba9a6ad
commit f9dd88b9b8

View File

@@ -27,7 +27,10 @@ module.exports = {
try { try {
const channel = await client.channels.fetch(reminder.channel_id); const channel = await client.channels.fetch(reminder.channel_id);
const message = await channel.messages.fetch(reminder.message_id); // force: true bypasses the client's message cache, which the reaction
// sweeper (see main.js) periodically empties - a cached message here
// would silently report zero reactions.
const message = await channel.messages.fetch({ message: reminder.message_id, force: true });
const reaction = message.reactions.cache.get(REMINDER_EMOTE); const reaction = message.reactions.cache.get(REMINDER_EMOTE);
const users = reaction ? await reaction.users.fetch() : new Map(); const users = reaction ? await reaction.users.fetch() : new Map();
@@ -41,6 +44,9 @@ module.exports = {
reply: { messageReference: reminder.message_id }, reply: { messageReference: reminder.message_id },
allowedMentions: { parse: [], users: mentions.map(m => m.slice(2, -1)) } allowedMentions: { parse: [], users: mentions.map(m => m.slice(2, -1)) }
}); });
console.log(`[TIMER] Sent vrc.tl reminder for "${reminder.event_name}" to ${mentions.length} user(s)`);
} else {
console.log(`[TIMER] No reactions found for vrc.tl reminder "${reminder.event_name}" (message ${reminder.message_id}), skipping ping`);
} }
markSent.run(reminder.id); markSent.run(reminder.id);