title: How to check if a role already exists in discord.py
body: <p><strong>How to check if a role already exist in discord.py</strong></p>
  <p>I am trying a command which creates a role, but if the role already exist the code won't create a new role.</p>
  <pre class="lang-py prettyprint-override"><code>@bot.command()
  async def modrole(ctx):
      guild = ctx.guild
      if guild.has_role(name=&quot;BotMod&quot;):
          await ctx.send(&quot;Role already exists&quot;)
      else:
          await guild.create_role(name=&quot;BotMod&quot;, colour=discord.Colour(0x0062ff))
  </code></pre>