Class Template

java.lang.Object
net.dv8tion.jda.api.entities.templates.Template

public class Template extends Object
Representation of a Discord Guild Template
This class is immutable.
Since:
4.3.0
See Also:
  • Constructor Details

  • Method Details

    • resolve

      @Nonnull @CheckReturnValue public static RestAction<Template> resolve(@Nonnull JDA api, @Nonnull String code)
      Retrieves a new Template instance for the given template code.

      Possible ErrorResponses include:

      Parameters:
      api - The JDA instance
      code - 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

      @Nonnull @CheckReturnValue public RestAction<Template> sync()
      Syncs this template.
      Requires MANAGE_SERVER in the template's guild. Will throw an InsufficientPermissionException otherwise.
      Returns:
      RestAction - Type: Template
      The synced Template object
      Throws:
      IllegalStateException - If the account is not in the template's guild
      InsufficientPermissionException - If the account does not have MANAGE_SERVER in the template's guild
    • delete

      @Nonnull @CheckReturnValue public RestAction<Void> delete()
      Deletes this template.
      Requires MANAGE_SERVER in the template's guild. Will throw an InsufficientPermissionException otherwise.
      Returns:
      RestAction
      Throws:
      IllegalStateException - If the account is not in the template's guild
      InsufficientPermissionException - If the account does not have MANAGE_SERVER in the template's guild
    • getCode

      @Nonnull public String getCode()
      The template code.
      Returns:
      The template code
    • getName

      @Nonnull public String getName()
      The template name.
      Returns:
      The template name
    • getDescription

      @Nullable public String 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

      @Nonnull public User getCreator()
      The user who created this template.
      Returns:
      The user who created this template
    • getTimeCreated

      @Nonnull public OffsetDateTime getTimeCreated()
      Returns creation date of this template.
      Returns:
      The creation date of this template
    • getTimeUpdated

      @Nonnull public OffsetDateTime 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

      @Nonnull public TemplateGuild getGuild()
      A Template.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

      @Nonnull @CheckReturnValue public TemplateManager getManager()
      Returns the TemplateManager 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 calling RestAction.queue().
      Returns:
      The TemplateManager of this Template
      Throws:
      IllegalStateException - If the account is not in the template's guild
      InsufficientPermissionException - If the currently logged in account does not have MANAGE_SERVER
    • getJDA

      @Nonnull public JDA getJDA()
      The JDA instance used to create this Template instance.
      Returns:
      The corresponding JDA instance
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object