我试图获取在一个通道中发送了多少消息的数量,并且使用logs_from()函数不会工作,因为它只接受固定数量的消息来检索,我该怎么做?
在discord.py-rewrite分支,有一个TextChannel.history
AsyncIterator
。如果你传递limit=None
,它将返回来自频道的所有消息
@bot.command()
async def message_count(ctx, channel: discord.TextChannel=None):
channel = channel or ctx.channel
count = 0
async for _ in channel.history(limit=None):
count += 1
await ctx.send("There were {} messages in {}".format(count, channel.mention))
您可以尝试将limit=None
传递给logs_from
,但它没有记录为像在重写分支中那样工作。