Class Template
java.lang.Object
net.dv8tion.jda.api.entities.templates.Template
Representation of a Discord Guild Template
This class is immutable.
This class is immutable.
- Since:
- 4.3.0
- See Also:
-
Constructor Summary
ConstructorDescriptionTemplate
(net.dv8tion.jda.internal.JDAImpl api, String code, String name, String description, int uses, User creator, OffsetDateTime createdAt, OffsetDateTime updatedAt, TemplateGuild guild, boolean synced) -
Method Summary
Modifier and TypeMethodDescriptiondelete()
Deletes this template.boolean
getCode()
The template code.The user who created this template.The template description.getGuild()
ATemplate.Guild
object containing information about this template's origin guild.getJDA()
TheJDA
instance used to create this Template instance.Returns theTemplateManager
for this Template.getName()
The template name.Returns creation date of this template.Returns the last update date of this template.int
getUses()
How often this template has been used.int
hashCode()
boolean
isSynced()
Whether or not this template is synced.static RestAction<Template>
Retrieves a newTemplate
instance for the given template code.sync()
Syncs this template.toString()
-
Constructor Details
-
Template
public Template(net.dv8tion.jda.internal.JDAImpl api, String code, String name, String description, int uses, User creator, OffsetDateTime createdAt, OffsetDateTime updatedAt, TemplateGuild guild, boolean synced)
-
-
Method Details
-
resolve
Retrieves a newTemplate
instance for the given template code.Possible
ErrorResponses
include:Unknown Guild Template
The template doesn't exist.
- Parameters:
api
- The JDA instancecode
- A valid template code- Returns:
RestAction
- Type:Template
The Template object- Throws:
IllegalArgumentException
-- If the provided code is null or empty
- If the provided code contains a whitespace
- If the provided JDA object is null
-
sync
Syncs this template.
RequiresMANAGE_SERVER
in the template's guild. Will throw anInsufficientPermissionException
otherwise.- Returns:
RestAction
- Type:Template
The synced Template object- Throws:
IllegalStateException
- If the account is not in the template's guildInsufficientPermissionException
- If the account does not haveMANAGE_SERVER
in the template's guild
-
delete
Deletes this template.
RequiresMANAGE_SERVER
in the template's guild. Will throw anInsufficientPermissionException
otherwise.- Returns:
RestAction
- Throws:
IllegalStateException
- If the account is not in the template's guildInsufficientPermissionException
- If the account does not haveMANAGE_SERVER
in the template's guild
-
getCode
The template code.- Returns:
- The template code
-
getName
The template name.- Returns:
- The template name
-
getDescription
The template description.- Returns:
- The template description
-
getUses
public int getUses()How often this template has been used.- Returns:
- The uses of this template
-
getCreator
The user who created this template.- Returns:
- The user who created this template
-
getTimeCreated
Returns creation date of this template.- Returns:
- The creation date of this template
-
getTimeUpdated
Returns the last update date of this template.
If this template has never been updated, this returns the date of creation.- Returns:
- The last update date of this template
- See Also:
-
getGuild
ATemplate.Guild
object containing information about this template's origin guild.- Returns:
- Information about this template's origin guild
- See Also:
-
isSynced
public boolean isSynced()Whether or not this template is synced.- Returns:
- True, if this template matches the current guild structure
-
getManager
Returns theTemplateManager
for this Template.
In the TemplateManager, you can modify the name or description of the template. You modify multiple fields in one request by chaining setters before callingRestAction.queue()
.- Returns:
- The TemplateManager of this Template
- Throws:
IllegalStateException
- If the account is not in the template's guildInsufficientPermissionException
- If the currently logged in account does not haveMANAGE_SERVER
-
getJDA
TheJDA
instance used to create this Template instance.- Returns:
- The corresponding JDA instance
-
hashCode
public int hashCode() -
equals
-
toString
-