How to use add_reaction without AttributeError ? (Using Hikari and Lightbulb) In Discord

Viewed 356

Im trying to make a discord bot which will an add reaction on a question . The code will get the message from the user using the command /poll and send it via an embed (already taken care of), here is my code

#Using Hikari And Lightbulb
import hikari
import lightbulb

@lightbulb.command("message", "type your message here")
@lightbulb.implements(lightbulb.SlashCommand)
async def poll(ctx):
    embed_options = (
    hikari.Embed(
      title="This is a test Embed",
      description="I want to add a reaction to this message"
    )
  )
  msg = await ctx.respond(embed=embed_options)
  await msg.add_reaction(":one:")

This code is just an example of my original code . Whenever I run it and the embed is sent, I get this error

await msg.add_reaction(":one:")
AttributeError: 'ResponseProxy' object has no attribute 'add_reaction'

Please note that I'm using Hikari and Lightbulb and not Discord.py

Documentation for Lightbulb - https://hikari-lightbulb.readthedocs.io/en/latest/

Github Page for Lightbulb - https://github.com/tandemdude/hikari-lightbulb

Hikari Documentation - https://www.hikari-py.dev/hikari/index.html

Hikari Github - https://github.com/hikari-py/hikari/

1 Answers

Judging from the error and after looking through a bit of the Lightbulb docs, I am fairly sure that ctx.respond is returning a ResponseProxy, try making it

#Using Hikari And Lightbulb
import hikari
import lightbulb

@lightbulb.command("message", "type your message here")
@lightbulb.implements(lightbulb.SlashCommand)
async def poll(ctx):
    embed_options = (
    hikari.Embed(
      title="This is a test Embed",
      description="I want to add a reaction to this message"
    )
  )
  rp = await ctx.respond(embed=embed_options)
  msg = await rp.message()
  await msg.add_reaction(":one:")
Related