[英]python - Is there a way to make a discord bot listen to another discord bot?
我正在嘗試制作一個程序來創建一個無限循環,例如:
bot1.py
@bot.command()
async def loop1(ctx):
await ctx.send('$loop2')
bot2.py
@bot.command()
async def loop2(ctx):
await ctx.send('$loop1')
但主要問題是機器人不會聽另一個機器人,所以這行不通......
有沒有辦法讓機器人聽另一個機器人? 提前致謝! :)
也許您可以使用on_message
事件而不是使用async def
來定義命令。
bot1.py:
@bot.event
async def on_message(message):
if message.content.startswith('$loop1'):
channel = message.channel
await channel.send("$loop2")
bot2.py:
@bot.event
async def on_message(message):
if message.content.startswith('$loop2'):
channel = message.channel
await channel.send("$loop1")
不完全確定這是否有效,但你可以嘗試
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.