original_docstring: Give a user a class role.
docstring: Give a user a class role.
docstring_tokens: Give a user a class role .
code: async def _add_class_role(
          self, ctx: commands.Context, user: discord.Member, role: int, role_name: str
      ) -> None:
          """Give a user a class role."""
          # Default to the user being the author
          if user is None:
              user = ctx.author
          # Check if the user is not a mod and they tried to give someone else a role.
          if user != ctx.author and await has_no_roles_check(ctx, *MOD_ROLES):
              await self._send_but_delete_in_roles(
                  ctx,
                  f"{Emoji.no} You cannot assign a user other than yourself a class "
                  + "role.",
              )
              return
          elif user != ctx.author and await has_any_role_check(ctx, *MOD_ROLES):
              log.info(
                  f"Replacing {user}'s class roles at request of moderator {ctx.author}"
              )
              for old_role in CLASS_ROLES:
                  await user.remove_roles(
                      discord.Object(old_role),
                      reason=f"Moderator {ctx.author} replacing {user}'s Class Roles",
                  )
              await user.add_roles(discord.Object(role), reason="Class Roles")
              log.trace(f"Assigned {user} the {role_name} role")
              await self._send_but_delete_in_roles(
                  ctx, f"{Emoji.ok} User `{user}` has been given the {role_name} role."
              )
              return
  
          # Check if the user is self-roleing and already has a class role.
          if user == ctx.author and await has_any_role_check(ctx, *CLASS_ROLES):
              modmail = discord.utils.get(ctx.guild.members, id=575252669443211264)
              await self._send_but_delete_in_roles(
                  ctx,
                  f"{Emoji.no} You already have a class role. If you mistakenly "
                  + f"assigned the wrong role, contact {modmail.mention}.",
              )
              return
  
          await user.add_roles(discord.Object(role), reason="Class Roles")
          log.info(f"Assigned {user} the {role_name} role")
  
          await self._send_but_delete_in_roles(
              ctx,
              f"{ctx.author.mention}, you have successfully been given the "
              + f"{role_name} role.",
          )
code_tokens: async def _add_class_role ( self , ctx : commands . Context , user : discord . Member , role : int , role_name : str ) -> None : if user is None : user = ctx . author if user != ctx . author and await has_no_roles_check ( ctx , * MOD_ROLES ) : await self . _send_but_delete_in_roles ( ctx , f"{Emoji.no} You cannot assign a user other than yourself a class " + "role." , ) return elif user != ctx . author and await has_any_role_check ( ctx , * MOD_ROLES ) : log . info ( f"Replacing {user}'s class roles at request of moderator {ctx.author}" ) for old_role in CLASS_ROLES : await user . remove_roles ( discord . Object ( old_role ) , reason = f"Moderator {ctx.author} replacing {user}'s Class Roles" , ) await user . add_roles ( discord . Object ( role ) , reason = "Class Roles" ) log . trace ( f"Assigned {user} the {role_name} role" ) await self . _send_but_delete_in_roles ( ctx , f"{Emoji.ok} User `{user}` has been given the {role_name} role." ) return if user == ctx . author and await has_any_role_check ( ctx , * CLASS_ROLES ) : modmail = discord . utils . get ( ctx . guild . members , id = 575252669443211264 ) await self . _send_but_delete_in_roles ( ctx , f"{Emoji.no} You already have a class role. If you mistakenly " + f"assigned the wrong role, contact {modmail.mention}." , ) return await user . add_roles ( discord . Object ( role ) , reason = "Class Roles" ) log . info ( f"Assigned {user} the {role_name} role" ) await self . _send_but_delete_in_roles ( ctx , f"{ctx.author.mention}, you have successfully been given the " + f"{role_name} role." , )
short_docstring: Give a user a class role.
short_docstring_tokens: Give a user a class role .
comment: """Give a user a class role."""$SEP$# Default to the user being the author$SEP$# Check if the user is not a mod and they tried to give someone else a role.$SEP$# Check if the user is self-roleing and already has a class role.