Discord.py Clean命令删除引脚
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Discord.py Clean命令删除引脚相关的知识,希望对你有一定的参考价值。
我正在尝试获取此命令以停止删除固定的邮件。我在这里看到了一些与此相关的主题,但是似乎没有一个代码适合我的机器人。这是我现在拥有的代码:
@commands.command(aliases=["c", "C", "Clean"])
@commands.has_permissions(manage_messages=True)
async def clean(self, ctx, amount: int):
await ctx.message.delete()
amount = amount
await ctx.channel.purge(limit=amount)
embed = discord.Embed(color=0x4a3d9a, timestamp=ctx.message.created_at)
embed.set_author(name="Clear", icon_url=ctx.author.avatar_url)
embed.add_field(name="Success", value=f"Successfully cleaned {amount} messages.")
embed.set_thumbnail(url=self.client.user.avatar_url)
embed.set_footer(text="NewHorizon Development | https://NewHorizon-Development.netlify.app", icon_url=self.client.user.avatar_url)
await ctx.send(embed=embed, delete_after=3)
@clean.error
async def clean_error(self, ctx, error):
await ctx.message.delete()
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=0x4a3d9a, timestamp=ctx.message.created_at)
embed.set_author(name="Whoopsie", icon_url=self.client.user.avatar_url)
embed.add_field(name="Command Error", value="I'm sorry. but it seems I do not know how many messages you want me to clean.
Please try again and specify the amount of messages for me to clean")
embed.set_thumbnail(url=self.client.user.avatar_url)
embed.set_footer(text="NewHorizon Development | https://NewHorizon-Development.netlify.app", icon_url=self.client.user.avatar_url)
await ctx.send(embed=embed, delete_after=3)
else:
if isinstance(error, commands.MissingPermissions):
embed = discord.Embed(color=0x4a3d9a, timestamp=ctx.message.created_at)
embed.set_author(name="Whoopsie", icon_url=ctx.author.avatar_url)
embed.add_field(name="Command Error", value="I'm sorry, but it seems you do not have the permissions to use this command.")
embed.set_thumbnail(url=self.client.user.avatar_url)
embed.set_footer(text="NewHorizon Development | https://NewHorizon-Development.netlify.app", icon_url=self.client.user.avatar_url)
await ctx.send(embed=embed, delete_after=3)
任何帮助将不胜感激。
答案
如果使用重写:await ctx.channelpurge(limit=amount, check=lambda msg: not msg.pinned)
如果没有,您可以使用purge_from
:await self.bot.purge_from(ctx.channel, limit=amount, check=lambda msg: not msg.pinned)
以上是关于Discord.py Clean命令删除引脚的主要内容,如果未能解决你的问题,请参考以下文章