如何让不和谐的机器人对编辑的命令做出反应?
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
event and by attempting to process the newly edited command with 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
现在假设你输入了一个错误的命令,然后你用正确的命令编辑消息,但机器人没有响应,所以你必须再次输入整个命令,我希望我的机器人做的是:我会输入错误的命令 !pimg
,我将消息编辑回 !ping
然后机器人应该意识到它是一个命令。
我怎样才能让我的机器人做到这一点
是的,可以使用“编辑事件”来做到这一点,您可能正在寻找 discord.on_message_edit(before,after)
来源:https://discordpy.readthedocs.io/en/latest/api.html?#event-reference
您可以使用 discord.on_message_edit
event and by attempting to process the newly edited command with 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