#channel.messages.fetch() does not fetch some messages...
21 messages · Page 1 of 1 (latest)
and how are you checking that the messages aren't being fetched?
they are. i use a console.log to see what messages are fetched.
for instance, if i use:
const fetchedMessages = await message.channel.messages.fetch({
limit: 5,
})
console.log(fetchedMessages);
And if i keep using my command to bulkDelete 5 fetched messages, eventually it will stop fetching relevant messages, for example: after i delete upto 100 messages or more, using the command over and over again, there would be a message that was sent 2 days ago that isn't being deleted. Why? because it isn't fetched, when i see the logs it shows me 5 messages, 1 is my command initative message, 1 is the bot's reply after command initiation, the rest are messages that we're sent 30 days ago.
so it didn't fetch that message that was sent 2 days ago.
they are.
sooo... your issue isn't about fetch not fetching then?
it is!
please read
this code above does not delete anything
they are fetched but eventually when i keep fetching the the same channel after bulkDeleting messages, it would stop fetching some or all messages after that point. even if the message is not older than 14 days.
does that code have the messages that aren't being deleted
one without nay filtering and deleting
yes, that isn't the problem, the rest of the code deletes the fetched messages fine, as i said. In the logs, the messages that should be deleted aren't in the fetch. so theres no way it would be deleted
In your code you always fetch the last (up to) 100 messages in the channel. So if the message you try to delete has 100 messages after it you‘ll never fetch it
FetchMessagesOptions#before discord.js@14.16.3
Consider only messages before this id
close the post, the issue has been resolved. someone helped from discord developers official server.
Someone who didn't need all the code and didn't made jokes about how my experimental code was bad.
Anyway, none of the content sent by you guys was any helpful.
but still, Thanks alot for your time, i know that it may be rude to say you guys we're no help but i appreciate it.
if you see any code in this post, im using either 100 max or 5.
yes, but after the fetch, the fetched messages are bulkDeleted.
no, after the fetch the messages are presumably filtered
you can stop posting here now if you want, the issue has been resolved 👍
the only filter i put is to just filter out messages older than 14 days.
(which bulkDelete can do on its own if you pass true as 2nd parameter)
but also the targetUser filter on the next line was doing something else