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.
public static record EntityRef.RoleRef(Snowflake id, Snowflake guildId)
extends Record
implements EntityRef<Role>
A reference to a role.
- Since:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.sympho.modular_commands.utils.parse.entity.EntityRef
EntityRef.ChannelRef<C extends @NonNull Channel>, EntityRef.MessageRef, EntityRef.RoleRef, EntityRef.UserRef -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SnowflakedefaultGuild(CommandContext context) Obtains the default guild based on the context.final booleanIndicates whether some other object is "equal to" this one.static SnowflakeeveryoneId(CommandContext context) Obtains the ID for the@everyonerole.get(GatewayDiscordClient client) Obtains the referenced entity.guildId()Returns the value of theguildIdrecord component.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
RoleRef
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
Creates an instance of aRoleRefrecord class.
-
-
Method Details
-
defaultGuild
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
Obtains the ID for the@everyonerole.- Parameters:
context- The execution context.- Returns:
- The
@everyonerole ID. - Throws:
InvalidArgumentException- if the invocation was not in a guild.
-
get
Description copied from interface:EntityRefObtains the referenced entity.- Specified by:
getin interfaceEntityRef<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
InvalidArgumentExceptionif an entity exists but there is a mismatch.
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
guildId
Returns the value of theguildIdrecord component.- Returns:
- the value of the
guildIdrecord component
-