Fetch an array of message IDs at once
Is there some sort of way to fetch multiple messages by
id
in a single request?
Kind of like message.channel.messages.fetch([snowflake_one, snowflake_two])
I tried interaction.channel.messages.fetch([1124766378705027212,1124766519826587670]).then(_ => console.log(_.size))
And it reports 50, which is a lot more than two lol
I basically create an array full of message ids, and I want to fetch them to get their content, author id, and displayname
But just running messages.fetch(id)
for each one is very slow
This is what I've got right now, which is works, but is undesirable as it's very slow (many times slower requesting 3 specific IDs vs limit
of 3)
It just turns an array of pins, into an array of pins and whatever they're replying to
I've read MessageManager.fetch(), but I don't really see what I'm looking for
Despite it saying that it accepts an array of options, and individual options can be snowflakesdiscord.js
discord.js
discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
8 Replies
• 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.i dont think .fetch can take an array of id's, hence why it returns 50. Only way to do it without spamming the api would be checking cache or making a backend yourself but i might be wrong
First of all. You have an old version of the website cached.
Shift + F5
or Ctrl + Shift + R
Oh I see
That does happen to have identical content to the cached page I've got, though I've been redirected now to the
old
subdomain
Still says that it accepts an array of MessageResolvable
For some reason I assumed that cache was always checked first, and then it falls back to making an API request
I'll give this one a trycache is always checked first, if not a request is made
but thats gonna get you reatelimited if none of the messages are cached and you have to fetch a lot
I swapped it out with this
And I seem to get what I'm looking for, so thank you
I thought this was redundancy, but it does seem to cut the eval time in half (with only 3 pins in total, one of which doesn't have a reference to begin with)
1.178s → 0.457s