Package discord4j.core.spec.legacy
Class LegacyMessageCreateSpec
java.lang.Object
discord4j.core.spec.legacy.LegacyMessageCreateSpec
- All Implemented Interfaces:
LegacySpec<MultipartRequest<discord4j.discordjson.json.MessageCreateRequest>>
public class LegacyMessageCreateSpec
extends Object
implements LegacySpec<MultipartRequest<discord4j.discordjson.json.MessageCreateRequest>>
LegacySpec used to create
Messages
to MessageChannels
. Clients using this spec must
have connected to gateway at least once.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddEmbed
(Consumer<? super LegacyEmbedCreateSpec> spec) Adds an embed to the message.addFile
(String fileName, InputStream file) Adds a file as attachment to the createdMessage
.addFileSpoiler
(String fileName, InputStream file) Adds a spoiler file as attachment to the createdMessage
.MultipartRequest<discord4j.discordjson.json.MessageCreateRequest>
setAllowedMentions
(AllowedMentions allowedMentions) Sets an allowed mentions object to the message spec.setComponents
(LayoutComponent... components) Sets the components of the message.setComponents
(List<LayoutComponent> components) Sets the components of the message.setContent
(String content) Sets the createdMessage
contents, up to 2000 characters.setEmbed
(Consumer<? super LegacyEmbedCreateSpec> spec) Deprecated.setMessageReference
(Snowflake messageId) Adds a message ID to reply to.Sets a nonce that can be used for optimistic message sending.setTts
(boolean tts) Sets whether the createdMessage
is a TTS message.
-
Constructor Details
-
LegacyMessageCreateSpec
public LegacyMessageCreateSpec()
-
-
Method Details
-
setContent
Sets the createdMessage
contents, up to 2000 characters.- Parameters:
content
- The message contents.- Returns:
- This spec.
-
setNonce
Sets a nonce that can be used for optimistic message sending.- Parameters:
nonce
- An identifier.- Returns:
- This spec.
-
setTts
Sets whether the createdMessage
is a TTS message.- Parameters:
tts
- If this message is a TTS message.- Returns:
- This spec.
-
setEmbed
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
- AnLegacyEmbedCreateSpec
consumer used to attach rich content when creating a message.- Returns:
- This spec.
-
addEmbed
Adds an embed to the message.A message may have up to 10 embeds.
- Parameters:
spec
- AnLegacyEmbedCreateSpec
consumer used to attach rich content when creating a message.- Returns:
- This spec.
-
addFile
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
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
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
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
Sets the components of the message.- Parameters:
components
- The message components.- Returns:
- This spec.
-
setComponents
Sets the components of the message.- Parameters:
components
- The message components.- Returns:
- This spec.
-
asRequest
- Specified by:
asRequest
in interfaceLegacySpec<MultipartRequest<discord4j.discordjson.json.MessageCreateRequest>>
-
addEmbed(Consumer)
.