我正在尝试获取通道中已发送的消息数,并且使用logs_from()函数将不起作用,因为它仅接受固定数量的消息来检索,我该怎么做?>
答案 0 :(得分:1)
在discord.py-rewrite分支中,有一个TextChannel.history
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr>
<th class="theader"> .theader </th>
<th class="theader"> .theader </th>
<th class="theader"> .theader </th>
</tr>
<tr>
<td class="troe"> .trow </td>
<td class="trow"> .trow </td>
<td class="trow"> <span class="check"></span> </td>
</tr>
<tr>
<td class="troe"> .trow </td>
<td class="trow"> .trow </td>
<td class="trow"> <span class="check"></span> </td>
</tr>
<tr>
<td class="troe"> .trow </td>
<td class="trow"> .trow </td>
<td class="trow"> <span class="check"></span> </td>
</tr>
</table>
。如果您通过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
,但没有记录为它像重写分支中那样工作。