【发布时间】:2021-05-17 23:34:40
【问题描述】:
我的机器人有一个清除命令。但是如果你清除,机器人会发送一条消息,说你清除了这个聊天......那么我怎么能在 10 秒后使用 maby asyncio 删除它...... 这是我的代码:
import discord
from discord.ext import commands
import asyncio
bot = commands.Bot(command_prefix='>', description="This is a bot")
@bot.command(aliases=['c'])
@commands.has_permissions(manage_messages=True)
async def clear(ctx, amount: int = None):
if amount == 0:
await ctx.channel.purge(limit=10000000000000000000000)
await ctx.send("Cleared the entire chat!")
print("Cleared the chat!")
else:
if amount >= 1:
await ctx.channel.purge(limit=amount)
await ctx.send("Done!")
print(f"Cleared {amount} messages!")
感谢您的帮助...
【问题讨论】: