title: (Discord Bot) on_raw_reaction_add(payload) problems (Ticket System)
body: <p>Hey I'm developing a Discord Bot with Python. Here is the documentation: <a href="https://discordpy.readthedocs.io/en/latest/index.html" rel="nofollow noreferrer">https://discordpy.readthedocs.io/en/latest/index.html</a></p>
  
  <p>I would ask a question. I making a discord bot in Python and I need help:</p>
  
  <ol>
  <li><p>Is it possible to make function in discord bot that I can relate to? I would like to include the entire ticketing system in event on_raw_reaction_add. Is this even possible? If this is not possible, then how to refer, for example, to a given ticket ?</p></li>
  <li><p>I would like to include a condition in the ticketing system. When creating a ticket, the user gets the rank "A". If he already has this rank, the bot will write to him that he has already created a ticket and will not be able to create another ticket. Does anyone have an idea how can I check if a user has a rank? I know that @ command.has_role exists, but this will not work for a condition.</p></li>
  </ol>
  
  <p>This is the my code:</p>
  
  <pre><code>@client.event
  async def on_raw_reaction_add(payload):
          message_id = payload.message_id
          if message_id == 701490140110913568:
                  guild_id = payload.guild_id
                  guild = discord.utils.find(lambda g : g.id == guild_id, client.guilds)
                  if payload.emoji.name == 'koperta':
                                  print("zlotek")
                                  channel = client.get_channel(payload.channel_id)
                                  message = await channel.fetch_message(payload.message_id)
                                  user = client.get_user(payload.user_id)
                                  emoji = client.get_emoji(700845595103068211)
                                  await message.remove_reaction(emoji, user)
                                  name = '✅ OPENED TICKETS ✅'
                                  category = discord.utils.get(guild.categories, name=name)
                                  overwrites = overwrites = {
                                  guild.default_role: discord.PermissionOverwrite(read_messages=False),
                                  guild.me: discord.PermissionOverwrite(read_messages=True)
                                  }
                                  await guild.create_text_channel(f'Ticket-0001', category=category, overwrites=overwrites)
                                  role = discord.utils.get(guild.roles, name='A')
                                  member = discord.utils.find(lambda m : m.id == payload.user_id, guild.members)
                                  await member.add_roles(role)
  </code></pre>
  
  <p>Thank you for all forms of help. You are the best</p>