如何使用 python 使另一个机器人做某事的不和谐机器人命令

How to make a discord bot command using python which will make another bot do something

我正在尝试制作一个可以让我的其他机器人做某事的机器人,但我还没有真正找到实现它的方法有人可以帮助

它们就像普通命令一样工作。唯一的问题是大多数机器人不听取其他机器人的意见以避免滥用。

但是,如果您有一个您知道的机器人 听机器人,您可以像往常一样发送消息。使您的机器人发送 <other-bot's-prefix><command_name> <args> 的命令将正常工作。

@client.command()
async def dosmth(ctx, command):
    await ctx.send(f"{other-bots-prefix}{command}")

例如,如果您想使用另一个名为 ping 的机器人命令,它将变为 <your-bot's-prefix>dosmth ping

编辑:

在你的第二个机器人的 on_message 底部放置一个 await client.process_commands() 以使其也响应机器人。小心可能的副作用(其他机器人触发它,...)。

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