Fetch messages older than certain date

I'd like to fetch the most recent messages from a channel that are older than a specific timestamp. E.g. if my limit is 5 days, I want the most recent messages that are at least 5 days old. I noticed the FetchMessagesOptions object has the before parameter, but it works with a specific message ID, not a timestamp. Do I first need to get the oldest message that is less than 5 days old, and then use that message's ID as the before value? Because I'm not sure how I could do this efficiently without unnecessary API requests. Or is there a better way?
2 Replies
d.js toolkit
d.js toolkit12mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Wawajabba
Wawajabba12mo ago
To be clear, I'm not requesting code help - I can figure this out myself. I'm simply wondering if there's a more efficient way to do this with discord.js Oh, I didn't realise that, thank you! That makes this much easier