Package net.dv8tion.jda.api.entities
Class RoleConnectionMetadata
java.lang.Object
net.dv8tion.jda.api.entities.RoleConnectionMetadata
- All Implemented Interfaces:
SerializableData
A metadata record used for role connections.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The type of metadata. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The maximum length a description can be (200)static final int
The maximum length a key can be (50)static final int
The maximum length a name can be (100)static final int
The maximum number of records that can be configured (5) -
Constructor Summary
ConstructorDescriptionRoleConnectionMetadata
(RoleConnectionMetadata.MetadataType type, String name, String key, String description) Creates a new RoleConnectionMetadata instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
static RoleConnectionMetadata
fromData
(DataObject data) Parses aRoleConnectionMetadata
from aDataObject
.The description of the metadata.The localizations of this record's description forvarious languages
.getKey()
The key of the metadata.getName()
The display name of the metadata.The localizations of this record's name forvarious languages
.getType()
The type of the metadata.int
hashCode()
setDescriptionLocalization
(DiscordLocale locale, String description) Sets alanguage-specific
localization of this record's description.Sets multiplelanguage-specific
localizations of this record's description.setNameLocalization
(DiscordLocale locale, String name) Sets alanguage-specific
localization of this record's name.Sets multiplelanguage-specific
localizations of this record's name.toData()
SerializedDataObject
for this object.toString()
-
Field Details
-
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTHThe maximum length a name can be (100)- See Also:
-
MAX_DESCRIPTION_LENGTH
public static final int MAX_DESCRIPTION_LENGTHThe maximum length a description can be (200)- See Also:
-
MAX_KEY_LENGTH
public static final int MAX_KEY_LENGTHThe maximum length a key can be (50)- See Also:
-
MAX_RECORDS
public static final int MAX_RECORDSThe maximum number of records that can be configured (5)- See Also:
-
-
Constructor Details
-
RoleConnectionMetadata
public RoleConnectionMetadata(@Nonnull RoleConnectionMetadata.MetadataType type, @Nonnull String name, @Nonnull String key, @Nonnull String description) Creates a new RoleConnectionMetadata instance.- Parameters:
type
- TheRoleConnectionMetadata.MetadataType
name
- The display name of the metadatakey
- The key of the metadata (to update the value later)description
- The description of the metadata- Throws:
IllegalArgumentException
-- If null is provided
- If the provided name is empty or more than 100 characters long
- If the provided key is empty or more than 50 characters long
- If the provided description is empty or more than 200 characters long
- If the provided type is
RoleConnectionMetadata.MetadataType.UNKNOWN
- If the provided key contains any characters other than
a-z
,0-9
, or_
-
-
Method Details
-
getType
The type of the metadata.- Returns:
- The type, or
RoleConnectionMetadata.MetadataType.UNKNOWN
if unknown
-
getName
The display name of the metadata.- Returns:
- The display name
-
getKey
The key of the metadata.- Returns:
- The key
-
getDescription
The description of the metadata.- Returns:
- The description
-
getNameLocalizations
The localizations of this record's name forvarious languages
.- Returns:
- The
LocalizationMap
containing the mapping fromDiscordLocale
to the localized name
-
getDescriptionLocalizations
The localizations of this record's description forvarious languages
.- Returns:
- The
LocalizationMap
containing the mapping fromDiscordLocale
to the localized description
-
setNameLocalization
@Nonnull public RoleConnectionMetadata setNameLocalization(@Nonnull DiscordLocale locale, @Nonnull String name) Sets alanguage-specific
localization of this record's name.This change will not take effect in Discord until you update the role connection metadata using
JDA.updateRoleConnectionMetadata(Collection)
.- Parameters:
locale
- The locale to associate the translated name withname
- The translated name to put- Returns:
- This updated record instance
- Throws:
IllegalArgumentException
-- If the locale is null
- If the name is null
- If the locale is
DiscordLocale.UNKNOWN
- If the provided name is empty or more than 100 characters long
-
setNameLocalizations
Sets multiplelanguage-specific
localizations of this record's name.This change will not take effect in Discord until you update the role connection metadata using
JDA.updateRoleConnectionMetadata(Collection)
.- Parameters:
map
- The map from which to transfer the translated names- Returns:
- This updated record instance
- Throws:
IllegalArgumentException
-- If the map is null
- If the map contains an
DiscordLocale.UNKNOWN
key - If the map contains a name which is empty or more than 100 characters long
-
setDescriptionLocalization
@Nonnull public RoleConnectionMetadata setDescriptionLocalization(@Nonnull DiscordLocale locale, @Nonnull String description) Sets alanguage-specific
localization of this record's description.This change will not take effect in Discord until you update the role connection metadata using
JDA.updateRoleConnectionMetadata(Collection)
.- Parameters:
locale
- The locale to associate the translated description withdescription
- The translated description to put- Returns:
- This updated record instance
- Throws:
IllegalArgumentException
-- If the locale is null
- If the description is null
- If the locale is
DiscordLocale.UNKNOWN
- If the provided description is empty or more than 200 characters long
-
setDescriptionLocalizations
@Nonnull public RoleConnectionMetadata setDescriptionLocalizations(@Nonnull Map<DiscordLocale, String> map) Sets multiplelanguage-specific
localizations of this record's description.This change will not take effect in Discord until you update the role connection metadata using
JDA.updateRoleConnectionMetadata(Collection)
.- Parameters:
map
- The map from which to transfer the translated descriptions- Returns:
- This updated record instance
- Throws:
IllegalArgumentException
-- If the map is null
- If the map contains an
DiscordLocale.UNKNOWN
key - If the map contains a description which is empty or more than 200 characters long
-
toString
-
equals
-
hashCode
public int hashCode() -
toData
Description copied from interface:SerializableData
SerializedDataObject
for this object.- Specified by:
toData
in interfaceSerializableData
- Returns:
DataObject
-
fromData
- Parameters:
data
- The data object to parse values from#- Returns:
- The parsed metadata instance
- Throws:
IllegalArgumentException
- If the provided data object is nullParsingException
- If the provided data does not have a valid int type value
-