Record Class GuildPrefix
java.lang.Object
java.lang.Record
dev.sympho.modular_commands.execute.GuildPrefix
- Record Components:
prefixes- The prefixes per guild, keyed by the guild ID.defaultPrefix- The default prefix.
- All Implemented Interfaces:
PrefixProvider
public record GuildPrefix(Map<Snowflake,String> prefixes, String defaultPrefix)
extends Record
implements PrefixProvider
Prefix provider that allows prefix overrides per guild while falling back to
a default construction-time prefix if no override.
Private channels are treated as guilds with no override, so the default prefix is used in their case.
- Since:
- 1.0
- Version:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionGuildPrefix(String defaultPrefix) Creates a new instance with no overrides.GuildPrefix(Map<Snowflake, String> prefixes, String defaultPrefix) Creates a new instance with the given set of initial overrides. -
Method Summary
Modifier and TypeMethodDescriptionbooleanclearPrefix(Snowflake guildId) Clears the override for a guild, if there is one.Returns the value of thedefaultPrefixrecord component.final booleanIndicates whether some other object is "equal to" this one.Determines the prefix that should be used for the given guild.final inthashCode()Returns a hash code value for this object.prefixes()Returns the value of theprefixesrecord component.voidSets a prefix override for a guild.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
GuildPrefix
Creates a new instance with the given set of initial overrides.- Parameters:
prefixes- The initial prefixes per guild, keyed by the guild ID.defaultPrefix- The default prefix.
-
GuildPrefix
Creates a new instance with no overrides.- Parameters:
defaultPrefix- The default prefix.
-
-
Method Details
-
setPrefix
Sets a prefix override for a guild.- Parameters:
guildId- The guild to set the override for.prefix- The prefix to use for that guild.
-
clearPrefix
Clears the override for a guild, if there is one.- Parameters:
guildId- The guild to reset the prefix override for.- Returns:
trueif the prefix was reset for the given guild.falseif the given guild did not have a prefix override.
-
getPrefix
Description copied from interface:PrefixProviderDetermines the prefix that should be used for the given guild.- Specified by:
getPrefixin interfacePrefixProvider- Parameters:
guildId- The ID of the guild that the event was issued from, ornullif it was issued from a private channel.- Returns:
- The prefix to use.
-
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). -
prefixes
Returns the value of theprefixesrecord component.- Returns:
- the value of the
prefixesrecord component
-
defaultPrefix
Returns the value of thedefaultPrefixrecord component.- Returns:
- the value of the
defaultPrefixrecord component
-