Class GuildTemplate

java.lang.Object
discord4j.core.object.GuildTemplate
All Implemented Interfaces:
DiscordObject

public final class GuildTemplate extends Object implements DiscordObject
A Discord Guild Template.
See Also:
  • Constructor Details

    • GuildTemplate

      public GuildTemplate(GatewayDiscordClient gateway, discord4j.discordjson.json.TemplateData data)
      Constructs a GuildTemplate with an associated GatewayDiscordClient and Discord data.
      Parameters:
      gateway - The GatewayDiscordClient associated to this object, must be non-null.
      data - The raw data as represented by Discord, must be non-null.
  • Method Details

    • getClient

      public GatewayDiscordClient getClient()
      Description copied from interface: DiscordObject
      Returns the GatewayDiscordClient that created this object. Methods in it are exclusively based on the entity cache or Store in use. Refer to calling getClient().rest() to access a DiscordClient that is capable of requesting entities directly from the REST API.
      Specified by:
      getClient in interface DiscordObject
      Returns:
      The GatewayDiscordClient associated to this object.
    • getData

      public discord4j.discordjson.json.TemplateData getData()
      Gets the data of the template.
      Returns:
      The data of the template.
    • getCode

      public String getCode()
      Gets the template code (unique ID).
      Returns:
      The template code (unique ID).
    • getGuildId

      public Snowflake getGuildId()
      Gets the ID of the guild this template is associated with.
      Returns:
      The source guild ID.
    • getName

      public String getName()
      Gets the name of the template.
      Returns:
      The template name.
    • getDescription

      public Optional<String> getDescription()
      Gets the description of the template, if present.
      Returns:
      The template description.
    • getUsageCount

      public int getUsageCount()
      Gets the number of times the template has been used.
      Returns:
      The number of times the template has been used.
    • getCreatorId

      public Snowflake getCreatorId()
      Gets the ID of the user who created the template.
      Returns:
      The ID of the user who created the template.
    • getCreator

      public User getCreator()
      Gets the user who created the template.
      Returns:
      The user who created the template.
    • getCreatedAt

      public Instant getCreatedAt()
      Gets when the template was created.
      Returns:
      When the template was created.
    • getUpdatedAt

      public Instant getUpdatedAt()
      Gets when the template was last updated.
      Returns:
      When the template was last updated.
    • getSourceGuild

      public discord4j.discordjson.json.SerializedSourceGuildData getSourceGuild()
      Gets the guild snapshot of the template.
      Returns:
      The guild snapshot.
    • createGuild

      @Deprecated public Mono<Guild> createGuild(Consumer<? super LegacyGuildCreateFromTemplateSpec> spec)
      Deprecated.
      use createGuild(GuildCreateFromTemplateSpec) or createGuild(String) which offer an immutable approach to build specs
      Requests to create a new guild from this template.
      Parameters:
      spec - A Consumer that provides a "blank" LegacyGuildCreateFromTemplateSpec to be operated on.
      Returns:
      A Mono where, upon successful completion, emits the created guild. If an error is received, it is emitted through the Mono.
    • createGuild

      public discord4j.core.spec.GuildCreateFromTemplateMono createGuild(String name)
      Requests to create a new guild from this template. Properties specifying how to create a new guild from this template can be set via the withXxx methods of the returned GuildCreateFromTemplateMono.
      Parameters:
      name - the name of the guild to create
      Returns:
      A GuildCreateFromTemplateMono where, upon successful completion, emits the created guild. If an error is received, it is emitted through the GuildCreateFromTemplateMono.
    • createGuild

      public Mono<Guild> createGuild(discord4j.core.spec.GuildCreateFromTemplateSpec spec)
      Requests to create a new guild from this template.
      Parameters:
      spec - an immutable object that specifies how to create a new guild from this template
      Returns:
      A Mono where, upon successful completion, emits the created guild. If an error is received, it is emitted through the Mono.
    • sync

      public Mono<GuildTemplate> sync()
      Requests to sync this template with the guild's current state.
      Returns:
      a Mono that, upon subscription, syncs a template with its guild. If an error is received, it will be emitted through the Mono.
    • edit

      Deprecated.
      use edit(GuildTemplateEditSpec) or edit() which offer an immutable approach to build specs
      Requests to edit this guild template.
      Parameters:
      spec - A Consumer that provides a "blank" LegacyGuildTemplateEditSpec to be operated on.
      Returns:
      A Mono where, upon successful completion, emits the edited GuildTemplate. If an error is received, it is emitted through the Mono.
    • edit

      public discord4j.core.spec.GuildTemplateEditMono edit()
      Requests to edit this guild template. Properties specifying how to edit this template can be set via the withXxx methods of the returned GuildTemplateEditMono.
      Returns:
      A GuildTemplateEditMono where, upon successful completion, emits the edited GuildTemplate. If an error is received, it is emitted through the GuildTemplateEditMono.
    • edit

      public Mono<GuildTemplate> edit(discord4j.core.spec.GuildTemplateEditSpec spec)
      Requests to edit this guild template.
      Parameters:
      spec - an immutable object that specifies how to edit this template
      Returns:
      A Mono where, upon successful completion, emits the edited GuildTemplate. If an error is received, it is emitted through the Mono.
    • delete

      public Mono<GuildTemplate> delete()
      Requests to delete this template.
      Returns:
      A Mono where, upon successful completion, emits the deleted template. If an error is received, it is emitted through the Mono.