python - 我需要帮助修复这个@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!")
^ 那是不与拥抱事件一起使用的代码之一。
解决方案
@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
推荐阅读
- php - 通过编码更改保留重音字符
- python - 来自def的Jsonify在python中返回空
- python - ModuleNotFoundError:没有名为“py_geo_nearby”的模块
- javascript - 如何在 puppeteer 上等待消失微调器?
- python - 如何使用 requests.post python 模块登录网站
- javascript - 如何通过 ReactJs 将巨大的 Json 转换为数组
- python - 如何使用beautifulsoup仅提取文本?
- c - C - 使用 scanf 读取特殊字符,如“ã”
- c++ - 冒泡排序 - 如何使用它?
- php - Symfony HttpClient GET 请求具有多个具有相同名称的查询字符串参数