[英]How to make a discord bot react to a edited command?
現在想象一下你輸入了錯誤的命令,然后你用正確的命令編輯消息,但機器人沒有響應它,所以你必須再次輸入整個命令,我希望我的機器人做的是:我會輸入錯誤的命令!pimg
和我將消息編輯回!ping
然后機器人應該意識到它的命令。
我怎樣才能讓我的機器人做到這一點
是的,有辦法使用“編輯事件”來做到這一點,您可能正在尋找discord.on_message_edit(before,after)
來源: https : //discordpy.readthedocs.io/en/latest/api.html?#event-reference
您可以通過實現這個discord.on_message_edit
事件,並通過嘗試與處理新編輯的命令discord.ext.commands.Bot.process_commands
:
@client.event
async def on_message_edit(before, after):
try:
await bot.process_commands(after) # Bot will attempt to process the new edited command
except:
raise error
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.