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 aGuildTemplate
with an associatedGatewayDiscordClient
and Discord data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mono<Guild>
createGuild(Consumer<? super GuildCreateFromTemplateSpec> spec)
Requests to create a new guild from this template.Mono<GuildTemplate>
delete()
Requests to delete this template.Mono<GuildTemplate>
edit(Consumer<? super GuildTemplateEditSpec> spec)
Requests to edit this guild template.GatewayDiscordClient
getClient()
Returns theGatewayDiscordClient
that created this object.String
getCode()
Gets the template code (unique ID).Instant
getCreatedAt()
Gets when the template was created.User
getCreator()
Gets the user who created the template.Snowflake
getCreatorId()
Gets the ID of the user who created the template.discord4j.discordjson.json.TemplateData
getData()
Gets the data of the template.Optional<String>
getDescription()
Gets the description of the template, if present.Snowflake
getGuildId()
Gets the ID of the guild this template is associated with.String
getName()
Gets the name of the template.discord4j.discordjson.json.SerializedSourceGuildData
getSourceGuild()
Gets the guild snapshot of the template.Instant
getUpdatedAt()
Gets when the template was last updated.int
getUsageCount()
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 aGuildTemplate
with an associatedGatewayDiscordClient
and Discord data.- Parameters:
gateway
- TheGatewayDiscordClient
associated 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:DiscordObject
Returns theGatewayDiscordClient
that created this object. Methods in it are exclusively based on the entity cache orStore
in use. Refer to callinggetClient().rest()
to access aDiscordClient
that is capable of requesting entities directly from the REST API.- Specified by:
getClient
in interfaceDiscordObject
- 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
public Mono<Guild> createGuild(Consumer<? super GuildCreateFromTemplateSpec> spec)
Requests to create a new guild from this template.- Parameters:
spec
- AConsumer
that provides a "blank"GuildTemplateEditSpec
to be operated on.- Returns:
- A
Mono
where, 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
Mono
that, upon subscription, syncs a template with its guild. If an error is received, it will be emitted through the Mono.
-
edit
public Mono<GuildTemplate> edit(Consumer<? super GuildTemplateEditSpec> spec)
Requests to edit this guild template.- Parameters:
spec
- AConsumer
that provides a "blank"GuildTemplateEditSpec
to be operated on.- Returns:
- A
Mono
where, 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
Mono
where, upon successful completion, emits the deleted template. If an error is received, it is emitted through theMono
.
-
-