允许不和谐重写机器人响应其他机器人



我有一个 Discord 机器人和一个 Discord 频道的网络钩子设置,每小时发送一次命令。但是,似乎默认情况下,Discord 重写会忽略从其他机器人发送的命令。我该如何禁用此功能?

我是否需要修改每个命令函数或on_message函数上的某些内容?

当前on_message

@bot.event
async def on_message(message):
    await bot.process_commands(message)

尝试为它添加检查:

on_message:

if message.author.bot == True:
    #Do something

命令:

if ctx.author.bot == True:
    #Do something

解决方案是:

@bot.event
async def on_message(message):
    ctx = await bot.get_context(message)
    await bot.invoke(ctx)

根据OP@Cynthia瓦尔迪兹对问题的编辑。

最新更新