Package discord4j.core.object
Class GuildTemplate
java.lang.Object
discord4j.core.object.GuildTemplate
- All Implemented Interfaces:
DiscordObject
A Discord Guild Template.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionGuildTemplate
(GatewayDiscordClient gateway, discord4j.discordjson.json.TemplateData data) Constructs aGuildTemplate
with an associatedGatewayDiscordClient
and Discord data. -
Method Summary
Modifier and TypeMethodDescriptioncreateGuild
(discord4j.core.spec.GuildCreateFromTemplateSpec spec) Requests to create a new guild from this template.discord4j.core.spec.GuildCreateFromTemplateMono
createGuild
(String name) Requests to create a new guild from this template.createGuild
(Consumer<? super LegacyGuildCreateFromTemplateSpec> spec) Deprecated.delete()
Requests to delete this template.discord4j.core.spec.GuildTemplateEditMono
edit()
Requests to edit this guild template.edit
(discord4j.core.spec.GuildTemplateEditSpec spec) Requests to edit this guild template.edit
(Consumer<? super LegacyGuildTemplateEditSpec> spec) Deprecated.useedit(GuildTemplateEditSpec)
oredit()
which offer an immutable approach to build specsReturns theGatewayDiscordClient
that created this object.getCode()
Gets the template code (unique ID).Gets when the template was created.Gets the user who created the template.Gets the ID of the user who created the template.discord4j.discordjson.json.TemplateData
getData()
Gets the data of the template.Gets the description of the template, if present.Gets the ID of the guild this template is associated with.getName()
Gets the name of the template.discord4j.discordjson.json.SerializedSourceGuildData
Gets the guild snapshot of the template.Gets when the template was last updated.int
Gets the number of times the template has been used.sync()
Requests to sync this template with the guild's current state.
-
Constructor Details
-
GuildTemplate
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 Details
-
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
Gets the template code (unique ID).- Returns:
- The template code (unique ID).
-
getGuildId
Gets the ID of the guild this template is associated with.- Returns:
- The source guild ID.
-
getName
Gets the name of the template.- Returns:
- The template name.
-
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
Gets the ID of the user who created the template.- Returns:
- The ID of the user who created the template.
-
getCreator
Gets the user who created the template.- Returns:
- The user who created the template.
-
getCreatedAt
Gets when the template was created.- Returns:
- When the template was created.
-
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
- AConsumer
that provides a "blank"LegacyGuildCreateFromTemplateSpec
to be operated on.- Returns:
- A
Mono
where, upon successful completion, emits thecreated guild
. If an error is received, it is emitted through theMono
.
-
createGuild
Requests to create a new guild from this template. Properties specifying how to create a new guild from this template can be set via thewithXxx
methods of the returnedGuildCreateFromTemplateMono
.- Parameters:
name
- the name of the guild to create- Returns:
- A
GuildCreateFromTemplateMono
where, upon successful completion, emits thecreated guild
. If an error is received, it is emitted through theGuildCreateFromTemplateMono
.
-
createGuild
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 thecreated guild
. If an error is received, it is emitted through theMono
.
-
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.useedit(GuildTemplateEditSpec)
oredit()
which offer an immutable approach to build specsRequests to edit this guild template.- Parameters:
spec
- AConsumer
that provides a "blank"LegacyGuildTemplateEditSpec
to be operated on.- Returns:
- A
Mono
where, 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 thewithXxx
methods of the returnedGuildTemplateEditMono
.- Returns:
- A
GuildTemplateEditMono
where, upon successful completion, emits the editedGuildTemplate
. If an error is received, it is emitted through theGuildTemplateEditMono
.
-
edit
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 editedGuildTemplate
. If an error is received, it is emitted through theMono
.
-
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
.
-
createGuild(GuildCreateFromTemplateSpec)
orcreateGuild(String)
which offer an immutable approach to build specs