Package discord4j.core.object
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:
- Template Resource
-
-
Constructor Summary
Constructors Constructor Description GuildTemplate(GatewayDiscordClient gateway, discord4j.discordjson.json.TemplateData data)Constructs aGuildTemplatewith an associatedGatewayDiscordClientand Discord data.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Mono<Guild>createGuild(discord4j.core.spec.GuildCreateFromTemplateSpec spec)Requests to create a new guild from this template.discord4j.core.spec.GuildCreateFromTemplateMonocreateGuild(String name)Requests to create a new guild from this template.Mono<Guild>createGuild(Consumer<? super LegacyGuildCreateFromTemplateSpec> spec)Deprecated.usecreateGuild(GuildCreateFromTemplateSpec)orcreateGuild(String)which offer an immutable approach to build specsMono<GuildTemplate>delete()Requests to delete this template.discord4j.core.spec.GuildTemplateEditMonoedit()Requests to edit this guild template.Mono<GuildTemplate>edit(discord4j.core.spec.GuildTemplateEditSpec spec)Requests to edit this guild template.Mono<GuildTemplate>edit(Consumer<? super LegacyGuildTemplateEditSpec> spec)Deprecated.useedit(GuildTemplateEditSpec)oredit()which offer an immutable approach to build specsGatewayDiscordClientgetClient()Returns theGatewayDiscordClientthat created this object.StringgetCode()Gets the template code (unique ID).InstantgetCreatedAt()Gets when the template was created.UsergetCreator()Gets the user who created the template.SnowflakegetCreatorId()Gets the ID of the user who created the template.discord4j.discordjson.json.TemplateDatagetData()Gets the data of the template.Optional<String>getDescription()Gets the description of the template, if present.SnowflakegetGuildId()Gets the ID of the guild this template is associated with.StringgetName()Gets the name of the template.discord4j.discordjson.json.SerializedSourceGuildDatagetSourceGuild()Gets the guild snapshot of the template.InstantgetUpdatedAt()Gets when the template was last updated.intgetUsageCount()Gets the number of times the template has been used.Mono<GuildTemplate>sync()Requests to sync this template with the guild's current state.
-
-
-
Constructor Detail
-
GuildTemplate
public GuildTemplate(GatewayDiscordClient gateway, discord4j.discordjson.json.TemplateData data)
Constructs aGuildTemplatewith an associatedGatewayDiscordClientand Discord data.- Parameters:
gateway- TheGatewayDiscordClientassociated to this object, must be non-null.data- The raw data as represented by Discord, must be non-null.
-
-
Method Detail
-
getClient
public GatewayDiscordClient getClient()
Description copied from interface:DiscordObjectReturns theGatewayDiscordClientthat created this object. Methods in it are exclusively based on the entity cache orStorein use. Refer to callinggetClient().rest()to access aDiscordClientthat is capable of requesting entities directly from the REST API.- Specified by:
getClientin interfaceDiscordObject- Returns:
- The
GatewayDiscordClientassociated 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.usecreateGuild(GuildCreateFromTemplateSpec)orcreateGuild(String)which offer an immutable approach to build specsRequests to create a new guild from this template.- Parameters:
spec- AConsumerthat provides a "blank"LegacyGuildCreateFromTemplateSpecto be operated on.- Returns:
- A
Monowhere, upon successful completion, emits thecreated guild. If an error is received, it is emitted through theMono.
-
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 thewithXxxmethods of the returnedGuildCreateFromTemplateMono.- Parameters:
name- the name of the guild to create- Returns:
- A
GuildCreateFromTemplateMonowhere, upon successful completion, emits thecreated guild. If an error is received, it is emitted through theGuildCreateFromTemplateMono.
-
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
Monowhere, upon successful completion, emits thecreated guild. If an error is received, it is emitted through theMono.
-
sync
public Mono<GuildTemplate> sync()
Requests to sync this template with the guild's current state.- Returns:
- a
Monothat, upon subscription, syncs a template with its guild. If an error is received, it will be emitted through the Mono.
-
edit
@Deprecated public Mono<GuildTemplate> edit(Consumer<? super LegacyGuildTemplateEditSpec> spec)
Deprecated.useedit(GuildTemplateEditSpec)oredit()which offer an immutable approach to build specsRequests to edit this guild template.- Parameters:
spec- AConsumerthat provides a "blank"LegacyGuildTemplateEditSpecto be operated on.- Returns:
- A
Monowhere, upon successful completion, emits the editedGuildTemplate. If an error is received, it is emitted through theMono.
-
edit
public discord4j.core.spec.GuildTemplateEditMono edit()
Requests to edit this guild template. Properties specifying how to edit this template can be set via thewithXxxmethods of the returnedGuildTemplateEditMono.- Returns:
- A
GuildTemplateEditMonowhere, upon successful completion, emits the editedGuildTemplate. If an error is received, it is emitted through theGuildTemplateEditMono.
-
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
Monowhere, upon successful completion, emits the editedGuildTemplate. If an error is received, it is emitted through theMono.
-
delete
public Mono<GuildTemplate> delete()
Requests to delete this template.- Returns:
- A
Monowhere, upon successful completion, emits the deleted template. If an error is received, it is emitted through theMono.
-
-