Interface MessageCreateRequest<R extends MessageCreateRequest<R>>
- Type Parameters:
- R- The return type for method chaining convenience
- All Superinterfaces:
- MessageData,- MessageRequest<R>
- All Known Subinterfaces:
- ForumPostAction,- MessageCreateAction,- ReplyCallbackAction,- WebhookMessageCreateAction<T>
- All Known Implementing Classes:
- MessageCreateBuilder
- 
Method SummaryModifier and TypeMethodDescriptiondefault RaddActionRow(Collection<? extends ItemComponent> components) Appends a singleActionRowto the request.default RaddActionRow(ItemComponent... components) Appends a singleActionRowto the request.addComponents(Collection<? extends LayoutComponent> components) Appends the providedLayoutComponentsto the request.default RaddComponents(LayoutComponent... components) Appends the providedLayoutComponentsto the request.addContent(String content) Appends the content to the currently set content of this request.addEmbeds(Collection<? extends MessageEmbed> embeds) Appends the providedMessageEmbedsto the request.default RaddEmbeds(MessageEmbed... embeds) Appends the providedMessageEmbedsto the request.addFiles(Collection<? extends FileUpload> files) Appends the providedFileUploadsto the request.default RaddFiles(FileUpload... files) Appends the providedFileUploadsto the request.default RapplyData(MessageCreateData data) Applies the providedMessageCreateDatato this request.default RapplyEditData(MessageEditData data) Applies the providedMessageEditDatato this request.default RapplyMessage(Message message) Applies all the data of the providedMessageand attempts to copy it.The configured message attachments asAttachedFile, this is the opposite ofMessageRequest.setFiles(Collection)and only returns what was set using that setter.getPoll()The poll attached to this messagesetPoll(MessagePollData poll) Add a poll to this message.setSuppressedNotifications(boolean suppressed) Set whether this message should trigger push/desktop notifications to other users.setTTS(boolean tts) Whether the message should use Text-to-Speech (TTS).setVoiceMessage(boolean voiceMessage) Whether this message should be considered a voice message.Methods inherited from interface net.dv8tion.jda.api.utils.messages.MessageDatagetAllowedMentions, getComponents, getContent, getEmbeds, getMentionedRoles, getMentionedUsers, isMentionRepliedUser, isSuppressEmbedsMethods inherited from interface net.dv8tion.jda.api.utils.messages.MessageRequestmention, mention, mentionRepliedUser, mentionRoles, mentionRoles, mentionRoles, mentionUsers, mentionUsers, mentionUsers, setActionRow, setActionRow, setAllowedMentions, setComponents, setComponents, setContent, setEmbeds, setEmbeds, setFiles, setFiles, setSuppressEmbeds
- 
Method Details- 
addContentAppends the content to the currently set content of this request.
 UseMessageRequest.setContent(String)instead, to replace the content entirely.Example 
 Sending a message with the content"Hello World!":channel.sendMessage("Hello ").addContent("World!").queue();- Parameters:
- content- The content to append
- Returns:
- The same instance for chaining
- Throws:
- IllegalArgumentException- If the provided content is- nullor the accumulated content is longer than 2000 characters
 
- 
addEmbedsAppends the providedMessageEmbedsto the request.
 UseMessageRequest.setEmbeds(Collection)instead, to replace the embeds entirely.Example 
 Sending a message with multiple embeds:channel.sendMessageEmbeds(embed1).addEmbeds(embed2).queue();- Parameters:
- embeds- The embeds to add
- Returns:
- The same instance for chaining
- Throws:
- IllegalArgumentException- If null is provided or the accumulated embed list is longer than 10
 
- 
addEmbedsAppends the providedMessageEmbedsto the request.
 UseMessageRequest.setEmbeds(Collection)instead, to replace the embeds entirely.Example 
 Sending a message with multiple embeds:channel.sendMessageEmbeds(embed1).addEmbeds(embed2).queue();- Parameters:
- embeds- The embeds to add
- Returns:
- The same instance for chaining
- Throws:
- IllegalArgumentException- If null is provided or the accumulated embed list is longer than 10
 
- 
addComponentsAppends the providedLayoutComponentsto the request.
 UseMessageRequest.setComponents(Collection)instead, to replace the components entirely.Example 
 Sending a message with multiple action rows:channel.sendMessageComponents(ActionRow.of(selectMenu)) .addComponents(ActionRow.of(button1, button2)) .queue();- Parameters:
- components- The layout components to add
- Returns:
- The same instance for chaining
- Throws:
- IllegalArgumentException-- If nullis provided
- If any of the components is not message compatible
- If the accumulated list of components is longer than 5
 
- If 
- See Also:
 
- 
addComponentsAppends the providedLayoutComponentsto the request.
 UseMessageRequest.setComponents(Collection)instead, to replace the components entirely.Example 
 Sending a message with multiple action rows:channel.sendMessageComponents(ActionRow.of(selectMenu)) .addComponents(ActionRow.of(button1, button2)) .queue();- Parameters:
- components- The layout components to add
- Returns:
- The same instance for chaining
- Throws:
- IllegalArgumentException-- If nullis provided
- If any of the components is not message compatible
- If the accumulated list of components is longer than 5
 
- If 
- See Also:
 
- 
addActionRowAppends a singleActionRowto the request.
 UseMessageRequest.setComponents(Collection)instead, to replace the components entirely.Example 
 Sending a message with multiple action rows:channel.sendMessageComponents(ActionRow.of(selectMenu)) .addActionRow(button1, button2) .queue();- Parameters:
- components- The- componentsto add to the action row, must not be empty
- Returns:
- The same instance for chaining
- Throws:
- IllegalArgumentException-- If nullis provided
- If any of the components is not message compatible
- If the accumulated list of components is longer than 5
- In all the same cases as ActionRow.of(Collection)throws an exception
 
- If 
- See Also:
 
- 
addActionRowAppends a singleActionRowto the request.
 UseMessageRequest.setComponents(Collection)instead, to replace the components entirely.Example 
 Sending a message with multiple action rows:channel.sendMessageComponents(ActionRow.of(selectMenu)) .addActionRow(button1, button2) .queue();- Parameters:
- components- The- componentsto add to the action row, must not be empty
- Returns:
- The same instance for chaining
- Throws:
- IllegalArgumentException-- If nullis provided
- If any of the components is not message compatible
- If the accumulated list of components is longer than 5
- In all the same cases as ActionRow.of(ItemComponent...)throws an exception
 
- If 
- See Also:
 
- 
addFilesAppends the providedFileUploadsto the request.
 UseMessageRequest.setFiles(Collection)instead, to replace the file attachments entirely.Resource Handling Note: Once the request is handed off to the requester, for example when you call RestAction.queue(), the requester will automatically clean up all opened files by itself. You are only responsible to close them yourself if it is never handed off properly. For instance, if an exception occurs after usingFileUpload.fromData(File), before callingRestAction.queue(). You can safely use a try-with-resources to handle this, sinceFileUpload.close()becomes ineffective once the request is handed off.Example 
 Sending a message with multiple files:channel.sendFiles(file1).addFiles(file2).queue();- Parameters:
- files- The files to add
- Returns:
- The same instance for chaining
- Throws:
- IllegalArgumentException- If null is provided
 
- 
addFilesAppends the providedFileUploadsto the request.
 UseMessageRequest.setFiles(Collection)instead, to replace the file attachments entirely.Resource Handling Note: Once the request is handed off to the requester, for example when you call RestAction.queue(), the requester will automatically clean up all opened files by itself. You are only responsible to close them yourself if it is never handed off properly. For instance, if an exception occurs after usingFileUpload.fromData(File), before callingRestAction.queue(). You can safely use a try-with-resources to handle this, sinceFileUpload.close()becomes ineffective once the request is handed off.Example 
 Sending a message with multiple files:channel.sendFiles(file1).addFiles(file2).queue();- Parameters:
- files- The files to add
- Returns:
- The same instance for chaining
- Throws:
- IllegalArgumentException- If null is provided
 
- 
getAttachmentsDescription 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 interface- MessageData
- Returns:
- The currently configured attachments, or an empty list if none were set yet
- See Also:
 
- 
getPollThe poll attached to this message- Returns:
- The attached poll, or null if no poll is present
 
- 
setPollAdd a poll to this message.- Parameters:
- poll- The poll to send
- Returns:
- The same instance for chaining
- See Also:
 
- 
setTTSWhether the message should use Text-to-Speech (TTS).Requires Permission.MESSAGE_TTSto be enabled.- Parameters:
- tts- True, if the message should use TTS
- Returns:
- The same instance for chaining
 
- 
setSuppressedNotificationsSet whether this message should trigger push/desktop notifications to other users.
 When a message is suppressed, it will not trigger push/desktop notifications.- Parameters:
- suppressed- True, if this message should not trigger push/desktop notifications
- Returns:
- The same instance for chaining
 
- 
setVoiceMessageWhether this message should be considered a voice message.
 Voice messages must upload a valid voice message attachment, usingFileUpload.asVoiceMessage(MediaType, byte[], double).- Parameters:
- voiceMessage- True, if this message is a voice message. Turned on automatically if attachment is a valid voice message attachment.
- Returns:
- The same instance for chaining
 
- 
applyDataApplies the providedMessageCreateDatato this request.- Parameters:
- data- The message create data to apply
- Returns:
- The same instance for chaining
- Throws:
- IllegalArgumentException- If the data is null
 
- 
applyMessageDescription copied from interface:MessageRequestApplies all the data of the providedMessageand attempts to copy it.
 This cannot copy the file attachments of the message, they must be manually downloaded and provided toMessageRequest.setFiles(FileUpload...).
 Theallowed mentionsare not updated to reflect the provided message, and might mention users that the message did not.For edit requests, this will set MessageEditRequest.setReplace(boolean)totrue, and replace the existing message completely.- Specified by:
- applyMessagein interface- MessageRequest<R extends MessageCreateRequest<R>>
- Parameters:
- message- The message to copy the data from
- Returns:
- The same instance for chaining
 
- 
applyEditDataApplies the providedMessageEditDatato this request.
 This will only set fields which were explicitly set on theMessageEditBuilder, unless it was configured to bereplacing.This will not copy the message's attachments, only any configured FileUploads. To copy attachments, you must download them explicitly instead.- Parameters:
- data- The message create data to apply
- Returns:
- The same instance for chaining
- Throws:
- IllegalArgumentException- If the data is null
 
 
-