0
votes

I'm making a reaction roles channel where if you react with an emoji it gives you the corresponding role. I used this exact same code with my verification system and it worked perfectly. But for some reason when I react to the message with the corresponding emoji, I don't get the role, no tracebacks show up and I don't get a message in the console saying "gave a role to someone".

Code:

async def roles(ctx):
  embed=discord.Embed(title="Reaction Roles", description="React with the corresponding emoji to get the role", color=0xff0000, timestamp=datetime.now())
  embed.set_author(name="Official Gnag Discord", icon_url="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2e/Exclamation_mark_red.png/50px-Exclamation_mark_red.png")
  embed.add_field(name="⛓️", value="Role 1", inline=True)
  embed.add_field(name="????", value="Role 2", inline=True)
  embed.add_field(name="????", value="Role 3", inline=True)
  embed.add_field(name="????️‍????", value="Role 4", inline=True)
  embed.add_field(name="????", value="Role 5", inline=True)
  embed.add_field(name="????", value="Role 6", inline=True)
  embed.add_field(name="????", value="Role 7", inline=True)
  embed.add_field(name="✔️", value="Role 8", inline=True)
  embed.add_field(name="????", value="Role 9", inline=True)
  embed.add_field(name="????", value="Role 10", inline=True)
  embed.add_field(name="♂️", value="Role 11", inline=True)
  embed.set_footer(text="Official Gnag Discord Bot Made By @Lukeee#6032")
  msg = await ctx.send(embed=embed)
  await msg.add_reaction('????')
  await msg.add_reaction('✔️')
  await msg.add_reaction('????')
  await msg.add_reaction('????')
  await msg.add_reaction('♂️')
  await msg.add_reaction('⛓️')
  await msg.add_reaction('????')
  await msg.add_reaction('????')
  await msg.add_reaction('????️‍????')
  await msg.add_reaction('????')
  await msg.add_reaction('????')


@bot.event
async def on_raw_reaction_add(payload):
    ourMessageID = 819597141743763467

    if ourMessageID == payload.message_id:
      member = payload.member
      guild = member.guild

      emoji = payload.emoji.name
      if emoji == '????':
        mrole = discord.utils.get(guild.roles, name='Role 7')
        await member.add_roles(mrole)
        print ('gave a role to someone')
1
What's the issue then?Cristian
Welcome to StackOverflow. Please read how-to-ask and ask a proper questionshark
Whenever I add a reaction, no errors pop up or anything, I also coded it to say "gave someone a role" in the console and it doesn't say that.Luke

1 Answers

1
votes

hey although you didnt say what you issue is I suppose that the command does not work properly.I would recommend doing something like this:

async def roles(ctx):
      embed=discord.Embed(title="Reaction Roles", description="React with the corresponding emoji to get the role", color=0xff0000)
      embed.set_author(name="Official Gnag Discord", icon_url="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2e/Exclamation_mark_red.png/50px-Exclamation_mark_red.png")
      embed.add_field(name="⛓️", value="Role 1", inline=True)
      embed.add_field(name="💩", value="Role 2", inline=True)
      embed.add_field(name="💣", value="Role 3", inline=True)
      embed.add_field(name="🏳️‍🌈", value="Role 4", inline=True)
      embed.add_field(name="👧", value="Role 5", inline=True)
      embed.add_field(name="🌈", value="Role 6", inline=True)
      embed.add_field(name="🤡", value="Role 7", inline=True)
      embed.add_field(name="✔️", value="Role 8", inline=True)
      embed.add_field(name="🤓", value="Role 9", inline=True)
      embed.add_field(name="🎥", value="Role 10", inline=True)
      embed.add_field(name="♂️", value="Role 11", inline=True)
      embed.set_footer(text="Official Gnag Discord Bot Made By @Lukeee#6032")
      msg = await ctx.send(embed=embed)
      await msg.add_reaction('🤡')
      await msg.add_reaction('✔️')
      await msg.add_reaction('🤓')
      await msg.add_reaction('🎥')
      await msg.add_reaction('♂️')
      await msg.add_reaction('⛓️')
      await msg.add_reaction('💩')
      await msg.add_reaction('💣')
      await msg.add_reaction('🏳️‍🌈')
      await msg.add_reaction('👧')
      await msg.add_reaction('🌈')

      def check(reaction, user):

            return user == ctx.user and reaction.message == msg and str(reaction.emoji) in ['🤡','✔','🤓','🎥','♂','⛓','💩','💣','🏳️‍🌈','👧','🌈']

      while True:
           try:
               reaction, user = await client.wait_for("reaction_add", check=check)

               if str(reaction.emoji) == '🤡':
                    mrole = discord.utils.get(ctx.guild.roles, name='Role 7')
                    await user.add_roles(mrole)
                    print ('gave a role to someone')
               

Ps before you copy and paste it, read it. It might not even work for you.

Edit:You can also join the discord.py server for more help discord.py