Hello! Im creating a message that my bot sends whenever its mentioned and it auto deletes after 20 seconds, but i dont know how to do it. Here's my code:
@bot.event
async def on_message(msg):
if bot.user.mentioned_in(msg):
rebed = discord.Embed(
title=f'Hello, {msg.author}',
description=f'Hello, I\'m {bot.user}!\nI am a bot to request and output keys for Roblox executors.\nWant to request a key to our staff? Use `/request` to start!',
color=discord.Color.blurple()
)
rebed.set_thumbnail(url=bot.user.avatar)
rebed.set_footer(text=f'{bot.user.display_name}, {datetime.datetime.now().strftime('%H:%M, %d/%m/%Y')}.')
autodel = await msg.reply(embed=rebed)
autodel.delete_after(20)
I asked Google Gemini how to do it but when I mention the bot the command to delete it raises this error:
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\client.py", line 400, in _run_event
await coro(*args, **kwargs)
File "c:\Users\user\VSCode\Python\Keybot\Keybot.py", line 36, in on_message
autodel.delete_after(20)
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Message' object has no attribute 'delete_after'
Can anyone help me with this?