Interface WebhookMessageAction<T>
-
- All Superinterfaces:
AllowedMentions<WebhookMessageAction<T>>
,RestAction<T>
public interface WebhookMessageAction<T> extends RestAction<T>, AllowedMentions<WebhookMessageAction<T>>
Extension of a defaultRestAction
that allows setting message information before sending!This is available as return type of all sendMessage/sendFile methods in
WebhookClient
.When this RestAction has been executed all provided files will be closed.
Note that the garbage collector also frees opened file streams when it finalizes the stream object.- Since:
- 4.3.0
- See Also:
WebhookClient.sendMessage(String)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default WebhookMessageAction<T>
addActionRow(java.util.Collection<? extends Component> components)
Add oneActionRow
for the message.default WebhookMessageAction<T>
addActionRow(Component... components)
Add oneActionRow
for the message.default WebhookMessageAction<T>
addActionRows(java.util.Collection<? extends ActionRow> rows)
AddActionRows
for the message.WebhookMessageAction<T>
addActionRows(ActionRow... rows)
AddActionRows
for the message.WebhookMessageAction<T>
addEmbeds(java.util.Collection<? extends MessageEmbed> embeds)
AddMessageEmbeds
to this messagedefault WebhookMessageAction<T>
addEmbeds(MessageEmbed embed, MessageEmbed... other)
AddMessageEmbeds
to this messagedefault WebhookMessageAction<T>
addFile(byte[] data, java.lang.String name, AttachmentOption... options)
Adds the provided byte[] as file data.default WebhookMessageAction<T>
addFile(java.io.File file, java.lang.String name, AttachmentOption... options)
Adds the providedFile
as file data.default WebhookMessageAction<T>
addFile(java.io.File file, AttachmentOption... options)
Adds the providedFile
as file data.WebhookMessageAction<T>
addFile(java.io.InputStream data, java.lang.String name, AttachmentOption... options)
Adds the providedInputStream
as file data.WebhookMessageAction<T>
applyMessage(Message message)
Applies the sendable information of the providedMessage
to this message action settings.WebhookMessageAction<T>
setContent(java.lang.String content)
Set the content for this message.WebhookMessageAction<T>
setEphemeral(boolean ephemeral)
Set whether this message should be visible to other users.WebhookMessageAction<T>
setTTS(boolean tts)
Enable/Disable Text-To-Speech for the resulting message.-
Methods inherited from interface net.dv8tion.jda.api.utils.AllowedMentions
allowedMentions, mention, mention, mentionRepliedUser, mentionRoles, mentionRoles, mentionUsers, mentionUsers
-
Methods inherited from interface net.dv8tion.jda.api.requests.RestAction
addCheck, and, and, complete, complete, completeAfter, deadline, delay, delay, delay, delay, flatMap, flatMap, getCheck, getJDA, map, mapToResult, onErrorFlatMap, onErrorFlatMap, onErrorMap, onErrorMap, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, setCheck, submit, submit, submitAfter, submitAfter, timeout, zip
-
-
-
-
Method Detail
-
setEphemeral
@Nonnull @CheckReturnValue WebhookMessageAction<T> setEphemeral(boolean ephemeral)
Set whether this message should be visible to other users.
When a message is ephemeral, it will only be visible to the user that used the interaction.Ephemeral messages have some limitations and will be removed once the user restarts their client.
Limitations:- Cannot be deleted by the bot
- Cannot contain any files/attachments
- Cannot be reacted to
- Cannot be retrieved
This only works on
InteractionHooks
!- Parameters:
ephemeral
- True, if this message should be invisible for other users- Returns:
- The same message action, for chaining convenience
-
setContent
@Nonnull @CheckReturnValue WebhookMessageAction<T> setContent(@Nullable java.lang.String content)
Set the content for this message.- Parameters:
content
- The new message content- Returns:
- The same message action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the provided content is longer thanMAX_CONTENT_LENGTH
characters
-
setTTS
@Nonnull @CheckReturnValue WebhookMessageAction<T> setTTS(boolean tts)
Enable/Disable Text-To-Speech for the resulting message.- Parameters:
tts
- True, if this should cause a Text-To-Speech effect when sent to the channel- Returns:
- The same message action, for chaining convenience
-
addEmbeds
@Nonnull @CheckReturnValue WebhookMessageAction<T> addEmbeds(@Nonnull java.util.Collection<? extends MessageEmbed> embeds)
AddMessageEmbeds
to this message- Parameters:
embeds
- The message embeds to add- Returns:
- The same message action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If null is provided, or one of the embeds is too big
-
addEmbeds
@Nonnull @CheckReturnValue default WebhookMessageAction<T> addEmbeds(@Nonnull MessageEmbed embed, @Nonnull MessageEmbed... other)
AddMessageEmbeds
to this message- Parameters:
embed
- The first message embed to addother
- Additional message embeds to add- Returns:
- The same message action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If null is provided, or one of the embeds is too big
-
addFile
@Nonnull @CheckReturnValue WebhookMessageAction<T> addFile(@Nonnull java.io.InputStream data, @Nonnull java.lang.String name, @Nonnull AttachmentOption... options)
Adds the providedInputStream
as file data.
The stream will be closed upon execution!- Parameters:
data
- The InputStream that will be interpreted as file dataname
- The file name that should be used to interpret the type of the given data using the file-name extension. This name is similar to what will be visible throughMessage.Attachment.getFileName()
options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
- The same message action, for chaining convenience
- Throws:
java.lang.IllegalStateException
- If the file limit of 10 has been reached prior to calling this methodjava.lang.IllegalArgumentException
- If the provided data isnull
or the provided name is blank ornull
InsufficientPermissionException
- If this is targeting a TextChannel and the currently logged in account does not havePermission.MESSAGE_ATTACH_FILES
-
addFile
@Nonnull @CheckReturnValue default WebhookMessageAction<T> addFile(@Nonnull byte[] data, @Nonnull java.lang.String name, @Nonnull AttachmentOption... options)
Adds the provided byte[] as file data.- Parameters:
data
- The byte[] that will be interpreted as file dataname
- The file name that should be used to interpret the type of the given data using the file-name extension. This name is similar to what will be visible throughMessage.Attachment.getFileName()
options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
- The same message action, for chaining convenience
- Throws:
java.lang.IllegalStateException
- If the file limit of 10 has been reached prior to calling this methodjava.lang.IllegalArgumentException
- If the provided data isnull
or the provided name is blank ornull
or if the provided data exceeds the maximum file size of the currently logged in accountInsufficientPermissionException
- If this is targeting a TextChannel and the currently logged in account does not havePermission.MESSAGE_ATTACH_FILES
- See Also:
SelfUser.getAllowedFileSize()
-
addFile
@Nonnull @CheckReturnValue default WebhookMessageAction<T> addFile(@Nonnull java.io.File file, @Nonnull java.lang.String name, @Nonnull AttachmentOption... options)
Adds the providedFile
as file data.
This method opens aFileInputStream
which will be closed by executing this action!- Parameters:
file
- The File that will be interpreted as file dataname
- The file name that should be used to interpret the type of the given data using the file-name extension. This name is similar to what will be visible throughMessage.Attachment.getFileName()
options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
- The same message action, for chaining convenience
- Throws:
java.lang.IllegalStateException
- If the file limit of 10 has been reached prior to calling this methodjava.lang.IllegalArgumentException
- If the provided file isnull
or the provided name is blank ornull
or if the provided file is bigger than the maximum file size of the currently logged in account, or if the provided file does not exist/ is not readableInsufficientPermissionException
- If this is targeting a TextChannel and the currently logged in account does not havePermission.MESSAGE_ATTACH_FILES
- See Also:
SelfUser.getAllowedFileSize()
-
addFile
@Nonnull @CheckReturnValue default WebhookMessageAction<T> addFile(@Nonnull java.io.File file, @Nonnull AttachmentOption... options)
Adds the providedFile
as file data.
Shortcut foraddFile(file, file.getName())
with the same side-effects.- Parameters:
file
- The File that will be interpreted as file dataoptions
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
- The same message action, for chaining convenience
- Throws:
java.lang.IllegalStateException
- If the file limit of 10 has been reached prior to calling this methodjava.lang.IllegalArgumentException
- If the provided file isnull
or if the provided File is bigger than the maximum file size of the currently logged in accountInsufficientPermissionException
- If this is targeting a TextChannel and the currently logged in account does not havePermission.MESSAGE_ATTACH_FILES
- See Also:
SelfUser.getAllowedFileSize()
-
addActionRow
@Nonnull @CheckReturnValue default WebhookMessageAction<T> addActionRow(@Nonnull Component... components)
Add oneActionRow
for the message.- Parameters:
components
- The components for the action row, such asButton
- Returns:
- The same message action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If null is provided or more than 5 actions rows are provided
-
addActionRow
@Nonnull @CheckReturnValue default WebhookMessageAction<T> addActionRow(@Nonnull java.util.Collection<? extends Component> components)
Add oneActionRow
for the message.- Parameters:
components
- The components for the action row, such asButton
- Returns:
- The same message action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If null is provided or more than 5 actions rows are provided
-
addActionRows
@Nonnull @CheckReturnValue default WebhookMessageAction<T> addActionRows(@Nonnull java.util.Collection<? extends ActionRow> rows)
AddActionRows
for the message.- Parameters:
rows
- The action rows to add- Returns:
- The same message action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If null is provided or more than 5 actions rows are provided
-
addActionRows
@Nonnull @CheckReturnValue WebhookMessageAction<T> addActionRows(@Nonnull ActionRow... rows)
AddActionRows
for the message.- Parameters:
rows
- The action rows to add- Returns:
- The same message action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If null is provided or more than 5 actions rows are provided
-
applyMessage
@Nonnull @CheckReturnValue WebhookMessageAction<T> applyMessage(@Nonnull Message message)
Applies the sendable information of the providedMessage
to this message action settings.
This will override all existing settings if new settings are available.This does not copy files!
- Parameters:
message
- The Message to apply settings from- Returns:
- The same message action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the message contains aMessageEmbed
that exceeds the sendable character limit, seeMessageEmbed.isSendable()
-
-