how do you fetch all messages created after a specific date?
self explanatory
33 Replies
- 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!:method: GuildMessageManager#fetch
@14.15.3
Fetches message(s) from a channel. The returned Collection does not contain reaction users of the messages if they were not cached. Those need to be fetched separately in such a case.
is there a function for fetching all messages in a guild at once or do i have to manually make a loop for it
loop
🙏
The
id
here for after
is just a snowflake, you can construct one for a specific Date/time by using SnowflakeUtil
and pass thati've hit a wall, it's saying fetch() is undefined for some reason, and chnl is a channel object
errors out at the second fetch btw
Just so you know, snowflake should be a string there in
after
so do timestamp.toString()
also, please show your erroroh okay one min
Also no need to fetch channels, it's all cached with Guilds intent
okay ty
Ok i see, you need to convert Collection to iterables
Converting a Collection to an array
You only need to convert it to an array if you need the index of an entry:
- Iteration (looping) is possible with
for...of
over Collection#values
or forEach
- You can transform a Collection to an array with Collection#map
- If you need indices, you can get the array using [...collection.values()]
i did convert them into iterables
const [id,chnl] of collection
right?
Read the first point
You can do something like
oh
wow didn't know that
okay lemme see if it works
mhm
fetch is still undefined

On a closer look, what you are trying to do seems to be API spammy
Why do you need to fetch messages from each channel?
^

I'm asking why? Just pointing it won't help, just because you want to do something doesn't mean you should
intellisense isn't even working here

no i'm getting the count of all messages in the last 24 hours, dividing it by 50 then creating a msg streak stat
Show your full code, not all channel types have
messages
property (like Category channels), you'll have to filter those outit's a seperate function it doesn't have any linkage to the rest of the code
You don't have to show everything, just the part/fuction related to the error
just this
nothing from outside is mentioned
except user.id which is

^ 2nd part of this message still applies
oh
worked and didn't work
no errors but msgCountInGuild is always 0
nvm got it working
it just takes a long time to finish
is there any better way to do this?
no
😢