删除特定人的消息

Deleting a specific person messages

现在它只删除 "content" 最后一条消息:

@commands.command()
    @commands.has_permissions(manage_guild=True)
    async def clear(self, ctx, content:int):
            await ctx.message.delete()
            if content > 0:
                await ctx.channel.purge(limit=content)
                if content == 1:
                    title = f'Usunięto {content} wiadomość'
                    colour = discord.Colour.blue()
                else:
                    title = f'Usunięto {content} wiadomości'
                    colour = discord.Colour.blue()
            else:
                title = 'Hej! Wartość nie może być mniejsza od 0!'
                colour = discord.Colour.red()
            clear = discord.Embed(
            title = title,
            colour = colour
            )
            clear.set_author(name=ctx.bot.user.name, icon_url=ctx.bot.user.avatar_url)
            clear.set_footer(text=version)
            textMsg = await ctx.send(embed=clear)
            await textMsg.delete(delay=2)

我想让机器人只删除特定的人(例如 "!clear 5 @Thundo#0000 <= mention)- 只会删除 Thundo 的最后五条消息,不会删除其他消息

使用清除功能的 check kwarg。它接受一个带有一个参数的函数——消息。仅当 message.author 是您要删除其消息的那个人时,您才能使该函数 return 为真。将该函数传递给 check kwarg。您还可以将应删除的消息数作为整数传递给 limit kwarg。繁荣,就是这样