Interface Webhook
- All Superinterfaces:
ISnowflake
,WebhookClient<Message>
- Since:
- 3.0
- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Partial Channel which references the source channel for a follower webhook.static class
Partial Guild which references the source guild for a follower webhook.static class
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondelete()
Deletes this Webhook.Deletes this Webhook.Thechannel
instance this Webhook is attached to.The default User for this Webhook.getGuild()
TheGuild
instance for this Webhook.getJDA()
The JDA instance of this Webhook.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
.getToken()
The execute token for this Webhook.getType()
TheWebhookType
of this webhook.getUrl()
ThePOST
route for this Webhook.boolean
Whether this webhook cannot providegetChannel()
andgetGuild()
.Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
Methods inherited from interface net.dv8tion.jda.api.entities.WebhookClient
deleteMessageById, deleteMessageById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageById, editMessageById, editMessageById, editMessageById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageEmbedsById, editMessageEmbedsById, editMessageEmbedsById, editMessageEmbedsById, editMessageFormatById, editMessageFormatById, retrieveMessageById, sendFiles, sendFiles, sendMessage, sendMessage, sendMessageComponents, sendMessageComponents, sendMessageEmbeds, sendMessageEmbeds, sendMessageFormat, sendMessagePoll
-
Field Details
-
WEBHOOK_URL
Pattern for a Webhook URL.Groups
Index Name Description 0 N/A The entire link 1 id The ID of the webhook 2 token The token of the webhook Matcher.group(String)
and the index withMatcher.group(int)
.
-
-
Method Details
-
getJDA
The JDA instance of this Webhook.- Specified by:
getJDA
in interfaceWebhookClient<Message>
- Returns:
- The current JDA instance of this Webhook
-
getType
- Returns:
- The
WebhookType
-
isPartial
boolean isPartial()Whether this webhook cannot providegetChannel()
andgetGuild()
.
This means that the webhook is not local to this shard's cache and cannot provide full channel/guild references.- Returns:
- True, if
getChannel()
andgetGuild()
would throw
-
getGuild
- Returns:
- The current Guild of this Webhook
- Throws:
IllegalStateException
- If this webhooksis partial
-
getChannel
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.- Returns:
- The current
channel
that this webhook is attached to. - Throws:
IllegalStateException
- If this webhooksis partial
-
getOwner
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 usegetOwnerAsUser()
to get a reference to the user instead.- Returns:
- Possibly-null
Member
instance representing the owner of this Webhook.
-
getOwnerAsUser
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 whengetOwner()
is null.getOwner()
requires the webhook to be local to this shard and in cache.- Returns:
- Possibly-null
User
instance representing the owner of this Webhook.
-
getDefaultUser
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 ingetUrl()
), 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.- Returns:
- A fake
User
instance representing the default webhook user. - See Also:
-
getName
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
.getDefaultUser()
.getName()- Returns:
- The name of this Webhook
-
getToken
The execute token for this Webhook.
This can be used to modify/delete/execute this Webhook.Note: Some Webhooks, such as those retrieved from Audit Logs, do not contain a token
- Specified by:
getToken
in interfaceWebhookClient<Message>
- Returns:
- The execute token for this Webhook
-
getUrl
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)
- Returns:
- The execution route for this Webhook.
-
getSourceChannel
The source channel for a Webhook of typeFOLLOWER
.- Returns:
Webhook.ChannelReference
-
getSourceGuild
The source guild for a Webhook of typeFOLLOWER
.- Returns:
Webhook.GuildReference
-
delete
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.
- Returns:
AuditableRestAction
The rest action to delete this Webhook.- Throws:
InsufficientPermissionException
- If the Webhook does not have a token, such as the Webhooks retrieved from Audit Logs and the currently logged in account does not havePermission.MANAGE_WEBHOOKS
in this channel.
-
delete
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.
- Parameters:
token
- The webhook token (this is not the bot authorization token!)- Returns:
AuditableRestAction
The rest action to delete this Webhook.- Throws:
IllegalArgumentException
- If the provided token is null- Since:
- 4.0.0
-
getManager
TheWebhookManager
for this Webhook.
You can modify multiple fields in one request by chaining setters before callingRestAction.queue()
.- Returns:
- The
WebhookManager
for this Webhook - Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_WEBHOOKS
-