Package net.dv8tion.jda.webhook
Class WebhookClient
- java.lang.Object
-
- net.dv8tion.jda.webhook.WebhookClient
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class WebhookClient extends java.lang.Object implements java.lang.AutoCloseable
WebhookClient representing an executableWebhook
This client allows to send messages to a Discord Webhook without reliance on a JDA instance/Webhook entity.Instances of this class can be retrieved using
WebhookClientBuilders
-
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.Logger
LOG
static java.lang.String
USER_AGENT
static java.lang.String
WEBHOOK_URL
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
java.lang.String
getId()
The snowflake id of the target Webhooklong
getIdLong()
The snowflake id of the target Webhookjava.lang.String
getUrl()
The URL of this WebhookClientRequestFuture<?>
send(byte[] data, java.lang.String fileName)
Sends the providedbyte[]
data to this webhook.RequestFuture<?>
send(java.io.File file)
Sends the providedFile
to this webhook.RequestFuture<?>
send(java.io.File file, java.lang.String fileName)
Sends the providedFile
to this webhook.RequestFuture<?>
send(java.io.InputStream data, java.lang.String fileName)
Sends the providedInputStream
data to this webhook.RequestFuture<?>
send(java.lang.String content)
Sends the provided text message to this webhook.RequestFuture<?>
send(java.util.Collection<MessageEmbed> embeds)
Sends the providedMessageEmbeds
to this webhook.RequestFuture<?>
send(Message message)
Sends the providedMessage
to this webhook.RequestFuture<?>
send(MessageEmbed[] embeds)
Sends the providedMessageEmbeds
to this webhook.RequestFuture<?>
send(MessageEmbed first, MessageEmbed... embeds)
Sends the providedMessageEmbeds
to this webhook.RequestFuture<?>
send(WebhookMessage message)
Sends the providedWebhookMessage
to this webhook.
-
-
-
Field Detail
-
WEBHOOK_URL
public static final java.lang.String WEBHOOK_URL
- See Also:
- Constant Field Values
-
USER_AGENT
public static final java.lang.String USER_AGENT
-
LOG
public static final org.slf4j.Logger LOG
-
-
Method Detail
-
getIdLong
public long getIdLong()
The snowflake id of the target Webhook- Returns:
- id of the target Webhook
-
getId
public java.lang.String getId()
The snowflake id of the target Webhook- Returns:
- id of the target Webhook
-
getUrl
public java.lang.String getUrl()
The URL of this WebhookClient- Returns:
- The URL of this client
-
send
public RequestFuture<?> send(WebhookMessage message)
Sends the providedWebhookMessage
to this webhook.Hint: Use
WebhookMessageBuilder
to create aWebhookMessage
instance!- Parameters:
message
- The message to send- Returns:
RequestFuture
representing the execution task, this will be completed once the message was sent.- Throws:
java.lang.IllegalArgumentException
- If the provided message is null
-
send
public RequestFuture<?> send(java.io.File file)
Sends the providedFile
to this webhook.
UseWebhookMessage.files(String, Object, Object...)
to send up to 10 files!- Parameters:
file
- The file to send- Returns:
RequestFuture
representing the execution task, this will be completed once the message was sent.- Throws:
java.lang.IllegalArgumentException
- If the provided file isnull
, does not exist or is not readablejava.util.concurrent.RejectedExecutionException
- If this client was closed
-
send
public RequestFuture<?> send(java.io.File file, java.lang.String fileName)
Sends the providedFile
to this webhook.
UseWebhookMessage.files(String, Object, Object...)
to send up to 10 files!- Parameters:
file
- The file to sendfileName
- The name that should be used for this file- Returns:
RequestFuture
representing the execution task, this will be completed once the message was sent.- Throws:
java.lang.IllegalArgumentException
- If the provided file isnull
, does not exist or is not readablejava.util.concurrent.RejectedExecutionException
- If this client was closed
-
send
public RequestFuture<?> send(byte[] data, java.lang.String fileName)
Sends the providedbyte[]
data to this webhook.
UseWebhookMessage.files(String, Object, Object...)
to send up to 10 files!- Parameters:
data
- The file data to sendfileName
- The name that should be used for this file- Returns:
RequestFuture
representing the execution task, this will be completed once the message was sent.- Throws:
java.lang.IllegalArgumentException
- If the provided data isnull
or exceeds the limit of 8MBjava.util.concurrent.RejectedExecutionException
- If this client was closed
-
send
public RequestFuture<?> send(java.io.InputStream data, java.lang.String fileName)
Sends the providedInputStream
data to this webhook.
UseWebhookMessage.files(String, Object, Object...)
to send up to 10 files!- Parameters:
data
- The file data to sendfileName
- The name that should be used for this file- Returns:
RequestFuture
representing the execution task, this will be completed once the message was sent.- Throws:
java.lang.IllegalArgumentException
- If the provided data isnull
java.util.concurrent.RejectedExecutionException
- If this client was closed
-
send
public RequestFuture<?> send(Message message)
Sends the providedMessage
to this webhook.Hint: Use
MessageBuilder
to create aMessage
instance!- Parameters:
message
- The message to send- Returns:
RequestFuture
representing the execution task, this will be completed once the message was sent.- Throws:
java.lang.IllegalArgumentException
- If the provided message is null
-
send
public RequestFuture<?> send(MessageEmbed[] embeds)
Sends the providedMessageEmbeds
to this webhook.You can send up to 10 embeds per message! If more are sent they will not be displayed.
Hint: Use
EmbedBuilder
to create aMessageEmbed
instance!- Parameters:
embeds
- The embeds to send- Returns:
RequestFuture
representing the execution task, this will be completed once the message was sent.- Throws:
java.lang.IllegalArgumentException
- If any of the provided embeds isnull
java.util.concurrent.RejectedExecutionException
- If this client was closed
-
send
public RequestFuture<?> send(MessageEmbed first, MessageEmbed... embeds)
Sends the providedMessageEmbeds
to this webhook.You can send up to 10 embeds per message! If more are sent they will not be displayed.
Hint: Use
EmbedBuilder
to create aMessageEmbed
instance!- Parameters:
first
- The first embedembeds
- The other embeds to send- Returns:
RequestFuture
representing the execution task, this will be completed once the message was sent.- Throws:
java.lang.IllegalArgumentException
- If any of the provided embeds isnull
java.util.concurrent.RejectedExecutionException
- If this client was closed
-
send
public RequestFuture<?> send(java.util.Collection<MessageEmbed> embeds)
Sends the providedMessageEmbeds
to this webhook.You can send up to 10 embeds per message! If more are sent they will not be displayed.
Hint: Use
EmbedBuilder
to create aMessageEmbed
instance!- Parameters:
embeds
- The embeds to send- Returns:
RequestFuture
representing the execution task, this will be completed once the message was sent.- Throws:
java.lang.IllegalArgumentException
- If any of the provided embeds isnull
java.util.concurrent.RejectedExecutionException
- If this client was closed
-
send
public RequestFuture<?> send(java.lang.String content)
Sends the provided text message to this webhook.- Parameters:
content
- The text message to send- Returns:
RequestFuture
representing the execution task, this will be completed once the message was sent.- Throws:
java.lang.IllegalArgumentException
- If any of the provided message isnull
, blank or exceeds 2000 characters in lengthjava.util.concurrent.RejectedExecutionException
- If this client was closed
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
-
-