Interface WebhookMessageAction<T>
- All Superinterfaces:
AllowedMentions<WebhookMessageAction<T>>,RestAction<T>
public interface WebhookMessageAction<T>
extends RestAction<T>, AllowedMentions<WebhookMessageAction<T>>
Extension of a default
RestAction
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:
-
Method Summary
Modifier and TypeMethodDescriptiondefault WebhookMessageAction<T>addActionRow(Collection<? extends ItemComponent> components) Add oneActionRowfor the message.default WebhookMessageAction<T>addActionRow(ItemComponent... components) Add oneActionRowfor the message.default WebhookMessageAction<T>addActionRows(Collection<? extends ActionRow> rows) AddActionRowsfor the message.addActionRows(ActionRow... rows) AddActionRowsfor the message.addEmbeds(Collection<? extends MessageEmbed> embeds) AddMessageEmbedsto this messagedefault WebhookMessageAction<T>addEmbeds(MessageEmbed embed, MessageEmbed... other) AddMessageEmbedsto this messagedefault WebhookMessageAction<T>addFile(byte[] data, String name, AttachmentOption... options) Adds the provided byte[] as file data.default WebhookMessageAction<T>addFile(File file, String name, AttachmentOption... options) Adds the providedFileas file data.default WebhookMessageAction<T>addFile(File file, AttachmentOption... options) Adds the providedFileas file data.addFile(InputStream data, String name, AttachmentOption... options) Adds the providedInputStreamas file data.applyMessage(Message message) Applies the sendable information of the providedMessageto this message action settings.setContent(String content) Set the content for this message.setEphemeral(boolean ephemeral) Set whether this message should be visible to other users.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, mentionUsersMethods 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 Details
-
setEphemeral
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
Set the content for this message.- Parameters:
content- The new message content- Returns:
- The same message action, for chaining convenience
- Throws:
IllegalArgumentException- If the provided content is longer thanMAX_CONTENT_LENGTHcharacters
-
setTTS
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 Collection<? extends MessageEmbed> embeds) AddMessageEmbedsto this message- Parameters:
embeds- The message embeds to add- Returns:
- The same message action, for chaining convenience
- Throws:
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) AddMessageEmbedsto this message- Parameters:
embed- The first message embed to addother- Additional message embeds to add- Returns:
- The same message action, for chaining convenience
- Throws:
IllegalArgumentException- If null is provided, or one of the embeds is too big
-
addFile
@Nonnull @CheckReturnValue WebhookMessageAction<T> addFile(@Nonnull InputStream data, @Nonnull String name, @Nonnull AttachmentOption... options) Adds the providedInputStreamas 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:
IllegalStateException- If the file limit of 10 has been reached prior to calling this methodIllegalArgumentException- If the provided data isnullor the provided name is blank ornullInsufficientPermissionException- 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 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:
IllegalStateException- If the file limit of 10 has been reached prior to calling this methodIllegalArgumentException- If the provided data isnullor the provided name is blank ornullor 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:
-
addFile
@Nonnull @CheckReturnValue default WebhookMessageAction<T> addFile(@Nonnull File file, @Nonnull String name, @Nonnull AttachmentOption... options) Adds the providedFileas file data.
This method opens aFileInputStreamwhich 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:
IllegalStateException- If the file limit of 10 has been reached prior to calling this methodIllegalArgumentException- If the provided file isnullor the provided name is blank ornullor 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:
-
addFile
@Nonnull @CheckReturnValue default WebhookMessageAction<T> addFile(@Nonnull File file, @Nonnull AttachmentOption... options) Adds the providedFileas 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:
IllegalStateException- If the file limit of 10 has been reached prior to calling this methodIllegalArgumentException- If the provided file isnullor 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:
-
addActionRow
@Nonnull @CheckReturnValue default WebhookMessageAction<T> addActionRow(@Nonnull ItemComponent... components) Add oneActionRowfor the message.- Parameters:
components- The components for the action row, such asButton- Returns:
- The same message action, for chaining convenience
- Throws:
IllegalArgumentException- If null is provided, an invalid number of components is provided, or any customidis duplicated
-
addActionRow
@Nonnull @CheckReturnValue default WebhookMessageAction<T> addActionRow(@Nonnull Collection<? extends ItemComponent> components) Add oneActionRowfor the message.- Parameters:
components- The components for the action row, such asButton- Returns:
- The same message action, for chaining convenience
- Throws:
IllegalArgumentException- If null is provided, an invalid number of components is provided, or any customidis duplicated
-
addActionRows
@Nonnull @CheckReturnValue default WebhookMessageAction<T> addActionRows(@Nonnull Collection<? extends ActionRow> rows) AddActionRowsfor the message.- Parameters:
rows- The action rows to add- Returns:
- The same message action, for chaining convenience
- Throws:
IllegalArgumentException- If null is provided, more than 5 action rows are provided, or any customidis duplicated
-
addActionRows
AddActionRowsfor the message.- Parameters:
rows- The action rows to add- Returns:
- The same message action, for chaining convenience
- Throws:
IllegalArgumentException- If null is provided, more than 5 action rows are provided, or any customidis duplicated
-
applyMessage
Applies the sendable information of the providedMessageto 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:
IllegalArgumentException- If the message contains aMessageEmbedthat exceeds the sendable character limit, seeMessageEmbed.isSendable()
-