How to make a bot delete a message sent from itself

41 views Asked by At

I have a Discord bot and I want it to delete a "Loading..." message. However it just deletes the user message for the command

@client.command()
async def run(ctx):
    await ctx.send("Loading...")
    await ctx.message.delete()
    await ctx.send("Loading Complete!")

This raises insufficient permissions as it is trying to delete the user message instead of the message it just sent.

What am I doing wrong here?

1

There are 1 answers

0
boez On BEST ANSWER

You can use the delete_after parameter which specifies after how much seconds the message will be deleted after sending.

await ctx.send("Loading...", delete_after=3) #deleting after 3 seconds