Package discord4j.core.object.entity
Class Webhook
java.lang.Object
discord4j.core.object.entity.Webhook
- All Implemented Interfaces:
DiscordObject
,Entity
A Discord webhook.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Represents the various types of webhooks. -
Constructor Summary
ConstructorDescriptionWebhook
(GatewayDiscordClient gateway, discord4j.discordjson.json.WebhookData data) Constructs aWebhook
with an associatedGatewayDiscordClient
and Discord data. -
Method Summary
Modifier and TypeMethodDescriptiondelete()
Requests to delete this webhook.Requests to delete this webhook while optionally specifying a reason.deleteMessage
(Snowflake messageId) Executes this webhook to delete a message.Requests to delete this webhook.discord4j.core.spec.WebhookEditMono
edit()
Requests to edit this webhook.edit
(discord4j.core.spec.WebhookEditSpec spec) Requests to edit this webhook.edit
(Consumer<? super LegacyWebhookEditSpec> spec) Deprecated.discord4j.core.spec.WebhookMessageEditMono
editMessage
(Snowflake messageId) Executes this webhook to edit a message.editMessage
(Snowflake messageId, discord4j.core.spec.WebhookMessageEditSpec spec) Executes this webhook to edit a message.discord4j.core.spec.WebhookEditWithTokenMono
Requests to edit this webhook.editWithToken
(discord4j.core.spec.WebhookEditWithTokenSpec spec) Requests to edit this webhook.editWithToken
(Consumer<? super LegacyWebhookEditWithTokenSpec> spec) Deprecated.useeditWithToken(WebhookEditWithTokenSpec)
oreditWithToken()
which offer an immutable approach to build specsboolean
discord4j.core.spec.WebhookExecuteMono
execute()
Executes this webhook.execute
(boolean wait, discord4j.core.spec.WebhookExecuteSpec spec) Executes this webhook.execute
(boolean wait, Consumer<? super LegacyWebhookExecuteSpec> spec) Deprecated.useexecute(boolean, WebhookExecuteSpec)
which offers an immutable approach to build specsexecute
(discord4j.core.spec.WebhookExecuteSpec spec) Executes this webhook without waiting for a confirmation that a message was created.execute
(Consumer<? super LegacyWebhookExecuteSpec> spec) Deprecated.useexecute(WebhookExecuteSpec)
orexecute()
which offer an immutable approach to build specsexecuteAndWait
(discord4j.core.spec.WebhookExecuteSpec spec) Executes this webhook and waits for server confirmation for the message to save.executeAndWait
(Consumer<? super LegacyWebhookExecuteSpec> spec) Deprecated.useexecuteAndWait(WebhookExecuteSpec)
which offers an immutable approach to build specsGets the bot/OAuth2 application ID that created this webhook.Gets the avatar of this webhook, if present.Requests to retrieve the channel this webhook is associated to.getChannel
(EntityRetrievalStrategy retrievalStrategy) Requests to retrieve the channel this webhook is associated to, using the given retrieval strategy.Gets the ID of the channel this webhook is associated to.Returns theGatewayDiscordClient
that created this object.Requests to retrieve the user this webhook was created by, if present.discord4j.discordjson.json.WebhookData
getData()
Gets the data of the webhook.getGuild()
Requests to retrieve the guild this webhook is associated to.getGuild
(EntityRetrievalStrategy retrievalStrategy) Requests to retrieve the guild this webhook is associated to, using the given retrieval strategy.Gets the ID of the guild this webhook is associated to.getId()
Gets the Snowflake that uniquely identifies this entity.getMessage
(Snowflake messageId) Executes this webhook to get a message.getName()
Gets the default name of the webhook.Gets the id of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.Gets the name of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.Gets the guild id of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.Gets the guild name of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.getToken()
Gets the secure token of this webhook.getType()
Gets the type of the webhook.int
hashCode()
toString()
-
Constructor Details
-
Webhook
Constructs aWebhook
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.
-
getId
Description copied from interface:Entity
Gets the Snowflake that uniquely identifies this entity. -
getData
public discord4j.discordjson.json.WebhookData getData()Gets the data of the webhook.- Returns:
- The data of the webhook.
-
getType
Gets the type of the webhook.- Returns:
- The type of the webhook.
-
getGuildId
Gets the ID of the guild this webhook is associated to.- Returns:
- The ID of the guild this webhook is associated to.
-
getGuild
Requests to retrieve the guild this webhook is associated to. -
getGuild
Requests to retrieve the guild this webhook is associated to, using the given retrieval strategy. -
getChannelId
Gets the ID of the channel this webhook is associated to.- Returns:
- The ID of the channel this webhook is associated to.
-
getChannel
Requests to retrieve the channel this webhook is associated to. -
getChannel
Requests to retrieve the channel this webhook is associated to, using the given retrieval strategy. -
getCreator
Requests to retrieve the user this webhook was created by, if present. Returns no creator if the webhook was retrieved using a token. -
getName
Gets the default name of the webhook.- Returns:
- The default name of the webhook.
-
getAvatar
Gets the avatar of this webhook, if present.- Returns:
- The avatar of this webhook, if present.
-
getToken
Gets the secure token of this webhook. The token is present forWebhook.Type.INCOMING
webhooks.- Returns:
- The secure token of this webhook.
-
getApplicationId
Gets the bot/OAuth2 application ID that created this webhook.- Returns:
- The bot/OAuth2 application ID that created this webhook.
-
getSourceGuildId
Gets the guild id of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.- Returns:
- The guild id of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.
-
getSourceGuildName
Gets the guild name of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.- Returns:
- The guild name of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.
-
getSourceChannelId
Gets the id of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.- Returns:
- The id of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.
-
getSourceChannelName
Gets the name of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.- Returns:
- The name of the channel that this webhook is following (returned for Channel Follower Webhooks), if present.
-
delete
Requests to delete this webhook. Requires the MANAGE_WEBHOOKS permission.- Returns:
- A
Mono
where, upon successful completion, emits nothing; indicating the webhook has been deleted. If an error is received, it is emitted through theMono
.
-
delete
Requests to delete this webhook while optionally specifying a reason. Requires the MANAGE_WEBHOOKS permission.- Parameters:
reason
- The reason, if present.- Returns:
- A
Mono
where, upon successful completion, emits nothing; indicating the webhook has been deleted. If an error is received, it is emitted through theMono
.
-
deleteWithToken
Requests to delete this webhook.- Returns:
- A
Mono
where, upon successful completion, emits nothing; indicating the webhook has been deleted. If an error is received, it is emitted through theMono
.
-
edit
Deprecated.useedit(WebhookEditSpec)
oredit()
which offer an immutable approach to build specsRequests to edit this webhook. Requires the MANAGE_WEBHOOKS permission.- Parameters:
spec
- AConsumer
that provides a "blank"LegacyWebhookEditSpec
to be operated on.- Returns:
- A
Mono
where, upon successful completion, emits the editedWebhook
. If an error is received, it is emitted through theMono
.
-
edit
public discord4j.core.spec.WebhookEditMono edit()Requests to edit this webhook. Properties specifying how to edit this webhook can be set via thewithXxx
methods of the returnedWebhookEditMono
. Requires the MANAGE_WEBHOOKS permission.- Returns:
- A
WebhookEditMono
where, upon successful completion, emits the editedWebhook
. If an error is received, it is emitted through theWebhookEditMono
.
-
edit
Requests to edit this webhook. Requires the MANAGE_WEBHOOKS permission. -
editWithToken
@Deprecated public Mono<Webhook> editWithToken(Consumer<? super LegacyWebhookEditWithTokenSpec> spec) Deprecated.useeditWithToken(WebhookEditWithTokenSpec)
oreditWithToken()
which offer an immutable approach to build specsRequests to edit this webhook. Does not require the MANAGE_WEBHOOKS permission.- Parameters:
spec
- AConsumer
that provides a "blank"LegacyWebhookEditWithTokenSpec
to be operated on.- Returns:
- A
Mono
where, upon successful completion, emits the editedWebhook
. If an error is received, it is emitted through theMono
.
-
editWithToken
public discord4j.core.spec.WebhookEditWithTokenMono editWithToken()Requests to edit this webhook. Properties specifying how to edit this webhook can be set via thewithXxx
methods of the returnedWebhookEditWithTokenMono
. Does not require the MANAGE_WEBHOOKS permission.- Returns:
- A
WebhookEditWithTokenMono
where, upon successful completion, emits the editedWebhook
. If an error is received, it is emitted through theWebhookEditWithTokenMono
.
-
editWithToken
Requests to edit this webhook. Does not require the MANAGE_WEBHOOKS permission. -
execute
Deprecated.useexecute(WebhookExecuteSpec)
orexecute()
which offer an immutable approach to build specsExecutes this webhook without waiting for a confirmation that a message was created.- Parameters:
spec
- AConsumer
that provides a "blank"LegacyWebhookExecuteSpec
to be operated on.- Returns:
- A
Mono
where, upon successful webhook execution, completes. If the message fails to save, an error IS NOT emitted through theMono
.
-
execute
public discord4j.core.spec.WebhookExecuteMono execute()Executes this webhook. Properties specifying how to execute this webhook, including whether to wait for confirmation that the message was created, can be set via thewithXxx
methods of the returnedWebhookExecuteMono
.- Returns:
- A
WebhookExecuteMono
where, upon successful webhook execution, emits a Message ifwithWaitForMessage(true)
. If the message fails to save, an error is emitted through theWebhookExecuteMono
only ifwithWaitForMessage(true)
.
-
execute
Executes this webhook without waiting for a confirmation that a message was created.- Parameters:
spec
- an immutable object that specifies how to execute this webhook- Returns:
- A
Mono
where, upon successful webhook execution, completes. If the message fails to save, an error IS NOT emitted through theMono
.
-
execute
@Deprecated public Mono<Message> execute(boolean wait, Consumer<? super LegacyWebhookExecuteSpec> spec) Deprecated.useexecute(boolean, WebhookExecuteSpec)
which offers an immutable approach to build specsExecutes this webhook.- Parameters:
wait
- True to specify to wait for server confirmation that the message was saved or there was an error saving the message.spec
- AConsumer
that provides a "blank"LegacyWebhookExecuteSpec
to be operated on.- Returns:
- A
Mono
where, upon successful webhook execution, emits a Message ifwait = true
. If the message fails to save, an error is emitted through theMono
only ifwait = true
.
-
execute
Executes this webhook.- Parameters:
wait
- True to specify to wait for server confirmation that the message was saved or there was an error saving the message.spec
- an immutable object that specifies how to execute this webhook- Returns:
- A
Mono
where, upon successful webhook execution, emits a Message ifwait = true
. If the message fails to save, an error is emitted through theMono
only ifwait = true
.
-
executeAndWait
Deprecated.useexecuteAndWait(WebhookExecuteSpec)
which offers an immutable approach to build specsExecutes this webhook and waits for server confirmation for the message to save.- Parameters:
spec
- AConsumer
that provides a "blank"LegacyWebhookExecuteSpec
to be operated on.- Returns:
- A
Mono
where, upon successful webhook execution, emits a Message. If the message fails to save, an error is emitted through theMono
.
-
executeAndWait
Executes this webhook and waits for server confirmation for the message to save.- Parameters:
spec
- an immutable object that specifies how to execute this webhook- Returns:
- A
Mono
where, upon successful webhook execution, emits a Message. If the message fails to save, an error is emitted through theMono
.
-
getMessage
Executes this webhook to get a message.- Parameters:
messageId
- The ID of the message to get- Returns:
- A
Mono
where, upon successful webhook execution, emits a Message. If the message get fails, an error is emitted through theMono
.
-
editMessage
Executes this webhook to edit a message. Properties specifying how to execute this webhook, including the ID of the message being edited, can be set via thewithXxx
methods of the returnedWebhookMessageEditMono
.- Parameters:
messageId
- The ID of the message to edit- Returns:
- A
WebhookMessageEditMono
where, upon successful webhook execution, emits a Message. If the message edit fails, an error is emitted through theWebhookMessageEditMono
.
-
editMessage
public Mono<Message> editMessage(Snowflake messageId, discord4j.core.spec.WebhookMessageEditSpec spec) Executes this webhook to edit a message.- Parameters:
messageId
- The ID of the message to editspec
- an immutable object that specifies how to edit the message- Returns:
- A
Mono
where, upon successful webhook execution, emits a Message. If the message edit fails, an error is emitted through theMono
.
-
deleteMessage
Executes this webhook to delete a message.- Parameters:
messageId
- The ID of the message to delete- Returns:
- A
Mono
where, upon successful webhook execution, emits nothing; indicating the message has been deleted. If the message delete fails, an error is emitted through theMono
.
-
equals
-
hashCode
public int hashCode() -
toString
-
edit(WebhookEditSpec)
oredit()
which offer an immutable approach to build specs