所以我试图为我的机器人做一个反应触发器。失败是每当你的消息中有“sus”时,机器人就会用 sus 表情做出反应

时间:2021-06-03 09:46:36

标签: python discord discord.py

这是我目前的代码:

@bot.event() 
async def  on_reaction_add(self, reaction, user,):
    if 'sus' in message.content:
        on_reaction_add(":sus:")

它在终端告诉我这个:

<块引用>

TypeError: event() 缺少 1 个必需的位置参数:'coro'

我该怎么办??

1 个答案:

答案 0 :(得分:2)

对不起,请不要在不理解的情况下从其他地方复制粘贴代码。建议你先学python。

话虽如此,您的错误是因为您为事件添加了 ()。只是@bot.event不是@bot.event()

on_reaction_add 是当有人添加反应时的事件。 message 不存在。 self 用于 cog,如果它在 Cog 中,则必须使用 @commands.Cog.listener() 而不是 @bot.event

出于您的目的使用 on_message 事件

@bot.event
async def on_message(message):
     if message.author.bot:
           return
     if "sus" in message.content.lower():
          await message.add_reaction("the emote")

# Note the emote needs to be in a form <:name:ID> or else it won't work
# your bot also needs to be in the server in which the "sus" emote is