A
A
Alexander2020-08-02 21:53:34
Python
Alexander, 2020-08-02 21:53:34

How to correctly implement deleting a message after a while?

I end up with a message: "deleted (some) messages" - it needs to be deleted after a few seconds.

#clear command
@client.command(aliases = ['очистить','клеар','clr','клр'])
@commands.has_permissions(administrator = True)

async def clear( ctx, amount : int):
    await ctx.channel.purge(limit = 1)
    await ctx.channel.purge(limit = amount)
    await ctx.send(embed = discord.Embed(description = f':white_check_mark: удалено {amount} сообщений(я)'))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Nevzorov, 2020-08-03
@sh1ethzee

delete_afterUse the functionsend argument .

@client.command(aliases = ['очистить', 'клеар', 'clr' ,'клр'])
@commands.has_permissions(administrator = True)
async def clear( ctx, amount : int):
    await ctx.message.delete()
    await ctx.channel.purge(limit = amount)
    await ctx.send(embed = discord.Embed(description = f':white_check_mark: удалено {amount} сообщений(я)'), delete_after=5)

A
Alexander, 2020-08-02
@Alexandre888

deleting a message: then just put this line into a function and call it after X seconds
client.delete_message("сообщение")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question