Interface ReplyAction
-
- All Superinterfaces:
AllowedMentions<ReplyAction>,InteractionCallbackAction,RestAction<InteractionHook>
public interface ReplyAction extends InteractionCallbackAction, AllowedMentions<ReplyAction>
AInteractionCallbackActionwhich can be used to send a message reply for an interaction.
You can usesetEphemeral(boolean)to hide this message from other users.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.requests.restaction.interactions.InteractionCallbackAction
InteractionCallbackAction.ResponseType
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ReplyActionaddActionRow(java.util.Collection<? extends Component> components)Add a singleActionRowto the message.default ReplyActionaddActionRow(Component... components)Add a singleActionRowto the message.default ReplyActionaddActionRows(java.util.Collection<? extends ActionRow> rows)AddActionRowsto the message.ReplyActionaddActionRows(ActionRow... rows)AddActionRowsto the message.ReplyActionaddEmbeds(java.util.Collection<? extends MessageEmbed> embeds)AddMessageEmbedsfor the messagedefault ReplyActionaddEmbeds(MessageEmbed... embeds)AddMessageEmbedsfor the messagedefault ReplyActionaddFile(byte[] data, java.lang.String name, AttachmentOption... options)Adds the providedbyte[]as file data.default ReplyActionaddFile(java.io.File file, java.lang.String name, AttachmentOption... options)Adds the providedFile.default ReplyActionaddFile(java.io.File file, AttachmentOption... options)Adds the providedFile.ReplyActionaddFile(java.io.InputStream data, java.lang.String name, AttachmentOption... options)Adds the providedInputStreamas file data.ReplyActiondeadline(long timestamp)Similar toRestAction.timeout(long, TimeUnit)but schedules a deadline at which the request has to be completed.ReplyActionsetCheck(java.util.function.BooleanSupplier checks)Sets the last-second checks before finally executing the http request in the queue.ReplyActionsetContent(java.lang.String content)Set the content for this message.ReplyActionsetEphemeral(boolean ephemeral)Set whether this message should be visible to other users.ReplyActionsetTTS(boolean isTTS)Enable/Disable Text-To-Speech for the resulting message.ReplyActiontimeout(long timeout, java.util.concurrent.TimeUnit unit)Timeout for this RestAction instance.-
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, delay, delay, delay, delay, flatMap, flatMap, getCheck, getJDA, map, mapToResult, onErrorFlatMap, onErrorFlatMap, onErrorMap, onErrorMap, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submit, submitAfter, submitAfter, zip
-
-
-
-
Method Detail
-
setCheck
@Nonnull ReplyAction setCheck(@Nullable java.util.function.BooleanSupplier checks)
Description copied from interface:RestActionSets the last-second checks before finally executing the http request in the queue.
If the provided supplier evaluates tofalseor throws an exception this will not be finished. When an exception is thrown from the supplier it will be provided to the failure callback.- Specified by:
setCheckin interfaceRestAction<InteractionHook>- Parameters:
checks- The checks to run before executing the request, ornullto run no checks- Returns:
- The current RestAction for chaining convenience
- See Also:
RestAction.getCheck(),RestAction.addCheck(BooleanSupplier)
-
timeout
@Nonnull ReplyAction timeout(long timeout, @Nonnull java.util.concurrent.TimeUnit unit)
Description copied from interface:RestActionTimeout for this RestAction instance.
If the request doesn't get executed within the timeout it will fail.When a RestAction times out, it will fail with a
TimeoutException. This is the same asdeadline(System.currentTimeMillis() + unit.toMillis(timeout)).Example
action.timeout(10, TimeUnit.SECONDS) // 10 seconds from now .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds- Specified by:
timeoutin interfaceRestAction<InteractionHook>- Parameters:
timeout- The timeout to useunit-Unitfor the timeout value- Returns:
- The same RestAction instance with the applied timeout
- See Also:
RestAction.setDefaultTimeout(long, TimeUnit)
-
deadline
@Nonnull ReplyAction deadline(long timestamp)
Description copied from interface:RestActionSimilar toRestAction.timeout(long, TimeUnit)but schedules a deadline at which the request has to be completed.
If the deadline is reached, the request will fail with aTimeoutException.This does not mean that the request will immediately timeout when the deadline is reached. JDA will check the deadline right before executing the request or within intervals in a worker thread. This only means the request will timeout if the deadline has passed.
Example
action.deadline(System.currentTimeMillis() + 10000) // 10 seconds from now .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds- Specified by:
deadlinein interfaceRestAction<InteractionHook>- Parameters:
timestamp- Millisecond timestamp at which the request will timeout- Returns:
- The same RestAction with the applied deadline
- See Also:
RestAction.timeout(long, TimeUnit),RestAction.setDefaultTimeout(long, TimeUnit)
-
addEmbeds
@Nonnull @CheckReturnValue default ReplyAction addEmbeds(@Nonnull MessageEmbed... embeds)
AddMessageEmbedsfor the message- Parameters:
embeds- The message embeds to add- Returns:
- The same reply action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException- If null is provided, or one of the embeds is too big
-
addEmbeds
@Nonnull @CheckReturnValue ReplyAction addEmbeds(@Nonnull java.util.Collection<? extends MessageEmbed> embeds)
AddMessageEmbedsfor the message- Parameters:
embeds- The message embeds to add- Returns:
- The same reply action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException- If null is provided, or one of the embeds is too big
-
addActionRow
@Nonnull @CheckReturnValue default ReplyAction addActionRow(@Nonnull Component... components)
Add a singleActionRowto the message.- Parameters:
components- The components for this action row- Returns:
- The same reply action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException- If null is provided or an invalid number of components are provided- See Also:
ActionRow.of(Component...)
-
addActionRow
@Nonnull @CheckReturnValue default ReplyAction addActionRow(@Nonnull java.util.Collection<? extends Component> components)
Add a singleActionRowto the message.- Parameters:
components- The components for this action row- Returns:
- The same reply action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException- If null is provided or an invalid number of components are provided- See Also:
ActionRow.of(Collection)
-
addActionRows
@Nonnull @CheckReturnValue default ReplyAction addActionRows(@Nonnull java.util.Collection<? extends ActionRow> rows)
AddActionRowsto the message.- Parameters:
rows- The action rows to add- Returns:
- The same reply action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException- If null is provided or more than 5 action rows are provided
-
addActionRows
@Nonnull @CheckReturnValue ReplyAction addActionRows(@Nonnull ActionRow... rows)
AddActionRowsto the message.- Parameters:
rows- The action rows to add- Returns:
- The same reply action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException- If null is provided or more than 5 action rows are provided
-
setContent
@Nonnull ReplyAction setContent(@Nullable java.lang.String content)
Set the content for this message.- Parameters:
content- The new message content or null to unset- Returns:
- The same reply action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException- If the provided content is longer thanMAX_CONTENT_LENGTHcharacters
-
setTTS
@Nonnull ReplyAction setTTS(boolean isTTS)
Enable/Disable Text-To-Speech for the resulting message.- Parameters:
isTTS- True, if this should cause a Text-To-Speech effect when sent to the channel- Returns:
- The same reply action, for chaining convenience
-
setEphemeral
@Nonnull @CheckReturnValue ReplyAction 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
- Parameters:
ephemeral- True, if this message should be invisible for other users- Returns:
- The same reply action, for chaining convenience
-
addFile
@Nonnull @CheckReturnValue default ReplyAction addFile(@Nonnull java.io.File file, @Nonnull AttachmentOption... options)
Adds the providedFile.
The stream will be closed upon execution!
The provided file will be appended to the message.- Parameters:
file- TheFiledata to upload in response to the interaction.options- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
- The same reply action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException- If the provided file isnull.
-
addFile
@Nonnull @CheckReturnValue default ReplyAction addFile(@Nonnull java.io.File file, @Nonnull java.lang.String name, @Nonnull AttachmentOption... options)
Adds the providedFile.
The stream will be closed upon execution!
The provided file will be appended to the message.The
nameparameter is used to inform Discord about what the file should be called. This is 2 fold:- The file name provided is the name that is found in
Message.Attachment.getFileName()after upload and it is the name that will show up in the client when the upload is displayed.
Note: The fileName does not show up on the Desktop client for images. It does on mobile however. - The extension of the provided fileName also determines how Discord will treat the file. Discord currently only has special handling for image file types, but the fileName's extension must indicate that it is an image file. This means it has to end in something like .png, .jpg, .jpeg, .gif, etc. As a note, you can also not provide a full name for the file and instead ONLY provide the extension like "png" or "gif" and Discord will generate a name for the upload and append the fileName as the extension.
- Parameters:
file- TheFiledata to upload in response to the interaction.name- The file name that should be sent to discordoptions- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
- The same reply action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException- If the provided file or filename isnull.
- The file name provided is the name that is found in
-
addFile
@Nonnull @CheckReturnValue default ReplyAction addFile(@Nonnull byte[] data, @Nonnull java.lang.String name, @Nonnull AttachmentOption... options)
Adds the providedbyte[]as file data.
The stream will be closed upon execution!
The provided file will be appended to the message.- Parameters:
data- Thebyte[]data to upload in response to the interaction.name- The file name that should be sent to discord
Refer to the documentation foraddFile(java.io.File, String, AttachmentOption...)for information about this parameter.options- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
- The same reply action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException- If the provided data or filename isnull.
-
addFile
@Nonnull @CheckReturnValue ReplyAction addFile(@Nonnull java.io.InputStream data, @Nonnull java.lang.String name, @Nonnull AttachmentOption... options)
Adds the providedInputStreamas file data.
The stream will be closed upon execution!
The provided file will be appended to the message.- Parameters:
data- The InputStream data to upload in response to the interaction.name- The file name that should be sent to discord
Refer to the documentation foraddFile(java.io.File, String, AttachmentOption...)for information about this parameter.options- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
- The same reply action, for chaining convenience
- Throws:
java.lang.IllegalArgumentException- If the provided data or filename isnull.
-
-