public class WebhookMessage
extends java.lang.Object
WebhookClient
.
username
and avatar_url
which override
the default username and avatar of a Webhook message.
This message can send multiple embeds at once!
Modifier and Type | Method | Description |
---|---|---|
static WebhookMessage |
embeds(java.util.Collection<MessageEmbed> embeds) |
Creates a new WebhookMessage instance with the provided
MessageEmbeds |
static WebhookMessage |
embeds(MessageEmbed first,
MessageEmbed... embeds) |
Creates a new WebhookMessage instance with the provided
MessageEmbeds |
static WebhookMessage |
files(java.lang.String name1,
java.lang.Object data1,
java.lang.Object... attachments) |
Constructs a message around pairs of (Name, Data).
|
static WebhookMessage |
files(java.util.Map<java.lang.String,?> attachments) |
Constructs a message around pairs of (Name, Data).
|
static WebhookMessage |
from(Message message) |
Creates a new WebhookMessage instance with the provided
Message
as layout for copying. |
boolean |
isFile() |
Whether this message contains an attachment
|
public static WebhookMessage embeds(MessageEmbed first, MessageEmbed... embeds)
MessageEmbeds
first
- The first embed to use for this messageembeds
- The other embeds to use for this messagejava.lang.IllegalArgumentException
- If any of the provided embeds is null
or exceeds the maximum total character count of MessageEmbed.EMBED_MAX_LENGTH_BOT
public static WebhookMessage embeds(java.util.Collection<MessageEmbed> embeds)
MessageEmbeds
embeds
- The embeds to use for this messagejava.lang.IllegalArgumentException
- If any of the provided embeds is null
or exceeds the maximum total character count of MessageEmbed.EMBED_MAX_LENGTH_BOT
public static WebhookMessage files(java.util.Map<java.lang.String,?> attachments)
InputStream
, File
, and byte[]
.
Map<String, Object> map = new HashMap<>();
map.put("dog", new File("dog.png"));
map.put("cat", new URL("https://random.cat/meow").openStream());
map.put("bird", new byte[100]);
WebhookMessage message = WebhookMessage.files(map);
attachments
- Map containing pairs from file names to data streamsjava.lang.IllegalArgumentException
- If one of the provided files is not readable
or the provided map is null/emptyWebhookMessageBuilder.addFile(String, InputStream)
,
WebhookMessageBuilder.addFile(String, byte[])
,
WebhookMessageBuilder.addFile(String, File)
,
WebhookMessageBuilder.addFile(File)
public static WebhookMessage files(java.lang.String name1, java.lang.Object data1, java.lang.Object... attachments)
InputStream
, File
, and byte[]
.
WebhookMessage message = WebhookMessage.files(
"dog", new File("dog.png"),
"cat", new URL("https://random.cat/meow").openStream(),
"bird", new byte[100]
);
name1
- The first name argumentdata1
- The first data argumentattachments
- Additional pairs in the form of (Name, Data)java.lang.IllegalArgumentException
- If the provided arguments are not pairs of (Name, Data)
or if one of the provided files is not readableWebhookMessageBuilder.addFile(String, InputStream)
,
WebhookMessageBuilder.addFile(String, byte[])
,
WebhookMessageBuilder.addFile(String, File)
,
WebhookMessageBuilder.addFile(File)
public static WebhookMessage from(Message message)
Message
as layout for copying.
message
- The message to copyjava.lang.IllegalArgumentException
- If the provided message is null
public boolean isFile()