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 createMessagestoMessageChannels. Clients using this spec must have connected to gateway at least once.- See Also:
- Create Message
-
-
Constructor Summary
Constructors Constructor Description LegacyMessageCreateSpec()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description LegacyMessageCreateSpecaddEmbed(Consumer<? super LegacyEmbedCreateSpec> spec)Adds an embed to the message.LegacyMessageCreateSpecaddFile(String fileName, InputStream file)Adds a file as attachment to the createdMessage.LegacyMessageCreateSpecaddFileSpoiler(String fileName, InputStream file)Adds a spoiler file as attachment to the createdMessage.MultipartRequest<discord4j.discordjson.json.MessageCreateRequest>asRequest()LegacyMessageCreateSpecsetAllowedMentions(AllowedMentions allowedMentions)Sets an allowed mentions object to the message spec.LegacyMessageCreateSpecsetComponents(LayoutComponent... components)Sets the components of the message.LegacyMessageCreateSpecsetComponents(List<LayoutComponent> components)Sets the components of the message.LegacyMessageCreateSpecsetContent(String content)Sets the createdMessagecontents, up to 2000 characters.LegacyMessageCreateSpecsetEmbed(Consumer<? super LegacyEmbedCreateSpec> spec)Deprecated.UseaddEmbed(Consumer).LegacyMessageCreateSpecsetMessageReference(Snowflake messageId)Adds a message ID to reply to.LegacyMessageCreateSpecsetNonce(Snowflake nonce)Sets a nonce that can be used for optimistic message sending.LegacyMessageCreateSpecsetTts(boolean tts)Sets whether the createdMessageis a TTS message.
-
-
-
Method Detail
-
setContent
public LegacyMessageCreateSpec setContent(String content)
Sets the createdMessagecontents, up to 2000 characters.- Parameters:
content- The message contents.- Returns:
- This spec.
-
setNonce
public LegacyMessageCreateSpec setNonce(Snowflake nonce)
Sets a nonce that can be used for optimistic message sending.- Parameters:
nonce- An identifier.- Returns:
- This spec.
-
setTts
public LegacyMessageCreateSpec setTts(boolean tts)
Sets whether the createdMessageis a TTS message.- Parameters:
tts- If this message is a TTS message.- Returns:
- This spec.
-
setEmbed
@Deprecated public LegacyMessageCreateSpec setEmbed(Consumer<? super LegacyEmbedCreateSpec> spec)
Deprecated.UseaddEmbed(Consumer).Sets rich content to the createdMessagein the form of anEmbedobject.This method overrides any embeds added by
addEmbed(Consumer).- Parameters:
spec- AnLegacyEmbedCreateSpecconsumer used to attach rich content when creating a message.- Returns:
- This spec.
-
addEmbed
public LegacyMessageCreateSpec addEmbed(Consumer<? super LegacyEmbedCreateSpec> spec)
Adds an embed to the message.A message may have up to 10 embeds.
- Parameters:
spec- AnLegacyEmbedCreateSpecconsumer used to attach rich content when creating a message.- Returns:
- This spec.
-
addFile
public LegacyMessageCreateSpec 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 LegacyMessageCreateSpec 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 LegacyMessageCreateSpec setAllowedMentions(@Nullable AllowedMentions allowedMentions)
Sets an allowed mentions object to the message spec. Can benullto reset a configuration added by default.- Parameters:
allowedMentions- The allowed mentions to add.- Returns:
- This spec.
-
setMessageReference
public LegacyMessageCreateSpec setMessageReference(Snowflake messageId)
Adds a message ID to reply to. This requires thePermission.READ_MESSAGE_HISTORYpermission, 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 LegacyMessageCreateSpec setComponents(LayoutComponent... components)
Sets the components of the message.- Parameters:
components- The message components.- Returns:
- This spec.
-
setComponents
public LegacyMessageCreateSpec setComponents(List<LayoutComponent> components)
Sets the components of the message.- Parameters:
components- The message components.- Returns:
- This spec.
-
asRequest
public MultipartRequest<discord4j.discordjson.json.MessageCreateRequest> asRequest()
- Specified by:
asRequestin interfaceLegacySpec<MultipartRequest<discord4j.discordjson.json.MessageCreateRequest>>
-
-