Record Class EntityRef.RoleRef

java.lang.Object
java.lang.Record
dev.sympho.modular_commands.utils.parse.entity.EntityRef.RoleRef
Record Components:
id - The role ID.
guildId - The ID of the guild that the role exists in.
All Implemented Interfaces:
EntityRef<Role>
Enclosing interface:
EntityRef<E extends @NonNull Entity>

public static record EntityRef.RoleRef(Snowflake id, Snowflake guildId) extends Record implements EntityRef<Role>
A reference to a role.
Since:
1.0
  • Constructor Details

    • RoleRef

      public RoleRef(CommandContext context, Snowflake id) throws InvalidArgumentException
      Creates a new instance when only the ID is specified.
      Parameters:
      context - The execution context.
      id - The role ID.
      Throws:
      InvalidArgumentException - if the invocation was not in a guild.
      Implementation Requirements:
      Other values default to where the command was invoked in.
    • RoleRef

      public RoleRef(Snowflake id, Snowflake guildId)
      Creates an instance of a RoleRef record class.
      Parameters:
      id - the value for the id record component
      guildId - the value for the guildId record component
  • Method Details

    • defaultGuild

      @Pure public static Snowflake defaultGuild(CommandContext context) throws InvalidArgumentException
      Obtains the default guild based on the context.
      Parameters:
      context - The execution context.
      Returns:
      The guild ID.
      Throws:
      InvalidArgumentException - if the invocation was not in a guild.
    • everyoneId

      @Pure public static Snowflake everyoneId(CommandContext context) throws InvalidArgumentException
      Obtains the ID for the @everyone role.
      Parameters:
      context - The execution context.
      Returns:
      The @everyone role ID.
      Throws:
      InvalidArgumentException - if the invocation was not in a guild.
    • get

      public Mono<Role> get(GatewayDiscordClient client)
      Description copied from interface: EntityRef
      Obtains the referenced entity.
      Specified by:
      get in interface EntityRef<Role>
      Parameters:
      client - The client to use to connect to Discord.
      Returns:
      The entity. May be empty if there is no entity that matches the reference, and may fail with a InvalidArgumentException if an entity exists but there is a mismatch.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public Snowflake id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • guildId

      public Snowflake guildId()
      Returns the value of the guildId record component.
      Returns:
      the value of the guildId record component