【发布时间】:2021-08-17 15:09:04
【问题描述】:
我希望我的机器人有一个删除频道中所有消息的命令。
@pip.command()
async def clear(ctx, amount):
if amount == "all":
await ctx.send("Are you sure you want to delete all messages in this channel?")
async def yes(ctx):
if ctx == "yes":
await ctx.channel.purge(limit=100000000)
这是我的代码。
它会向我发送消息,询问我是否确定要删除所有消息,但在那之后,当我输入“pip yes”时它什么也不做(pip 是我的前缀)我该如何解决这个问题?
感谢您的帮助!
【问题讨论】:
-
使用
wait_for -
这帮助解决了我的大部分问题,非常感谢!
-
如果要清除频道中的所有消息,最好使用
TextChannel.clone()克隆频道,然后删除原来的频道
标签: python discord discord.py