Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants