Home > Back-end >  How can I get the last 1000 messages sent by a certain user?
How can I get the last 1000 messages sent by a certain user?

Time:12-21

I've tried channel.fetchMessages(), but the limit is 100 messages. It's for a bot supposed to simulate users using machine learning.

CodePudding user response:

The limit of returned messages is 100, with the default being 50. See the actual API docs for details.

By default, you get the most recent messages, but you can specify additional query criteria when fetching messages. You'll need to repeat your fetch requests, adjusting the query criteria each time, in order to collect successively older messages. After each request, you can analyze what you've collected so far to determine if you need to keep fetching or not.

Beware of the rate limits.

  • Related