I’m making a Discord bot with Python, the code is the following:
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:')
It gives me the following error that I can’t understand:
discord.app_commands.errors.CommandInvokeError: Command ‘hm’ raised an exception: AttributeError: ‘NoneType’ object has no attribute ‘add_reaction’
2
Answers
The
response
cannot be saved as a message that can be reacted to.Instead you should use
msg = await interaction.channel.send(embed=embed)
this will create a message variable for msg instead of a response.As Rexy had mentioned, InteractionResponse.send_message does not return any value, unlike Channel.send which returns the Message object of the message that was sent.
You can get the original_response (response sent with InteractionResponse) with the Interaction.original_response method.
For more information: InteractionResponse, InteractionResponse.send_message, Interaction.original_response