Interface MessageCreateAction
- All Superinterfaces:
FluentRestAction<Message,
,MessageCreateAction> MessageCreateRequest<MessageCreateAction>
,MessageData
,MessageRequest<MessageCreateAction>
,RestAction<Message>
RestAction
used for sending messages to MessageChannels
.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionfailOnInvalidReply
(boolean fail) Whether to throw a exception if the referenced message does not exist, when replying to a message.static void
setDefaultFailOnInvalidReply
(boolean fail) Sets the default value forfailOnInvalidReply(boolean)
default MessageCreateAction
setMessageReference
(long messageId) Message reference used for a reply.setMessageReference
(String messageId) Message reference used for a reply.default MessageCreateAction
setMessageReference
(Message message) Message reference used for a reply.default MessageCreateAction
setMessageReference
(MessageReference.MessageReferenceType type, long guildId, long channelId, long messageId) Message reference used for a reply or forwarded message.setMessageReference
(MessageReference.MessageReferenceType type, String guildId, String channelId, String messageId) Message reference used for a reply or forwarded message.default MessageCreateAction
setMessageReference
(MessageReference.MessageReferenceType type, Message message) 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.default MessageCreateAction
setStickers
(StickerSnowflake... stickers) Set the stickers to send alongside this message.Methods inherited from interface net.dv8tion.jda.api.requests.FluentRestAction
addCheck, deadline, setCheck, timeout
Methods inherited from interface net.dv8tion.jda.api.utils.messages.MessageCreateRequest
addActionRow, addActionRow, addComponents, addComponents, addContent, addEmbeds, addEmbeds, addFiles, addFiles, applyData, applyEditData, applyMessage, getAttachments, getPoll, setPoll, setSuppressedNotifications, setTTS, setVoiceMessage
Methods inherited from interface net.dv8tion.jda.api.utils.messages.MessageData
getAllowedMentions, getComponents, getContent, getEmbeds, getMentionedRoles, getMentionedUsers, isMentionRepliedUser, isSuppressEmbeds
Methods inherited from interface net.dv8tion.jda.api.utils.messages.MessageRequest
mention, mention, mentionRepliedUser, mentionRoles, mentionRoles, mentionRoles, mentionUsers, mentionUsers, mentionUsers, setActionRow, setActionRow, setAllowedMentions, setComponents, setComponents, setContent, setEmbeds, setEmbeds, setFiles, setFiles, setSuppressEmbeds
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
-
Method Details
-
setDefaultFailOnInvalidReply
static void setDefaultFailOnInvalidReply(boolean fail) Sets the default value forfailOnInvalidReply(boolean)
Default: false
- Parameters:
fail
- True, to throw a exception if the referenced message does not exist
-
setNonce
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.- 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
- Throws:
IllegalArgumentException
- If the provided nonce is longer than 25 characters- See Also:
-
setMessageReference
@Nonnull @CheckReturnValue MessageCreateAction setMessageReference(@Nonnull MessageReference.MessageReferenceType type, @Nullable String guildId, @Nonnull String channelId, @Nonnull String messageId) 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 usefailOnInvalidReply(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
- 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
- Throws:
IllegalArgumentException
- If null or an invalid snowflake is passed or the reference type isMessageReference.MessageReferenceType.UNKNOWN
-
setMessageReference
@Nonnull @CheckReturnValue default MessageCreateAction setMessageReference(@Nonnull MessageReference.MessageReferenceType type, long guildId, long channelId, long messageId) 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 usefailOnInvalidReply(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
- Parameters:
type
- The type of message referenceguildId
- The guild id the forwarded message comes from, or 0 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
- Throws:
IllegalArgumentException
- If the reference type is null orMessageReference.MessageReferenceType.UNKNOWN
-
setMessageReference
@Nonnull @CheckReturnValue default MessageCreateAction setMessageReference(@Nonnull MessageReference.MessageReferenceType type, @Nonnull Message message) 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 usefailOnInvalidReply(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
- Parameters:
type
- The type of message referencemessage
- The target message- Returns:
- The same instance for chaining
- Throws:
IllegalArgumentException
- If null is provided or the reference type isMessageReference.MessageReferenceType.UNKNOWN
-
setMessageReference
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 usefailOnInvalidReply(boolean)
to allow unknown or deleted messages.- Parameters:
messageId
- The target message id to reply to- Returns:
- The same instance for chaining
- Throws:
IllegalArgumentException
- If the message id is not a valid snowflake
-
setMessageReference
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 usefailOnInvalidReply(boolean)
to allow unknown or deleted messages.- Parameters:
messageId
- The target message id to reply to- Returns:
- The same instance for chaining
-
setMessageReference
@Nonnull @CheckReturnValue default MessageCreateAction setMessageReference(@Nullable Message message) 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 usefailOnInvalidReply(boolean)
to allow unknown or deleted messages.- Parameters:
message
- The target message to reply to- Returns:
- The same instance for chaining
-
failOnInvalidReply
Whether to throw a exception if the referenced message does not exist, when replying to a message.
This only matters in combination withsetMessageReference(Message)
andsetMessageReference(long)
!This is false by default but can be configured using
setDefaultFailOnInvalidReply(boolean)
!- Parameters:
fail
- True, to throw a exception if the referenced message does not exist- Returns:
- Updated MessageCreateAction for chaining convenience
-
setStickers
@Nonnull @CheckReturnValue MessageCreateAction setStickers(@Nullable Collection<? extends StickerSnowflake> stickers) Set the stickers to send alongside this message.
This is not supported for message edits.- Parameters:
stickers
- The stickers to send, or null to not send any stickers- Returns:
- Updated MessageCreateAction for chaining convenience
- Throws:
IllegalStateException
- If this request is a message edit requestIllegalArgumentException
-- If any of the provided stickers is a
GuildSticker
, which is eitherunavailable
or from a different guild. - If the collection has more than 3 stickers
- If a collection with null entries is provided
- If any of the provided stickers is a
- See Also:
-
setStickers
@Nonnull @CheckReturnValue default MessageCreateAction setStickers(@Nullable StickerSnowflake... stickers) Set the stickers to send alongside this message.
This is not supported for message edits.- Parameters:
stickers
- The stickers to send, or null to not send any stickers- Returns:
- Updated MessageCreateAction for chaining convenience
- Throws:
IllegalStateException
- If this request is a message edit requestIllegalArgumentException
-- If any of the provided stickers is a
GuildSticker
, which is eitherunavailable
or from a different guild. - If the collection has more than 3 stickers
- If a collection with null entries is provided
- If any of the provided stickers is a
- See Also:
-