如何使用discord.py创建一个bot来检查特定服务器通道中的所有消息

2024-04-25 20:17:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在制作一个discord bot,它检查特定服务器通道中的所有消息,并在消息包含特定内容时添加一个反应。顺便说一句,我知道如何执行后一种操作,但我不知道如何让bot检查服务器中的每条消息。请告诉我怎么做


Tags: 服务器消息内容botdiscord
1条回答
网友
1楼 · 发布于 2024-04-25 20:17:59

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)

返回允许接收目标消息历史记录的异步迭代器

您必须具有read_message_history权限才能使用此文件

例如: messages = await channel.history(limit=123).flatten() 要获取频道历史记录消息,请将其放入展开列表中

https://discordpy.readthedocs.io/en/latest/api.html#textchannel

相关问题 更多 >