public class WebhookMessage
extends java.lang.Object
WebhookClient
ReadonlyMessage can be sent
by first converting it to a WebhookMessage with from(club.minnced.discord.webhook.receive.ReadonlyMessage).| Modifier and Type | Field and Description |
|---|---|
protected AllowedMentions |
allowedMentions |
protected MessageAttachment[] |
attachments |
protected java.lang.String |
avatarUrl |
protected java.lang.String |
content |
protected java.util.List<WebhookEmbed> |
embeds |
protected int |
flags |
protected boolean |
isTTS |
static int |
MAX_EMBEDS
Maximum amount of embeds a single message can hold (10)
|
static int |
MAX_FILES
Maximum amount of files a single message can hold (10)
|
protected java.lang.String |
username |
| Modifier | Constructor and Description |
|---|---|
protected |
WebhookMessage(java.lang.String username,
java.lang.String avatarUrl,
java.lang.String content,
java.util.List<WebhookEmbed> embeds,
boolean isTTS,
MessageAttachment[] files,
AllowedMentions allowedMentions,
int flags) |
| Modifier and Type | Method and Description |
|---|---|
@NotNull WebhookMessage |
asEphemeral(boolean ephemeral)
Returns a new WebhookMessage instance with the ephemeral flag turned on/off (true/false).
|
static @NotNull WebhookMessage |
embeds(@NotNull java.util.Collection<WebhookEmbed> embeds)
Creates a WebhookMessage from
the provided embeds.
|
static @NotNull WebhookMessage |
embeds(@NotNull WebhookEmbed first,
WebhookEmbed... embeds)
Creates a WebhookMessage from
the provided embeds.
|
static @NotNull WebhookMessage |
files(@NotNull java.util.Map<java.lang.String,?> attachments)
Creates a WebhookMessage from the provided attachments.
|
static @NotNull WebhookMessage |
files(@NotNull java.lang.String name1,
@NotNull java.lang.Object data1,
java.lang.Object... attachments)
Creates a WebhookMessage from the provided attachments.
|
static @NotNull WebhookMessage |
from(@NotNull ReadonlyMessage message)
Converts a
ReadonlyMessage to a
WebhookMessage. |
@Nullable MessageAttachment[] |
getAttachments()
The attachments for this message
|
@Nullable java.lang.String |
getAvatarUrl()
The avatar url for this message
|
@NotNull okhttp3.RequestBody |
getBody()
Provides a
RequestBody of this message. |
@Nullable java.lang.String |
getContent()
The content for this message
|
@NotNull java.util.List<WebhookEmbed> |
getEmbeds()
The embeds for this message
|
int |
getFlags()
The message flags used for this message.
|
@Nullable java.lang.String |
getUsername()
The username for this message
|
boolean |
isFile()
Whether this message contains files
|
boolean |
isTTS()
Whether this message should use Text-to-Speech (TTS)
|
public static final int MAX_FILES
public static final int MAX_EMBEDS
protected final java.lang.String username
protected final java.lang.String avatarUrl
protected final java.lang.String content
protected final java.util.List<WebhookEmbed> embeds
protected final boolean isTTS
protected final MessageAttachment[] attachments
protected final AllowedMentions allowedMentions
protected final int flags
protected WebhookMessage(java.lang.String username,
java.lang.String avatarUrl,
java.lang.String content,
java.util.List<WebhookEmbed> embeds,
boolean isTTS,
MessageAttachment[] files,
AllowedMentions allowedMentions,
int flags)
@Nullable public @Nullable java.lang.String getUsername()
@Nullable public @Nullable java.lang.String getAvatarUrl()
@Nullable public @Nullable java.lang.String getContent()
@NotNull public @NotNull java.util.List<WebhookEmbed> getEmbeds()
@Nullable public @Nullable MessageAttachment[] getAttachments()
public boolean isTTS()
public int getFlags()
@NotNull public @NotNull WebhookMessage asEphemeral(boolean ephemeral)
ephemeral - Whether to make this message ephemeral@NotNull public static @NotNull WebhookMessage from(@NotNull @NotNull ReadonlyMessage message)
ReadonlyMessage to a
WebhookMessage.
message - The message to convertjava.lang.NullPointerException - If provided with null@NotNull public static @NotNull WebhookMessage embeds(@NotNull @NotNull WebhookEmbed first, @NotNull WebhookEmbed... embeds)
first - The first embedembeds - Optional additional embeds for the messagejava.lang.NullPointerException - If provided with nulljava.lang.IllegalArgumentException - If more than are provided@NotNull public static @NotNull WebhookMessage embeds(@NotNull @NotNull java.util.Collection<WebhookEmbed> embeds)
embeds - Embeds for the messagejava.lang.NullPointerException - If provided with nulljava.lang.IllegalArgumentException - If more than are provided@NotNull public static @NotNull WebhookMessage files(@NotNull @NotNull java.util.Map<java.lang.String,?> attachments)
attachments - The attachments to add, keys are the alternative names
for each attachmentjava.lang.NullPointerException - If provided with nulljava.lang.IllegalArgumentException - If no attachments are provided or more than 10@NotNull public static @NotNull WebhookMessage files(@NotNull @NotNull java.lang.String name1, @NotNull @NotNull java.lang.Object data1, @NotNull java.lang.Object... attachments)
The files are provided in pairs of Name->Data similar
to the first 2 arguments.
The allowed data types are byte[] | InputStream | File
name1 - The alternative name of the first attachmentdata1 - The first attachment, must be of type byte[] | InputStream | Fileattachments - Optional additional attachments to add, pairs of String->Datajava.lang.NullPointerException - If provided with nulljava.lang.IllegalArgumentException - If no attachments are provided or more than 10
or the additional arguments are not an even count or an invalid formatpublic boolean isFile()
@NotNull public @NotNull okhttp3.RequestBody getBody()
RequestBody of this message.