#channel.messages.fetch() does not fetch some messages...

21 messages · Page 1 of 1 (latest)

red anvilBOT
  • 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
oak thunder

and how are you checking that the messages aren't being fetched?

subtle tinsel
oak thunder 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.

oak thunder

they are.
sooo... your issue isn't about fetch not fetching then?

oak thunder

this code above does not delete anything

subtle tinsel
oak thunder

does that code have the messages that aren't being deleted

one without nay filtering and deleting

subtle tinsel
little notch

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

tender muralBOT
subtle tinsel

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.

subtle tinsel
subtle tinsel
oak thunder

no, after the fetch the messages are presumably filtered

subtle tinsel

you can stop posting here now if you want, the issue has been resolved 👍

subtle tinsel
oak thunder

(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