如何解决我的Python代码中的错误?

问题描述 投票:0回答:1

你好,我正在用Python制作一个Discord机器人,代码如下:

embed = discord.Embed(title=f'Topic: {tema.capitalize()}',
                      description='The word has ' + str(len(secretWord)) + ' letters',
                      color=discord.Color.yellow())
msg = await interaction.response.send_message(embed=embed)
await msg.add_reaction('regional_indicator_1:')

它给了我以下我无法理解的错误:

discord.app_commands.errors.CommandInvokeError:命令“hm”引发异常:AttributeError:“NoneType”对象没有属性“add_reaction”

javascript python discord discord.js discord.py
1个回答
-1
投票

代码的目的是将表情符号发送到嵌入,但错误表明没有这样的属性。嵌入发送成功,但表情符号出现错误。

我阅读了文档,但它不起作用。我已经尝试将其保存在变量中,但它不起作用。

文档:https://discordpy.readthedocs.io/en/stable/interactions/api.html?highlight=add_reaction#interaction

© www.soinside.com 2019 - 2024. All rights reserved.