Class MessageCreateData
java.lang.Object
net.dv8tion.jda.api.utils.messages.MessageCreateData
- All Implemented Interfaces:
AutoCloseable
,SerializableData
,MessageData
public class MessageCreateData
extends Object
implements MessageData, AutoCloseable, SerializableData
Output of a
MessageCreateBuilder
and used for sending messages to channels/webhooks/interactions.-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static MessageCreateData
fromContent
(String content) Shortcut fornew MessageCreateBuilder().setContent(content).build()
.static MessageCreateData
fromEditData
(MessageEditData data) Shortcut fornew MessageCreateBuilder().applyEditData(data).build()
.static MessageCreateData
fromEmbeds
(Collection<? extends MessageEmbed> embeds) Shortcut fornew MessageCreateBuilder().setEmbeds(embeds).build()
.static MessageCreateData
fromEmbeds
(MessageEmbed... embeds) Shortcut fornew MessageCreateBuilder().setEmbeds(embeds).build()
.static MessageCreateData
fromFiles
(Collection<? extends FileUpload> files) Shortcut fornew MessageCreateBuilder().setFiles(embeds).build()
.static MessageCreateData
fromFiles
(FileUpload... files) Shortcut fornew MessageCreateBuilder().setFiles(embeds).build()
.static MessageCreateData
fromMessage
(Message message) Shortcut fornew MessageCreateBuilder().applyMessage(message).build()
.The mention types which are whitelisted.List<? extends FileUpload>
The configured message attachments asAttachedFile
, this is the opposite ofMessageRequest.setFiles(Collection)
and only returns what was set using that setter.The components of the message.The content of the message.The embeds of the message.getFiles()
TheFileUploads
attached to this message.The IDs for roles which are allowed to be mentioned, or an empty list.The IDs for users which are allowed to be mentioned, or an empty list.getPoll()
The poll to send with the messageboolean
Whether this message would mention a user, if it is sent as a reply.boolean
Whether this message is silent.boolean
Whether embeds will be suppressed on this message.boolean
isTTS()
Whether this message uses Text-to-Speech (TTS).boolean
Whether this message is intended as a voice message.toData()
SerializedDataObject
for this object.
-
Method Details
-
fromContent
Shortcut fornew MessageCreateBuilder().setContent(content).build()
.- Parameters:
content
- The message content (up to 2000)- Returns:
- New valid instance of MessageCreateData
- Throws:
IllegalArgumentException
- If the content is null, empty, or longer than 2000- See Also:
-
fromEmbeds
@Nonnull public static MessageCreateData fromEmbeds(@Nonnull Collection<? extends MessageEmbed> embeds) Shortcut fornew MessageCreateBuilder().setEmbeds(embeds).build()
.- Parameters:
embeds
- The message embeds (up to 10)- Returns:
- New valid instance of MessageCreateData
- Throws:
IllegalArgumentException
- If the embed list is null, empty, or longer than 10- See Also:
-
fromEmbeds
Shortcut fornew MessageCreateBuilder().setEmbeds(embeds).build()
.- Parameters:
embeds
- The message embeds (up to 10)- Returns:
- New valid instance of MessageCreateData
- Throws:
IllegalArgumentException
- If the embed list is null, empty, or longer than 10- See Also:
-
fromFiles
Shortcut fornew MessageCreateBuilder().setFiles(embeds).build()
.- Parameters:
files
- The file uploads- Returns:
- New valid instance of MessageCreateData
- Throws:
IllegalArgumentException
- If the null is provided or the list is empty- See Also:
-
fromFiles
Shortcut fornew MessageCreateBuilder().setFiles(embeds).build()
.- Parameters:
files
- The file uploads- Returns:
- New valid instance of MessageCreateData
- Throws:
IllegalArgumentException
- If the null is provided or the list is empty- See Also:
-
fromMessage
Shortcut fornew MessageCreateBuilder().applyMessage(message).build()
.- Parameters:
message
- The message to apply- Returns:
- New valid instance of MessageCreateData
- Throws:
IllegalArgumentException
- If the message is null or a system message- See Also:
-
fromEditData
Shortcut fornew MessageCreateBuilder().applyEditData(data).build()
.- Parameters:
data
- The message edit data to apply- Returns:
- New valid instance of MessageCreateData
- Throws:
IllegalArgumentException
- If the data is null or empty- See Also:
-
getContent
The content of the message.- Specified by:
getContent
in interfaceMessageData
- Returns:
- The content or an empty string if none was provided
- See Also:
-
getEmbeds
The embeds of the message.- Specified by:
getEmbeds
in interfaceMessageData
- Returns:
- The embeds or an empty list if none were provided
- See Also:
-
getComponents
The components of the message.- Specified by:
getComponents
in interfaceMessageData
- Returns:
- The components or an empty list if none were provided
- See Also:
-
getAttachments
Description copied from interface:MessageData
The configured message attachments asAttachedFile
, this is the opposite ofMessageRequest.setFiles(Collection)
and only returns what was set using that setter.For message edit requests, this will not be the current file attachments of the message.
- Specified by:
getAttachments
in interfaceMessageData
- Returns:
- The currently configured attachments, or an empty list if none were set yet
- See Also:
-
getPoll
The poll to send with the message- Returns:
- The poll, or null if no poll is sent
-
isSuppressEmbeds
public boolean isSuppressEmbeds()Description copied from interface:MessageData
Whether embeds will be suppressed on this message.- Specified by:
isSuppressEmbeds
in interfaceMessageData
- Returns:
- True, if embeds are suppressed
-
isTTS
public boolean isTTS()Whether this message uses Text-to-Speech (TTS).- Returns:
- True, if text to speech will be used when this is sent
-
isSuppressedNotifications
public boolean isSuppressedNotifications()Whether this message is silent.- Returns:
- True, if the message will not trigger push and desktop notifications.
-
isVoiceMessage
public boolean isVoiceMessage()Whether this message is intended as a voice message.- Returns:
- True, if this message is intended as a voice message.
-
getMentionedUsers
The IDs for users which are allowed to be mentioned, or an empty list.- Specified by:
getMentionedUsers
in interfaceMessageData
- Returns:
- The user IDs which are mention whitelisted
-
getMentionedRoles
The IDs for roles which are allowed to be mentioned, or an empty list.- Specified by:
getMentionedRoles
in interfaceMessageData
- Returns:
- The role IDs which are mention whitelisted
-
getAllowedMentions
The mention types which are whitelisted.- Specified by:
getAllowedMentions
in interfaceMessageData
- Returns:
- The mention types which can be mentioned by this message
-
isMentionRepliedUser
public boolean isMentionRepliedUser()Whether this message would mention a user, if it is sent as a reply.- Specified by:
isMentionRepliedUser
in interfaceMessageData
- Returns:
- True, if this would mention with the reply
-
toData
Description copied from interface:SerializableData
SerializedDataObject
for this object.- Specified by:
toData
in interfaceSerializableData
- Returns:
DataObject
-
getFiles
TheFileUploads
attached to this message.- Returns:
- The list of file uploads
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-