首页 > 解决方案 > 我需要帮助修复这个@bot.event 循环

问题描述

@bot.event
async def on_message(message):
  if message.author ==bot.user or message.author.bot:
    return
  mention=message.author.mention
  if message.content == "$hug":  
    await message.channel.send(f"Hugs {mention} back")
    return

这是我用来运行循环的代码,它可以工作,但会关闭我的其余代码。我想知道这段代码中关闭其余部分的内容是什么。

Im using replit and am using one of the discord.py templates.
@bot.command()
async def dink(ctx):
    await ctx.send("Donk!")

^ 那是不与拥抱事件一起使用的代码之一。

标签: pythondiscord.py

解决方案



    @bot.event
    async def on_message(message):
      if message.author ==bot.user or message.author.bot:
        return
      mention=message.author.mention
      if message.content == "$hug":  
        await message.channel.send(f"Hugs {mention} back")
        return
      elif message.content == "dink":
        await message.channel.send("Donk!")
        return


推荐阅读