Skip to content

Get Previous Message by ID #94

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

Open
JakeStevenson opened this issue Jul 10, 2023 · 1 comment
Open

Get Previous Message by ID #94

JakeStevenson opened this issue Jul 10, 2023 · 1 comment

Comments

@JakeStevenson
Copy link

I have a bot that needs to be able to respond to a previous message when mentioned in a reply. For example:

Joe (message A): I need help with .
Moderator, replying to message A: @helpbot
HelpBot, replying to message A: @joe, You can find help for at .....

Right now, I'm using discordMessage and capturing history of messages by ID, so if the bot sees another message come into the flow that mentions it's name, it will find the original, get the original request, and respond to it. But this can be memory intensive.

Is there a better way to get older messages by id than keeping a bunch of them in memory?

@JuliaSoriaSmith
Copy link
Contributor

You can utilize the discordMessageManager. When you receive a message from discordMessage any message it is replying to is captured within the object, use this to get the previous message. E.g. in your case the message received for the moderator replying to the message, in the object there will be a reply parameter which contains the message id.

Using the discordMessageManager you can then obtain this message, if you set the msg.message parameter to the message id, and msg.action to 'info'. This will retrieve the previous message.

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

2 participants