Fix reminder timer reading stale swept reaction cache
This commit is contained in:
@@ -27,7 +27,10 @@ module.exports = {
|
||||
|
||||
try {
|
||||
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 users = reaction ? await reaction.users.fetch() : new Map();
|
||||
@@ -41,6 +44,9 @@ module.exports = {
|
||||
reply: { messageReference: reminder.message_id },
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user