0

I am trying to make on reaction edit embed...


@bot.event
async def on_raw_reaction_add(payload):
  channel = await bot.fetch_channel(payload.channel_id)
  message = await channel.fetch_message(payload.message_id)
  if payload.emoji.name == "✅":
    await message.set_field_at(4,"Status:","Accepted")
  elif payload.emoji.name == "❎":
    await message.set_field_at(4,"Status:","Denied")
  elif payload.emoji.name == "❌":
    await message.set_field_at(4,"Status:","Canceled")
  else:
    pass

Error given:

AttributeError: 'Message' object has no attribute 'set_field_at'

I don't know why this is happening...

1 Answers1

0

According to the documentation: https://discordpy.readthedocs.io/en/stable/api.html?highlight=fetch_emoji#discord.Guild.fetch_emoji

You want to call await fetch_emoji(id) with the emoji id and not the PartialEmoji object (which your emoji variable is). Instead use fetch_emoji(emoji.id)

Try the following:

@bot.event
async def on_raw_reaction_add(payload):
  channel = await bot.fetch_channel(payload.channel_id)
  message = await channel.fetch_message(payload.message_id)
  guild = await bot.fetch_guild(payload.guild_id)
  emoji = await guild.fetch_emoji(payload.emoji.id)
  if emoji.name == "U+2705":
    status = "Appected"
  elif emoji.name == "U+274E":
    status = "Denied"
  elif emoji.name == "U+274C":
    status = "Canceled"
  else:
    pass
  message.set_field_at(4,"Status:",f"{status}")
dnorhoj
  • 128
  • 1
  • 10