I'm using Hikari + Lightbulb to create my first discord bot and I'm using this as an opportunity to learn as much as possible. As mentioned in the title, I just want to learn how to use
add_reaction(":smile:")
correctly. I've read through the Hikari documentation and to be honest, I am having difficulties understanding it fully. I thought the correct line of code would be something along the lines of this
@bot.listen(hikari.MessageCreateEvent)
async def message(event):
print(event.content)
await message.add_reaction(":smile:")
When I go to run this code I receive the following error: AttributeError: 'GuildMessageCreateEvent' object has no attribute 'add_reaction'
. This is making think my error lies with using the MessageCreateEvent
object but after reading the documentation I can't tell which object does support this attribute. Is there something I'm missing? Or am I simply not using the attribute correctly and it's meant to be used in some other way?
Okay so I've managed to figure it out with Help from the comments (Thank you Guimoute).
I needed to include event.
before the message.add_reaction
.
Just in case anyone has had a similar issue this is the complete code that worked for me
@bot.listen(hikari.MessageCreateEvent)
async def message(event):
print(event.content)
await event.message.add_reaction(emoji="👍")
Keen eyed among you will notice I had to change the end. If you don't be specific and and use emoji=""
is will tell you that the value is not snowflake, I don't fully understand it but reading over some of the discord dev portal documentation, I think it's a requirement of discord.