'How To Fix "Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'"

im making a simple license system in pycord and keep getting this error, when i redeem vixxy+ it works, but the others i get the error listed in the title. Any help is appreciated.

    @bot.slash_command(description="Redeem A Vixxy License Key.")
    async def redeem(ctx, code):
      user = ctx.author
      deluxerole = discord.utils.get(ctx.guild.roles, name="Vixxy Deluxe")
      deluxebadge = "Vixxy Deluxe"
      plusrole = discord.utils.get(ctx.guild.roles, name="Vixxy+")
      plusbadge = "Vixxy+"
      alpharole = discord.utils.get(ctx.guild.roles, name="Alpha Tester")
      alphabadge = "Alpha Tester"
      url = f"https://" + domain + f"/api.admin.addBadge/"
      if code in pluslicence:
        await user.add_roles(plusrole)
        embed=discord.Embed(description=f"***Successfully Redeemed Your Vixxy+ Key.***", colour=discord.Colour(0xFBFBFB))
        await ctx.respond(embed=embed)            
      if code in deluxelicence:
          await user.add_roles(deluxerole)
          embed=discord.Embed(description=f"***Successfully Redeemed Your Vixxy Deluxe Key.***", colour=discord.Colour(0xFBFBFB))
          await ctx.respond(embed=embed)
      if code in testerlicence:
          await user.add_roles(alpharole)
          embed=discord.Embed(description=f"***Successfully Redeemed Your Alpha Tester Key.***", colour=discord.Colour(0xFBFBFB))
          await ctx.respond(embed=embed)
      else:
          embed=discord.Embed(description=f"***This Key Doesn't Exist.***", colour=discord.Colour(0xFBFBFB))
          await ctx.respond(embed=embed)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source