【发布时间】:2022-01-20 20:52:56
【问题描述】:
我想创建一个清除命令,例如 .clear @user#0000 100 它将清除 @user#0000 发送的最后 100 条消息。这是我的代码:
@commands.command()
@commands.has_permissions(manage_messages=True)
async def clear(self, ctx, amount=1):
await ctx.channel.purge(limit=amount + 1)
@clear.error
async def clear_error(self, ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.send('Sorry, you are missing the ``MANAGE_MESSAGES`` permission to use this command.')
我提供的此代码仅删除取决于频道中将删除多少条消息。我想制作一个代码,机器人将删除来自特定用户的消息。如果这是可能的,请告诉我。我将使用该代码作为将来的参考。非常感谢。
【问题讨论】:
标签: discord discord.py message