Discord.py如何在特定的时间后让Bot删除邮件

问题描述:

我有一个Discord机器人,当他们使用!img命令时,该机器人会向用户发送图像,我不希望人们请求图像然后将其放置在那里,直到有人将其删除为止.我有什么办法可以让它在10秒钟左右后删除图像,而无需使用python中的 time.sleep()之类的任何阻止功能?

I have a discord bot that sends images to users when they use the !img command, I don't want people to request an image and then have it sit there until someone deletes it. Is there any way I can make it delete images after 10 seconds or so without using any blocking functions such as time.sleep() in python?

谢谢

Messageable.send 有一个 delete_after kwarg,需要花费几秒钟的时间才能删除之后发送的消息,例如

Messageable.send has a delete_after kwarg that takes the amount of seconds to delete the sent message after, for example

await channel.send("this message will be deleted after 10 seconds", delete_after=10)

https://discordpy.readthedocs.io/en/neo-docs/api.html#discord.abc.Messageable.send