Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to increase number of messages retrieved on a Discord channel (python)

With following code, I am able to retrieve messages from a given Discord channel, but only the 50 last messages get retrieved.
Please, how to increase this number (for instance 200 messages)?
Thanks for your help.
Have a good day,
Bests,

import requests
import json

def retrieve_messages(channelIdn author):
    headers = {'authorization':author}
    r = requests.get(f'https://discord.com/api/v9/channels/{channelId}/messages', headers=headers)
    return json.loads(r.text)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

So the limit is 100 messages according to the docs. You can set that amount up to 100 by adding the limit query string param.

ex: https://discord.com/api/v9/channels/{channelId}/messages?limit={limit}

Source: https://discord.com/developers/docs/resources/channel#get-channel-messages

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading