Class WebhookImpl
- All Implemented Interfaces:
ISnowflake
,Webhook
,WebhookClient<Message>
Webhook
- Since:
- 3.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.entities.Webhook
Webhook.ChannelReference, Webhook.GuildReference, Webhook.WebhookReference
-
Field Summary
Fields inherited from interface net.dv8tion.jda.api.entities.Webhook
WEBHOOK_URL
-
Constructor Summary
ConstructorsConstructorDescriptionWebhookImpl
(IWebhookContainer channel, long id, WebhookType type) WebhookImpl
(IWebhookContainer channel, JDA api, long id, WebhookType type) -
Method Summary
Modifier and TypeMethodDescriptiondelete()
Deletes this Webhook.Deletes this Webhook.deleteMessageById
(String messageId) Delete a message from this webhook.editRequest
(String messageId) boolean
Thechannel
instance this Webhook is attached to.The default User for this Webhook.getGuild()
TheGuild
instance for this Webhook.getJDA()
The associatedJDA
instance.TheWebhookManager
for this Webhook.getName()
The name of this Webhook.getOwner()
The owner of this Webhook.The owner of this Webhook.The source channel for a Webhook of typeFOLLOWER
.The source guild for a Webhook of typeFOLLOWER
.getType()
TheWebhookType
of this webhook.getUrl()
ThePOST
route for this Webhook.int
hashCode()
boolean
Whether this webhook cannot provideWebhook.getChannel()
andWebhook.getGuild()
.retrieveMessageById
(String messageId) Retrieves the message with the provided id.setSourceChannel
(Webhook.ChannelReference reference) setSourceGuild
(Webhook.GuildReference reference) toString()
Methods inherited from class net.dv8tion.jda.internal.entities.AbstractWebhookClient
editMessageAttachmentsById, editMessageById, editMessageById, editMessageComponentsById, editMessageEmbedsById, getIdLong, getToken, sendFiles, sendMessage, sendMessage, sendMessageComponents, sendMessageEmbeds, sendMessagePoll
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
Methods inherited from interface net.dv8tion.jda.api.entities.WebhookClient
deleteMessageById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageById, editMessageById, editMessageById, editMessageById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageEmbedsById, editMessageEmbedsById, editMessageEmbedsById, editMessageEmbedsById, editMessageFormatById, editMessageFormatById, sendFiles, sendFiles, sendMessage, sendMessage, sendMessageComponents, sendMessageComponents, sendMessageComponents, sendMessageEmbeds, sendMessageEmbeds, sendMessageFormat, sendMessagePoll
-
Constructor Details
-
WebhookImpl
-
WebhookImpl
-
-
Method Details
-
getType
Description copied from interface:Webhook
- Specified by:
getType
in interfaceWebhook
- Returns:
- The
WebhookType
-
isPartial
public boolean isPartial()Description copied from interface:Webhook
Whether this webhook cannot provideWebhook.getChannel()
andWebhook.getGuild()
.
This means that the webhook is not local to this shard's cache and cannot provide full channel/guild references.- Specified by:
isPartial
in interfaceWebhook
- Returns:
- True, if
Webhook.getChannel()
andWebhook.getGuild()
would throw
-
getJDA
Description copied from interface:WebhookClient
The associatedJDA
instance.- Specified by:
getJDA
in interfaceWebhook
- Specified by:
getJDA
in interfaceWebhookClient<Message>
- Overrides:
getJDA
in classAbstractWebhookClient<Message>
- Returns:
- The JDA instance
-
getGuild
Description copied from interface:Webhook
-
getChannel
Description copied from interface:Webhook
Thechannel
instance this Webhook is attached to. Webhooks are created on specific channels so that they can interact with that channel. With regard tothreads
, Webhooks are attached to theirparent channel
and then the Webhooks can post to theparent
and thethread
too.- Specified by:
getChannel
in interfaceWebhook
- Returns:
- The current
channel
that this webhook is attached to.
-
getOwner
Description copied from interface:Webhook
The owner of this Webhook. This will be null for some Webhooks, such as those retrieved from Audit Logs.
This requires the member to be cached. You can useWebhook.getOwnerAsUser()
to get a reference to the user instead. -
getOwnerAsUser
Description copied from interface:Webhook
The owner of this Webhook. This will be null for some Webhooks, such as those retrieved from Audit Logs.
This can be non-null even whenWebhook.getOwner()
is null.Webhook.getOwner()
requires the webhook to be local to this shard and in cache.- Specified by:
getOwnerAsUser
in interfaceWebhook
- Returns:
- Possibly-null
User
instance representing the owner of this Webhook.
-
getDefaultUser
Description copied from interface:Webhook
The default User for this Webhook.The
User
returned is always fake and cannot be interacted with.
This User is used for all messages posted to the Webhook route (found inWebhook.getUrl()
), it holds the default references for the message authors of messages by this Webhook.When
POST
ing to a Webhook route the name/avatar of this default user can be overridden.- Specified by:
getDefaultUser
in interfaceWebhook
- Returns:
- A fake
User
instance representing the default webhook user. - See Also:
-
getName
Description copied from interface:Webhook
The name of this Webhook.
This will be displayed by default as the author name of every message by this Webhook.This is a shortcut for
.Webhook.getDefaultUser()
.getName() -
getUrl
Description copied from interface:Webhook
ThePOST
route for this Webhook.
This contains thetoken
andid
of this Webhook. Some Webhooks without tokens (such as those retrieved from Audit Logs) will return a URL without a token.The route returned by this method does not need permission checks to be executed.
It is implied that Webhook messages always have all permissions includingmentioning everyone
.Webhook executions are limited with 5 requests per second. The response contains rate limit headers that should be handled by execution frameworks. (Learn More)
-
getSourceChannel
Description copied from interface:Webhook
The source channel for a Webhook of typeFOLLOWER
.- Specified by:
getSourceChannel
in interfaceWebhook
- Returns:
Webhook.ChannelReference
-
getSourceGuild
Description copied from interface:Webhook
The source guild for a Webhook of typeFOLLOWER
.- Specified by:
getSourceGuild
in interfaceWebhook
- Returns:
Webhook.GuildReference
-
delete
Description copied from interface:Webhook
Deletes this Webhook.The following
ErrorResponses
are possible:MISSING_ACCESS
The delete was attempted after the account lost permission to view the channel.MISSING_PERMISSIONS
The delete was attempted after the account lostPermission.MANAGE_WEBHOOKS
in the channel.UNKNOWN_WEBHOOK
The delete was attempted after the Webhook had already been deleted.
- Specified by:
delete
in interfaceWebhook
- Returns:
AuditableRestAction
The rest action to delete this Webhook.
-
delete
Description copied from interface:Webhook
Deletes this Webhook.The following
ErrorResponses
are possible:MISSING_ACCESS
The delete was attempted after the account lost permission to view the channel.MISSING_PERMISSIONS
The delete was attempted after the account lostPermission.MANAGE_WEBHOOKS
in the channel.UNKNOWN_WEBHOOK
The delete was attempted after the Webhook had already been deleted.INVALID_WEBHOOK_TOKEN
If the provided webhook token is not valid.
- Specified by:
delete
in interfaceWebhook
- Parameters:
token
- The webhook token (this is not the bot authorization token!)- Returns:
AuditableRestAction
The rest action to delete this Webhook.
-
getManager
Description copied from interface:Webhook
TheWebhookManager
for this Webhook.
You can modify multiple fields in one request by chaining setters before callingRestAction.queue()
.- Specified by:
getManager
in interfaceWebhook
- Returns:
- The
WebhookManager
for this Webhook
-
sendRequest
- Specified by:
sendRequest
in classAbstractWebhookClient<Message>
-
editRequest
- Specified by:
editRequest
in classAbstractWebhookClient<Message>
-
deleteMessageById
Description copied from interface:WebhookClient
Delete a message from this webhook.Use
setThreadId(threadId)
to delete messages from threads.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Specified by:
deleteMessageById
in interfaceWebhookClient<Message>
- Overrides:
deleteMessageById
in classAbstractWebhookClient<Message>
- Parameters:
messageId
- The id for the message to delete- Returns:
WebhookMessageDeleteAction
-
retrieveMessageById
Description copied from interface:WebhookClient
Retrieves the message with the provided id.
This only works for messages sent by this webhook. All other messages are unknown.Use
setThreadId(threadId)
to retrieve messages from threads.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
If the message is inaccessible to this webhook or does not exist.
- Specified by:
retrieveMessageById
in interfaceWebhookClient<Message>
- Returns:
WebhookMessageRetrieveAction
-
setOwner
-
setToken
-
setUser
-
setSourceGuild
-
setSourceChannel
-
hashCode
public int hashCode() -
equals
-
toString
-