【发布时间】:2020-10-27 21:16:22
【问题描述】:
我不知道为什么它不清除它可能只是我很愚蠢,但如果有人能指出这一点,那就太好了,谢谢
@client.command(aliases=["clean"])
@commands.has_permissions(manage_messages=True)
async def purge(ctx, amount: int):
authors = {}
async for message in ctx.channel.history(limit=amount + 1):
if message.author not in authors:
authors[message.author] = 1
else:
authors[message.author] += 1
message.delete()
msg = "\n".join([f"{author}:{amount}" for author, amount in authors.items()])
await ctx.channel.send(msg)
【问题讨论】:
-
也许可以试试
await message.delete() -
message.delete()是一个courotine,所以你必须等待它。
标签: python discord discord.py