How to get the previous message from a message ?

Hello! I would like to get the previous message from a message, and create a link like https://discord.com/channels/${interaction.guild.id}/${message.channel.id}/${message.id} . If I can make that, I would like help, thanks!
7 Replies
d.js toolkit
d.js toolkit4mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
NyR
NyR4mo ago
Previous message as in? Like get the message it's replied to?
Thomas Bnt
Thomas BntOP4mo ago
Oh sorry for not specifying. The previous message, like @d.js toolkit message preceding your message
NyR
NyR4mo ago
Oh, you specify the before option in fetch with limit 1. Pass the message id in before option of which you want the get previous message of Like
<Channel>.messages.fetch({ before: "Message Id", limit: 1})
<Channel>.messages.fetch({ before: "Message Id", limit: 1})
Will return a collection I believe
Thomas Bnt
Thomas BntOP4mo ago
owh, thanks that works! ✅
NyR
NyR4mo ago
Yeah, as for the url. You can just do <Message>.url to get that
Thomas Bnt
Thomas BntOP4mo ago
good, thanks again!
Want results from more Discord servers?
Add your server