本文介紹了(Discord.py)如何讓機器人在一段時間后刪除自己的消息?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我在 Python 中有這段代碼:
I have this code in Python:
import discord
client = commands.Bot(command_prefix='!')
@client.event
async def on_voice_state_update(member):
channel = client.get_channel(channels_id_where_i_want_to_send_message))
response = f'Hello {member}!'
await channel.send(response)
client.run('bots_token')
我希望機器人刪除自己的消息.比如一分鐘后,我該怎么做?
And I want the bot to delete its own message. For example, after one minute, how do I do it?
推薦答案
有一個比 Dean Ambros 和 Dom 建議的更好的方法,你可以簡單地添加 kwarg.send
There is a better way than what Dean Ambros and Dom suggested, you can simply add the kwarg delete_after
in .send
await ctx.send('whatever', delete_after=60.0)
參考
這篇關于(Discord.py)如何讓機器人在一段時間后刪除自己的消息?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!