Interface Webhook
-
- All Superinterfaces:
IFakeable
,ISnowflake
public interface Webhook extends ISnowflake, IFakeable
An object representing Webhooks in Discord- Since:
- 3.0
- See Also:
TextChannel.retrieveWebhooks()
,Guild.retrieveWebhooks()
,JDA.retrieveWebhookById(String)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description AuditableRestAction<Void>
delete()
Deletes this Webhook.AuditableRestAction<Void>
delete(String token)
Deletes this Webhook.TextChannel
getChannel()
TheTextChannel
instance this Webhook is attached to.User
getDefaultUser()
The default User for this Webhook.Guild
getGuild()
TheGuild
instance for this Webhook.JDA
getJDA()
The JDA instance of this Webhook.WebhookManager
getManager()
TheWebhookManager
for this Webhook.String
getName()
The name of this Webhook.Member
getOwner()
The owner of this Webhook.String
getToken()
The execute token for this Webhook.WebhookType
getType()
TheWebhookType
of this webhook.String
getUrl()
ThePOST
route for this Webhook.-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
-
-
-
Method Detail
-
getJDA
@Nonnull JDA getJDA()
The JDA instance of this Webhook.- Returns:
- The current JDA instance of this Webhook
-
getType
@Nonnull WebhookType getType()
- Returns:
- The
WebhookType
-
getChannel
@Nonnull TextChannel getChannel()
TheTextChannel
instance this Webhook is attached to.- Returns:
- The current TextChannel of this Webhook
-
getOwner
@Nullable Member getOwner()
The owner of this Webhook. This will be null for fake Webhooks, such as those retrieved from Audit Logs.- Returns:
- Possibly-null
Member
instance representing the owner of this Webhook.
-
getDefaultUser
@Nonnull User getDefaultUser()
The default User for this Webhook.The
User
returned is alwaysfake
.
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:
- Execute Webhook Docs
-
getName
@Nonnull String 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
@Nullable String getToken()
The execute token for this Webhook.
This can be used to modify/delete/execute this Webhook.Note: Fake Webhooks, such as those retrieved from Audit Logs, do not contain a token
- Returns:
- The execute token for this Webhook
-
getUrl
@Nonnull String getUrl()
ThePOST
route for this Webhook.
This contains thetoken
andid
of this Webhook. Fake 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.
-
delete
@Nonnull @CheckReturnValue AuditableRestAction<Void> 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 is fake, such as the Webhooks retrieved from Audit Logs and the currently logged in account does not havePermission.MANAGE_WEBHOOKS
in this channel.
-
delete
@Nonnull @CheckReturnValue AuditableRestAction<Void> delete(@Nonnull String token)
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
@Nonnull WebhookManager 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
-
-