Lysander12 PT
Lysander12 PT

Reputation: 164

Delete a message from a user private message discord.py

I have a command that sends a message in the users dm. But after some time I want to delete that message. How can I do that? I've been trying to find a way but I can't. Thanks

Upvotes: 0

Views: 344

Answers (1)

Abdulaziz
Abdulaziz

Reputation: 3426

Use asyncio.sleep(NUM_OF_SEC)

@bot.command()
async def private(ctx):
    msg = await ctx.author.send('This is private')
    await asyncio.sleep(3)  # number of seconds
    await msg.delete()

Upvotes: 1

Related Questions