Interface Webhook
-
- All Superinterfaces:
DiscordEntity,Updatable<Webhook>,WebhookAttachableListenerManager
- All Known Subinterfaces:
IncomingWebhook
public interface Webhook extends DiscordEntity, Updatable<Webhook>, WebhookAttachableListenerManager
This class represents a webhook. Webhook objects won't receive any updates!
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.Optional<IncomingWebhook>asIncomingWebhook()Gets the webhook as incoming webhook.default WebhookUpdatercreateUpdater()Gets the updater for this webhook.default java.util.concurrent.CompletableFuture<java.lang.Void>delete()Deletes the webhook.java.util.concurrent.CompletableFuture<java.lang.Void>delete(java.lang.String reason)Deletes the webhook.java.util.Optional<Icon>getAvatar()Gets the default avatar of the webhook.java.util.Optional<TextChannel>getChannel()Gets the channel of the webhook.longgetChannelId()Gets the channel id of the webhook.java.util.Optional<User>getCreator()Gets the creator of the webhook.default java.util.concurrent.CompletableFuture<Webhook>getLatestInstance()Gets an updated instance of this entity from the cache or from Discord directly.java.util.Optional<java.lang.String>getName()Gets the default name of the webhook.java.util.Optional<Server>getServer()Gets the server of the webhook.java.util.Optional<java.lang.Long>getServerId()Gets the server id of the webhook.WebhookTypegetType()Gets the type of the webhook.default booleanisChannelFollowerWebhook()Checks if the webhook is a channel follower webhook.default booleanisIncomingWebhook()Checks if the webhook is an incoming webhook.default java.util.concurrent.CompletableFuture<Webhook>removeAvatar()Removes the avatar of the webhook.default java.util.concurrent.CompletableFuture<Webhook>updateAvatar(byte[] avatar)Updates the avatar of the webhook.default java.util.concurrent.CompletableFuture<Webhook>updateAvatar(byte[] avatar, java.lang.String fileType)Updates the avatar of the webhook.default java.util.concurrent.CompletableFuture<Webhook>updateAvatar(java.awt.image.BufferedImage avatar)Updates the avatar of the webhook.default java.util.concurrent.CompletableFuture<Webhook>updateAvatar(java.awt.image.BufferedImage avatar, java.lang.String fileType)Updates the avatar of the webhook.default java.util.concurrent.CompletableFuture<Webhook>updateAvatar(java.io.File avatar)Updates the avatar of the webhook.default java.util.concurrent.CompletableFuture<Webhook>updateAvatar(java.io.InputStream avatar)Updates the avatar of the webhook.default java.util.concurrent.CompletableFuture<Webhook>updateAvatar(java.io.InputStream avatar, java.lang.String fileType)Updates the avatar of the webhook.default java.util.concurrent.CompletableFuture<Webhook>updateAvatar(java.net.URL avatar)Updates the avatar of the webhook.default java.util.concurrent.CompletableFuture<Webhook>updateAvatar(Icon avatar)Updates the avatar of the webhook.default java.util.concurrent.CompletableFuture<Webhook>updateChannel(ServerTextChannel channel)Updates the channel of the webhook.default java.util.concurrent.CompletableFuture<Webhook>updateName(java.lang.String name)Updates the name of the webhook.-
Methods inherited from interface org.javacord.api.entity.DiscordEntity
getApi, getCreationTimestamp, getId, getIdAsString
-
Methods inherited from interface org.javacord.api.listener.webhook.WebhookAttachableListenerManager
addMessageCreateListener, addWebhookAttachableListener, getMessageCreateListeners, getWebhookAttachableListeners, removeListener, removeWebhookAttachableListener
-
-
-
-
Method Detail
-
getServerId
java.util.Optional<java.lang.Long> getServerId()
Gets the server id of the webhook.- Returns:
- The server id of the webhook.
-
getServer
java.util.Optional<Server> getServer()
Gets the server of the webhook.- Returns:
- The server of the webhook.
-
getChannelId
long getChannelId()
Gets the channel id of the webhook.- Returns:
- The channel id of the webhook.
-
getChannel
java.util.Optional<TextChannel> getChannel()
Gets the channel of the webhook.- Returns:
- The channel of the webhook.
-
getCreator
java.util.Optional<User> getCreator()
Gets the creator of the webhook.- Returns:
- The creator of the webhook.
-
getName
java.util.Optional<java.lang.String> getName()
Gets the default name of the webhook.- Returns:
- The default name of the webhook.
-
getAvatar
java.util.Optional<Icon> getAvatar()
Gets the default avatar of the webhook.- Returns:
- The default avatar of the webhook.
-
getType
WebhookType getType()
Gets the type of the webhook.- Returns:
- The type of the webhook.
-
isIncomingWebhook
default boolean isIncomingWebhook()
Checks if the webhook is an incoming webhook.- Returns:
- Whether the webhook an incoming webhook.
-
isChannelFollowerWebhook
default boolean isChannelFollowerWebhook()
Checks if the webhook is a channel follower webhook.- Returns:
- Whether the webhook a channel following webhook.
-
asIncomingWebhook
java.util.Optional<IncomingWebhook> asIncomingWebhook()
Gets the webhook as incoming webhook.- Returns:
- The webhook as incoming webhook.
-
delete
default java.util.concurrent.CompletableFuture<java.lang.Void> delete()
Deletes the webhook.- Returns:
- A future to tell us if the deletion was successful.
-
delete
java.util.concurrent.CompletableFuture<java.lang.Void> delete(java.lang.String reason)
Deletes the webhook.- Parameters:
reason- The audit log reason for the deletion.- Returns:
- A future to tell us if the deletion was successful.
-
createUpdater
default WebhookUpdater createUpdater()
Gets the updater for this webhook.- Returns:
- The updater for this webhook.
-
updateName
default java.util.concurrent.CompletableFuture<Webhook> updateName(java.lang.String name)
Updates the name of the webhook.If you want to update several settings at once, it's recommended to use the
WebhookUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
name- The new name of the webhook.- Returns:
- The updated webhook.
-
updateChannel
default java.util.concurrent.CompletableFuture<Webhook> updateChannel(ServerTextChannel channel)
Updates the channel of the webhook.If you want to update several settings at once, it's recommended to use the
WebhookUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
channel- The new channel of the webhook.- Returns:
- The updated webhook.
-
updateAvatar
default java.util.concurrent.CompletableFuture<Webhook> updateAvatar(java.awt.image.BufferedImage avatar)
Updates the avatar of the webhook. This method assumes the file type is "png"!If you want to update several settings at once, it's recommended to use the
WebhookUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
avatar- The new avatar.- Returns:
- The updated webhook.
-
updateAvatar
default java.util.concurrent.CompletableFuture<Webhook> updateAvatar(java.awt.image.BufferedImage avatar, java.lang.String fileType)
Updates the avatar of the webhook.If you want to update several settings at once, it's recommended to use the
WebhookUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
avatar- The new avatar.fileType- The type of the avatar, e.g. "png" or "jpg".- Returns:
- The updated webhook.
-
updateAvatar
default java.util.concurrent.CompletableFuture<Webhook> updateAvatar(java.io.File avatar)
Updates the avatar of the webhook.If you want to update several settings at once, it's recommended to use the
WebhookUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
avatar- The new avatar.- Returns:
- The updated webhook.
-
updateAvatar
default java.util.concurrent.CompletableFuture<Webhook> updateAvatar(Icon avatar)
Updates the avatar of the webhook.If you want to update several settings at once, it's recommended to use the
WebhookUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
avatar- The new avatar.- Returns:
- The updated webhook.
-
updateAvatar
default java.util.concurrent.CompletableFuture<Webhook> updateAvatar(java.net.URL avatar)
Updates the avatar of the webhook.If you want to update several settings at once, it's recommended to use the
WebhookUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
avatar- The new avatar.- Returns:
- The updated webhook.
-
updateAvatar
default java.util.concurrent.CompletableFuture<Webhook> updateAvatar(byte[] avatar)
Updates the avatar of the webhook. This method assumes the file type is "png"!If you want to update several settings at once, it's recommended to use the
WebhookUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
avatar- The new avatar.- Returns:
- The updated webhook.
-
updateAvatar
default java.util.concurrent.CompletableFuture<Webhook> updateAvatar(byte[] avatar, java.lang.String fileType)
Updates the avatar of the webhook.If you want to update several settings at once, it's recommended to use the
WebhookUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
avatar- The new avatar.fileType- The type of the avatar, e.g. "png" or "jpg".- Returns:
- The updated webhook.
-
updateAvatar
default java.util.concurrent.CompletableFuture<Webhook> updateAvatar(java.io.InputStream avatar)
Updates the avatar of the webhook. This method assumes the file type is "png"!If you want to update several settings at once, it's recommended to use the
WebhookUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
avatar- The new avatar.- Returns:
- The updated webhook.
-
updateAvatar
default java.util.concurrent.CompletableFuture<Webhook> updateAvatar(java.io.InputStream avatar, java.lang.String fileType)
Updates the avatar of the webhook.If you want to update several settings at once, it's recommended to use the
WebhookUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
avatar- The new avatar.fileType- The type of the avatar, e.g. "png" or "jpg".- Returns:
- The updated webhook.
-
removeAvatar
default java.util.concurrent.CompletableFuture<Webhook> removeAvatar()
Removes the avatar of the webhook.If you want to update several settings at once, it's recommended to use the
WebhookUpdaterfromcreateUpdater()which provides a better performance!- Returns:
- The updated webhook.
-
getLatestInstance
default java.util.concurrent.CompletableFuture<Webhook> getLatestInstance()
Description copied from interface:UpdatableGets an updated instance of this entity from the cache or from Discord directly. This is for example necessary if an instance got invalid by a reconnect to Discord which invalidates all existing instances which means they do not get any further updates from Discord applied. Due to that, references to instances should usually not be held for an extended period of time. If they are, this method can be used to retrieve the current instance from the cache if present or from Discord directly.This method returns the currently cached entity if present, or request the entity from Discord if it is not cached or not permanently cached. If the entity is a fully cached entity and is not in the cache any longer, for example because it was deleted or the message was thrown out of the cache, the
CompletableFuturecompletes exceptionally with aNoSuchElementException. If a request to Discord is made, the according remote call exception will be used to complete theCompletableFutureexceptionally.- Specified by:
getLatestInstancein interfaceUpdatable<Webhook>- Returns:
- The current cached instance.
-
-