Class MessageCreateActionImpl
- All Implemented Interfaces:
FluentRestAction<Message,
,MessageCreateAction> RestAction<Message>
,MessageCreateAction
,MessageCreateRequest<MessageCreateAction>
,MessageData
,MessageRequest<MessageCreateAction>
,AbstractMessageBuilderMixin<MessageCreateAction,
,MessageCreateBuilder> MessageCreateBuilderMixin<MessageCreateAction>
-
Field Summary
Fields inherited from class net.dv8tion.jda.internal.requests.RestActionImpl
LOG
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeadline
(long timestamp) Similar toRestAction.timeout(long, TimeUnit)
but schedules a deadline at which the request has to be completed.failOnInvalidReply
(boolean fail) Whether to throw a exception if the referenced message does not exist, when replying to a message.setCheck
(BooleanSupplier checks) Sets the last-second checks before finally executing the http request in the queue.static void
setDefaultFailOnInvalidReply
(boolean fail) setMessageReference
(String messageId) Message reference used for a reply.setMessageReference
(MessageReference.MessageReferenceType type, String guildId, String channelId, String messageId) Message reference used for a reply or forwarded message.Unique string/number used to identify messages usingMessage.getNonce()
inMessageReceivedEvent
.setStickers
(Collection<? extends StickerSnowflake> stickers) Set the stickers to send alongside this message.Methods inherited from class net.dv8tion.jda.internal.requests.RestActionImpl
complete, getCheck, getDefaultFailure, getDefaultSuccess, getDefaultTimeout, getJDA, handleResponse, isPassContext, priority, queue, setDefaultFailure, setDefaultSuccess, setDefaultTimeout, setErrorMapper, setPassContext, submit
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.dv8tion.jda.internal.utils.message.AbstractMessageBuilderMixin
getAllowedMentions, getComponents, getContent, getEmbeds, getMentionedRoles, getMentionedUsers, isMentionRepliedUser, isSuppressEmbeds, isUsingComponentsV2, mention, mentionRepliedUser, mentionRoles, mentionUsers, setAllowedMentions, setComponents, setContent, setEmbeds, setSuppressEmbeds, useComponentsV2
Methods inherited from interface net.dv8tion.jda.api.requests.FluentRestAction
addCheck, timeout
Methods inherited from interface net.dv8tion.jda.api.requests.restaction.MessageCreateAction
setMessageReference, setMessageReference, setMessageReference, setMessageReference, setStickers
Methods inherited from interface net.dv8tion.jda.internal.utils.message.MessageCreateBuilderMixin
addComponents, addContent, addEmbeds, addFiles, getAttachments, getPoll, setFiles, setPoll, setSuppressedNotifications, setTTS, setVoiceMessage
Methods inherited from interface net.dv8tion.jda.api.utils.messages.MessageCreateRequest
addComponents, addComponents, addEmbeds, addFiles, applyData, applyEditData, applyMessage, getAttachments
Methods inherited from interface net.dv8tion.jda.api.utils.messages.MessageData
getComponentTree
Methods inherited from interface net.dv8tion.jda.api.utils.messages.MessageRequest
mention, mentionRoles, mentionRoles, mentionUsers, mentionUsers, setComponents, setComponents, setEmbeds, setFiles, useComponentsV2
Methods inherited from interface net.dv8tion.jda.api.requests.RestAction
and, and, complete, complete, completeAfter, delay, delay, delay, delay, flatMap, flatMap, getCheck, getJDA, map, mapToResult, onErrorFlatMap, onErrorFlatMap, onErrorMap, onErrorMap, onSuccess, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submit, submitAfter, submitAfter, zip
-
Constructor Details
-
MessageCreateActionImpl
-
-
Method Details
-
setDefaultFailOnInvalidReply
public static void setDefaultFailOnInvalidReply(boolean fail) -
getBuilder
- Specified by:
getBuilder
in interfaceAbstractMessageBuilderMixin<MessageCreateAction,
MessageCreateBuilder>
-
setNonce
Description copied from interface:MessageCreateAction
Unique string/number used to identify messages usingMessage.getNonce()
inMessageReceivedEvent
.The nonce can be used for deduping messages and marking them for use with
MessageReceivedEvent
. JDA will automatically generate a unique nonce per message, it is not necessary to do this manually.- Specified by:
setNonce
in interfaceMessageCreateAction
- Parameters:
nonce
- The nonce string to use, must be unique per message. A unique nonce will be generated automatically if this is null.- Returns:
- The same instance for chaining
- See Also:
-
setMessageReference
@Nonnull public MessageCreateAction setMessageReference(@Nonnull MessageReference.MessageReferenceType type, @Nullable String guildId, @Nonnull String channelId, @Nonnull String messageId) Description copied from interface:MessageCreateAction
Message reference used for a reply or forwarded message.You can only reply to messages from the same channel. By default, this will mention the author of the target message, this can be disabled using
MessageRequest.mentionRepliedUser(boolean)
.This also requires
Permission.MESSAGE_HISTORY
in the channel. If this permission is missing, you receiveErrorResponse.REPLY_FAILED_MISSING_MESSAGE_HISTORY_PERM
.If the target message does not exist, this will result in
ErrorResponse.UNKNOWN_MESSAGE
. You can useMessageCreateAction.failOnInvalidReply(boolean)
to allow unknown or deleted messages.Creates a snapshot of the referenced message at the current time and sends it in this channel.
You cannot forward messages from channels you do not have access to.
Possible
ErrorResponses
from forwarding include:REFERENCED_MESSSAGE_NOT_FOUND
If the provided reference cannot be resolved to a messageFORWARD_CANNOT_HAVE_CONTENT
If additional content is sent alongside a forwarded message
- Specified by:
setMessageReference
in interfaceMessageCreateAction
- Parameters:
type
- The type of message referenceguildId
- The guild id the forwarded message comes from, or null if it is not from a guildchannelId
- The channel id the forwarded message comes frommessageId
- The target message id- Returns:
- The same instance for chaining
-
setMessageReference
Description copied from interface:MessageCreateAction
Message reference used for a reply.
The client will show this message as a reply to the target message.You can only reply to messages from the same channel. By default, this will mention the author of the target message, this can be disabled using
MessageRequest.mentionRepliedUser(boolean)
.This also requires
Permission.MESSAGE_HISTORY
in the channel. If this permission is missing, you receiveErrorResponse.REPLY_FAILED_MISSING_MESSAGE_HISTORY_PERM
.If the target message does not exist, this will result in
ErrorResponse.UNKNOWN_MESSAGE
. You can useMessageCreateAction.failOnInvalidReply(boolean)
to allow unknown or deleted messages.- Specified by:
setMessageReference
in interfaceMessageCreateAction
- Parameters:
messageId
- The target message id to reply to- Returns:
- The same instance for chaining
-
failOnInvalidReply
Description copied from interface:MessageCreateAction
Whether to throw a exception if the referenced message does not exist, when replying to a message.
This only matters in combination withMessageCreateAction.setMessageReference(Message)
andMessageCreateAction.setMessageReference(long)
!This is false by default but can be configured using
MessageCreateAction.setDefaultFailOnInvalidReply(boolean)
!- Specified by:
failOnInvalidReply
in interfaceMessageCreateAction
- Parameters:
fail
- True, to throw a exception if the referenced message does not exist- Returns:
- Updated MessageCreateAction for chaining convenience
-
setStickers
@Nonnull public MessageCreateAction setStickers(@Nullable Collection<? extends StickerSnowflake> stickers) Description copied from interface:MessageCreateAction
Set the stickers to send alongside this message.
This is not supported for message edits.- Specified by:
setStickers
in interfaceMessageCreateAction
- Parameters:
stickers
- The stickers to send, or null to not send any stickers- Returns:
- Updated MessageCreateAction for chaining convenience
- See Also:
-
setCheck
Description copied from interface:RestAction
Sets the last-second checks before finally executing the http request in the queue.
If the provided supplier evaluates tofalse
or 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:
setCheck
in interfaceFluentRestAction<Message,
MessageCreateAction> - Specified by:
setCheck
in interfaceRestAction<Message>
- Overrides:
setCheck
in classRestActionImpl<Message>
- Parameters:
checks
- The checks to run before executing the request, ornull
to run no checks- Returns:
- The current RestAction for chaining convenience
- See Also:
-
deadline
Description copied from interface:RestAction
Similar 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:
deadline
in interfaceFluentRestAction<Message,
MessageCreateAction> - Specified by:
deadline
in interfaceRestAction<Message>
- Overrides:
deadline
in classRestActionImpl<Message>
- Parameters:
timestamp
- Millisecond timestamp at which the request will timeout- Returns:
- The same RestAction with the applied deadline
- See Also:
-