【发布时间】:2021-05-01 06:22:47
【问题描述】:
我正在尝试找出一种方法来获取由特定用户在频道和/或整个服务器中发送的所有消息(可能需要一段时间)。
我也查看了User.history() 和Member.history(),但尽管文档没有提及,它只会返回用户的 DM 历史记录。
这里是 Bot 命令代码 sn-p:
@bot.command(aliases=['rq'])
async def randomquote(ctx):
def check(ctx):
return ctx.author.id == memberID
messages = await ctx.channel.history(limit=100, check=check).flatten()
await ctx.send(f"{random.choice(messages).content}")
我尝试过this answer,但是,check=check 抛出:an exception: TypeError: history() got an unexpected keyword argument 'check',尽管它看起来确实是最干净的解决方案。
【问题讨论】:
标签: python discord.py