#I need a better clear command xD

1 messages · Page 1 of 1 (latest)

wise breach
#
        if user and amount:
            embed = discord.Embed(title="Clear | Loading...",
                                  description=f"Deleting {amount} messages from user {user.mention} in Channel.",
                                  color=0xD5B815)
            embed.set_footer(text=f"Aromic4All | /discord")
            await ctx.respond(embed=embed, ephemeral=True)

            async for message in ctx.channel.history(limit=1000):
                if message_amount == amount:
                    break
                if message.author == user:
                    await message.delete()
                    message_amount += 1

            embed = discord.Embed(title="Clear | SUCCESSFULLY",
                                  description=f"You have successfully cleared {message_amount}/{amount} message(s) from user {user.mention}.",
                                  color=0x6915D5)
            embed.set_footer(text=f"Aromic4All | /discord")
            await ctx.send(embed=embed, delete_after=3)
        elif amount:
            embed = discord.Embed(title="Clear | Loading...",
                                  description=f"Deleting {amount} messages in Channel.",
                                  color=0xD5B815)
            embed.set_footer(text=f"Aromic4All | /discord")
            await ctx.respond(embed=embed, ephemeral=True)

            async for message in ctx.channel.history(limit=amount):
                await message.delete()
                message_amount += 1

            embed = discord.Embed(title="Clear | SUCCESSFULLY",
                                  description=f"You have successfully cleared {message_amount}/{amount} message(s).",
                                  color=0x6915D5)
            embed.set_footer(text=f"Aromic4All | /discord")
            await ctx.send(embed=embed, delete_after=3)
        elif user:
            embed = discord.Embed(title="Clear | Loading...",
                                  description=f"Deleting 100 messages from user {user.mention} in Channel.",
                                  color=0xD5B815)
            embed.set_footer(text=f"Aromic4All | /discord")
            await ctx.respond(embed=embed, ephemeral=True)

            async for message in ctx.channel.history(limit=200):
                if message_amount == 100:
                    break
                if message.author == user:
                    await message.delete()
                    message_amount += 1

I only have the problem that the messages are cleared individually and that is too slow. I want that all messages are cleared immediately at once, can help me there who?

chilly basin
#

Have you tried using the "threading" module?

signal mist
#

So something like this (taken straight out of the docs):

def is_me(m):
    return m.author == client.user

deleted = await channel.purge(limit=100, check=is_me)
await channel.send(f'Deleted {len(deleted)} message(s)')
wise breach
#

Thanks, i will try it

signal mist
#

Yw

wise breach
#

Thank you, works the way I wanted :D