Package discord4j.core.spec
Class MessageCreateSpec
- java.lang.Object
-
- discord4j.core.spec.MessageCreateSpec
-
- All Implemented Interfaces:
Spec<MultipartRequest>
public class MessageCreateSpec extends Object implements Spec<MultipartRequest>
Spec used to createMessages
toMessageChannels
. Clients using this spec must have connected to gateway at least once.- See Also:
- Create Message
-
-
Constructor Summary
Constructors Constructor Description MessageCreateSpec()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MessageCreateSpec
addEmbed(Consumer<? super EmbedCreateSpec> spec)
Adds an embed to the message.MessageCreateSpec
addFile(String fileName, InputStream file)
Adds a file as attachment to the createdMessage
.MessageCreateSpec
addFileSpoiler(String fileName, InputStream file)
Adds a spoiler file as attachment to the createdMessage
.MultipartRequest
asRequest()
MessageCreateSpec
setAllowedMentions(AllowedMentions allowedMentions)
Sets an allowed mentions object to the message spec.MessageCreateSpec
setComponents(LayoutComponent... components)
Sets the components of the message.MessageCreateSpec
setComponents(List<LayoutComponent> components)
Sets the components of the message.MessageCreateSpec
setContent(String content)
Sets the createdMessage
contents, up to 2000 characters.MessageCreateSpec
setEmbed(Consumer<? super EmbedCreateSpec> spec)
Deprecated.UseaddEmbed(Consumer)
.MessageCreateSpec
setMessageReference(Snowflake messageId)
Adds a message ID to reply to.MessageCreateSpec
setNonce(Snowflake nonce)
Sets a nonce that can be used for optimistic message sending.MessageCreateSpec
setTts(boolean tts)
Sets whether the createdMessage
is a TTS message.
-
-
-
Method Detail
-
setContent
public MessageCreateSpec setContent(String content)
Sets the createdMessage
contents, up to 2000 characters.- Parameters:
content
- The message contents.- Returns:
- This spec.
-
setNonce
public MessageCreateSpec setNonce(Snowflake nonce)
Sets a nonce that can be used for optimistic message sending.- Parameters:
nonce
- An identifier.- Returns:
- This spec.
-
setTts
public MessageCreateSpec setTts(boolean tts)
Sets whether the createdMessage
is a TTS message.- Parameters:
tts
- If this message is a TTS message.- Returns:
- This spec.
-
setEmbed
@Deprecated public MessageCreateSpec setEmbed(Consumer<? super EmbedCreateSpec> spec)
Deprecated.UseaddEmbed(Consumer)
.Sets rich content to the createdMessage
in the form of anEmbed
object.This method overrides any embeds added by
addEmbed(Consumer)
.- Parameters:
spec
- AnEmbedCreateSpec
consumer used to attach rich content when creating a message.- Returns:
- This spec.
-
addEmbed
public MessageCreateSpec addEmbed(Consumer<? super EmbedCreateSpec> spec)
Adds an embed to the message.A message may have up to 10 embeds.
- Parameters:
spec
- AnEmbedCreateSpec
consumer used to attach rich content when creating a message.- Returns:
- This spec.
-
addFile
public MessageCreateSpec addFile(String fileName, InputStream file)
Adds a file as attachment to the createdMessage
.- Parameters:
fileName
- The filename used in the file being sent.file
- The file contents.- Returns:
- This spec.
-
addFileSpoiler
public MessageCreateSpec addFileSpoiler(String fileName, InputStream file)
Adds a spoiler file as attachment to the createdMessage
.- Parameters:
fileName
- The filename used in the file being sent.file
- The file contents.- Returns:
- This spec.
-
setAllowedMentions
public MessageCreateSpec setAllowedMentions(@Nullable AllowedMentions allowedMentions)
Sets an allowed mentions object to the message spec. Can benull
to reset a configuration added by default.- Parameters:
allowedMentions
- The allowed mentions to add.- Returns:
- This spec.
-
setMessageReference
public MessageCreateSpec setMessageReference(Snowflake messageId)
Adds a message ID to reply to. This requires thePermission.READ_MESSAGE_HISTORY
permission, and the referenced message must exist and cannot be a system message.- Parameters:
messageId
- The ID of the message to reply to.- Returns:
- This spec.
-
setComponents
public MessageCreateSpec setComponents(LayoutComponent... components)
Sets the components of the message.- Parameters:
components
- The message components.- Returns:
- This spec.
-
setComponents
public MessageCreateSpec setComponents(List<LayoutComponent> components)
Sets the components of the message.- Parameters:
components
- The message components.- Returns:
- This spec.
-
asRequest
public MultipartRequest asRequest()
- Specified by:
asRequest
in interfaceSpec<MultipartRequest>
-
-