Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

"messageReactionAdd" listener is not triggered in old messages #64

Open
ythepaut opened this issue Jul 6, 2021 · 2 comments
Open

"messageReactionAdd" listener is not triggered in old messages #64

ythepaut opened this issue Jul 6, 2021 · 2 comments

Comments

@ythepaut
Copy link

ythepaut commented Jul 6, 2021

Hello, I encountered an issue when I tried to listen to user reactions on messages :
A messageReactionAdd listener won't trigger if the message the reaction was added on was sent before the bot started.

Code where I ran my tests :

import {ArgsOf, On} from "@typeit/discord";

export abstract class Reaction {

    @On("messageReactionAdd")
    private async processEvent([reaction, user]: ArgsOf<"messageReactionAdd">) {
        console.log("**REACTION**", reaction.emoji.name);
    }
}

The console.log() is triggered on messages sent after the bot started, but not before.

@samarmeena
Copy link
Contributor

discord instance cache messages that sent after bot started. you can try to fetch previous messages then it might let you see reactions for old messages.

@Cosmiiko
Copy link

This is how Discord.js behaves too. The raw event should still be passed though, so you should be able to do something like this (this is old discord.js code of mine, not adapted for discord.ts).

    client.on("raw", (ev) => {
        if (!ev.t || ev.t != "MESSAGE_REACTION_REMOVE") return;
   
        let messageId = ev.d.message_id;
        let emoji = ev.d.emoji.name;
    });

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants