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 TypeMethodDescriptionvoidclose()static MessageCreateDatafromContent(String content) Shortcut fornew MessageCreateBuilder().setContent(content).build().static MessageCreateDatafromEditData(MessageEditData data) Shortcut fornew MessageCreateBuilder().applyEditData(data).build().static MessageCreateDatafromEmbeds(Collection<? extends MessageEmbed> embeds) Shortcut fornew MessageCreateBuilder().setEmbeds(embeds).build().static MessageCreateDatafromEmbeds(MessageEmbed... embeds) Shortcut fornew MessageCreateBuilder().setEmbeds(embeds).build().static MessageCreateDatafromFiles(Collection<? extends FileUpload> files) Shortcut fornew MessageCreateBuilder().setFiles(embeds).build().static MessageCreateDatafromFiles(FileUpload... files) Shortcut fornew MessageCreateBuilder().setFiles(embeds).build().static MessageCreateDatafromMessage(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()TheFileUploadsattached 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 messagebooleanWhether this message would mention a user, if it is sent as a reply.booleanWhether this message is silent.booleanWhether embeds will be suppressed on this message.booleanisTTS()Whether this message uses Text-to-Speech (TTS).booleanWhether this message is intended as a voice message.toData()SerializedDataObjectfor 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:
getContentin interfaceMessageData- Returns:
- The content or an empty string if none was provided
- See Also:
-
getEmbeds
The embeds of the message.- Specified by:
getEmbedsin interfaceMessageData- Returns:
- The embeds or an empty list if none were provided
- See Also:
-
getComponents
The components of the message.- Specified by:
getComponentsin interfaceMessageData- Returns:
- The components or an empty list if none were provided
- See Also:
-
getAttachments
Description copied from interface:MessageDataThe 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:
getAttachmentsin 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:MessageDataWhether embeds will be suppressed on this message.- Specified by:
isSuppressEmbedsin 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:
getMentionedUsersin 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:
getMentionedRolesin interfaceMessageData- Returns:
- The role IDs which are mention whitelisted
-
getAllowedMentions
The mention types which are whitelisted.- Specified by:
getAllowedMentionsin 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:
isMentionRepliedUserin interfaceMessageData- Returns:
- True, if this would mention with the reply
-
toData
Description copied from interface:SerializableDataSerializedDataObjectfor this object.- Specified by:
toDatain interfaceSerializableData- Returns:
DataObject
-
getFiles
TheFileUploadsattached to this message.- Returns:
- The list of file uploads
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-