如何增加在 Discord 频道上检索到的消息数量(python)

Posted

技术标签:

【中文标题】如何增加在 Discord 频道上检索到的消息数量(python)【英文标题】:How to increase number of messages retrieved on a Discord channel (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)

【问题讨论】:

【参考方案1】:

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

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

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

【讨论】:

非常感谢。多亏了'before',我可以看到我可以进行分页并获取以前的消息。

以上是关于如何增加在 Discord 频道上检索到的消息数量(python)的主要内容,如果未能解决你的问题,请参考以下文章