Discord.py 2.0
我无法在交互消息中添加反应
@bot.tree.command()
@app_commands.describe(question="Give a title")
async def poll(interaction: discord.Interaction, question: str):
emb = discord.Embed(title=f":bar_chart: {question}n",
type="rich")
message = await interaction.response.send_message(embed=emb)
emoji = ("✅")
await interaction.message.add_reaction(emoji)
同时获取错误:discord.app_commands.errors.CommonInvokeError:命令"poll"引发异常:AttributeError:"NoneType"对象没有属性"add_reaction">
我认为是:
await message.add_reaction(emoji)
问题是message = await interaction.response.send_message(embed=emb)
返回一个NoneType对象。为了使您的代码工作,您需要首先发送消息,然后将其作为";原始响应":
await interaction.response.send_message(embed = page1)
message = await interaction.original_response()