java.lang.AutoCloseable
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 | Description |
---|---|---|
static org.slf4j.Logger |
LOG |
|
static java.lang.String |
USER_AGENT |
|
static java.lang.String |
WEBHOOK_URL |
Modifier and Type | Method | 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.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(java.lang.String content) |
Sends the provided text message to this webhook.
|
RequestFuture<?> |
send(java.util.Collection<MessageEmbed> embeds) |
Sends the provided
MessageEmbeds
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(MessageEmbed first,
MessageEmbed... embeds) |
Sends the provided
MessageEmbeds
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 org.slf4j.Logger 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.java.lang.IllegalArgumentException
- If the provided message is nullpublic RequestFuture<?> send(java.io.File file)
File
to this webhook.
WebhookMessage.files(String, Object, Object...)
to send up to 10 files!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 closedpublic RequestFuture<?> send(java.io.File file, java.lang.String fileName)
File
to this webhook.
WebhookMessage.files(String, Object, Object...)
to send up to 10 files!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 closedpublic RequestFuture<?> send(byte[] data, java.lang.String fileName)
byte[]
data to this webhook.
WebhookMessage.files(String, Object, Object...)
to send up to 10 files!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 closedpublic RequestFuture<?> send(java.io.InputStream data, java.lang.String fileName)
InputStream
data to this webhook.
WebhookMessage.files(String, Object, Object...)
to send up to 10 files!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 closedpublic 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.java.lang.IllegalArgumentException
- If the provided message is nullpublic 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 closedpublic RequestFuture<?> send(MessageEmbed first, 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!
first
- The first embedembeds
- The other 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 closedpublic 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 closedpublic 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 closedpublic void close()
close
in interface java.lang.AutoCloseable