public class WebhookClient
extends java.lang.Object
implements java.lang.AutoCloseable
Webhook
Instances of this class can be retrieved using WebhookClientBuilders
Modifier and Type | Field and Description |
---|---|
static SimpleLog |
LOG |
static java.lang.String |
USER_AGENT |
static java.lang.String |
WEBHOOK_URL |
Modifier and Type | Method and Description |
---|---|
void |
close() |
java.lang.String |
getId()
The snowflake id of the target Webhook
|
long |
getIdLong()
The snowflake id of the target Webhook
|
java.lang.String |
getUrl()
The URL of this WebhookClient
|
RequestFuture<?> |
send(byte[] data,
java.lang.String fileName)
Sends the provided
byte[] data to this webhook. |
RequestFuture<?> |
send(java.util.Collection<MessageEmbed> embeds)
Sends the provided
MessageEmbeds
to this webhook. |
RequestFuture<?> |
send(java.io.File file)
Sends the provided
File to this webhook. |
RequestFuture<?> |
send(java.io.File file,
java.lang.String fileName)
Sends the provided
File to this webhook. |
RequestFuture<?> |
send(java.io.InputStream data,
java.lang.String fileName)
Sends the provided
InputStream data to this webhook. |
RequestFuture<?> |
send(Message message)
Sends the provided
Message
to this webhook. |
RequestFuture<?> |
send(MessageEmbed... embeds)
Sends the provided
MessageEmbeds
to this webhook. |
RequestFuture<?> |
send(java.lang.String content)
Sends the provided text message to this webhook.
|
RequestFuture<?> |
send(WebhookMessage message)
Sends the provided
WebhookMessage
to this webhook. |
public static final java.lang.String WEBHOOK_URL
public static final java.lang.String USER_AGENT
public static final SimpleLog LOG
public long getIdLong()
public java.lang.String getId()
public java.lang.String getUrl()
public RequestFuture<?> send(WebhookMessage message)
WebhookMessage
to this webhook.
Hint: Use WebhookMessageBuilder
to
create a WebhookMessage
instance!
message
- The message to sendRequestFuture
representing the execution task,
this will be completed once the message was sent.HttpException
- If the HTTP request failspublic RequestFuture<?> send(java.io.File file)
File
to this webhook.file
- The file to sendRequestFuture
representing the execution task,
this will be completed once the message was sent.java.lang.IllegalArgumentException
- If the provided file is null
, does not exist or is not readablejava.util.concurrent.RejectedExecutionException
- If this client was closedHttpException
- If the HTTP request failspublic RequestFuture<?> send(java.io.File file, java.lang.String fileName)
File
to this webhook.file
- The file to sendfileName
- The name that should be used for this fileRequestFuture
representing the execution task,
this will be completed once the message was sent.java.lang.IllegalArgumentException
- If the provided file is null
, does not exist or is not readablejava.util.concurrent.RejectedExecutionException
- If this client was closedHttpException
- If the HTTP request failspublic RequestFuture<?> send(byte[] data, java.lang.String fileName)
byte[]
data to this webhook.data
- The file data to sendfileName
- The name that should be used for this fileRequestFuture
representing the execution task,
this will be completed once the message was sent.java.lang.IllegalArgumentException
- If the provided data is null
or exceeds the limit of 8MBjava.util.concurrent.RejectedExecutionException
- If this client was closedHttpException
- If the HTTP request failspublic RequestFuture<?> send(java.io.InputStream data, java.lang.String fileName)
InputStream
data to this webhook.data
- The file data to sendfileName
- The name that should be used for this fileRequestFuture
representing the execution task,
this will be completed once the message was sent.java.lang.IllegalArgumentException
- If the provided data is null
java.util.concurrent.RejectedExecutionException
- If this client was closedHttpException
- If the HTTP request failspublic RequestFuture<?> send(Message message)
Message
to this webhook.
Hint: Use MessageBuilder
to
create a Message
instance!
message
- The message to sendRequestFuture
representing the execution task,
this will be completed once the message was sent.HttpException
- If the HTTP request failspublic RequestFuture<?> send(MessageEmbed... embeds)
MessageEmbeds
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 a MessageEmbed
instance!
embeds
- The embeds to sendRequestFuture
representing the execution task,
this will be completed once the message was sent.java.lang.IllegalArgumentException
- If any of the provided embeds is null
java.util.concurrent.RejectedExecutionException
- If this client was closedHttpException
- If the HTTP request failspublic RequestFuture<?> send(java.util.Collection<MessageEmbed> embeds)
MessageEmbeds
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 a MessageEmbed
instance!
embeds
- The embeds to sendRequestFuture
representing the execution task,
this will be completed once the message was sent.java.lang.IllegalArgumentException
- If any of the provided embeds is null
java.util.concurrent.RejectedExecutionException
- If this client was closedHttpException
- If the HTTP request failspublic RequestFuture<?> send(java.lang.String content)
content
- The text message to sendRequestFuture
representing the execution task,
this will be completed once the message was sent.java.lang.IllegalArgumentException
- If any of the provided message is null
, blank or exceeds 2000 characters in lengthjava.util.concurrent.RejectedExecutionException
- If this client was closedHttpException
- If the HTTP request failspublic void close()
close
in interface java.lang.AutoCloseable