Discord.py如何在特定的时间后让Bot删除邮件 [英] Discord.py How can I make a bot delete messages after a specific amount of time

查看:43
本文介绍了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

这篇关于Discord.py如何在特定的时间后让Bot删除邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆