【问题标题】:How to increase number of messages retrieved on a Discord channel (python)如何增加在 Discord 频道上检索到的消息数量(python)
【发布时间】:2022-01-03 22:52:01
【问题描述】:

使用以下代码,我可以从给定的 Discord 频道检索消息,但只能检索最后 50 条消息。 请问,如何增加这个数字(例如 200 条消息)? 谢谢你的帮助。 祝你有美好的一天, 最好的,

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)

【问题讨论】:

    标签: python python-requests discord


    【解决方案1】:

    因此,根据文档,限制为 100 条消息。您可以通过添加限制查询字符串参数将该数量设置为最多 100。

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

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

    【讨论】:

    • 非常感谢。多亏了'before',我可以看到我可以进行分页并获取以前的消息。
    猜你喜欢
    • 2019-04-03
    • 2019-03-18
    • 1970-01-01
    • 2020-07-06
    • 1970-01-01
    • 2021-03-24
    • 2021-07-06
    • 2021-06-21
    • 2020-09-24
    相关资源
    最近更新 更多