MessageBuilder class Null safety
Allows to create pre built custom messages which can be passed to classes which inherits from ISend.
Constructors
-
MessageBuilder({String? content = '', AllowedMentions? allowedMentions, List<
AttachmentMetadataBuilder> ? attachments, List<EmbedBuilder> ? embeds, List<AttachmentBuilder> ? files, String? nonce, ReplyBuilder? replyBuilder, bool? tts}) - Generic constructor for MessageBuilder
- MessageBuilder.content(String content)
-
Creates MessageBuilder with only content
factory
- MessageBuilder.embed(EmbedBuilder embed)
-
Creates MessageBuilder with only embed
factory
- MessageBuilder.empty()
-
Creates MessageBuilder with content of empty character
factory
-
MessageBuilder.files(List<
AttachmentBuilder> files) -
Creates MessageBuilder with only specified files
factory
- MessageBuilder.fromMessage(IMessage message)
-
Creates MessageBuilder from
Message
. Copies content, tts and first embed of targetmessage
factory
Properties
- allowedMentions ↔ AllowedMentions?
-
AllowedMentions object to control mentions in message
read / write
-
attachments
↔ List<
AttachmentMetadataBuilder> ? -
List of attachments to send with message
read / write
- content ↔ String
-
Returns current content of message
read / write
-
embeds
↔ List<
EmbedBuilder> ? -
Embed to include in message
read / write
-
files
↔ List<
AttachmentBuilder> ? -
List of files to send with message
read / write
- flags ↔ MessageFlagBuilder?
-
Flags to attach to message
read / write
- hashCode → int
-
The hash code for this object.
read-onlyinherited
- nonce ↔ String?
-
A nonce that can be used for optimistic message sending (up to 25 characters)
You will be able to identify that message when receiving it through gateway
read / write
- replyBuilder ↔ ReplyBuilder?
-
Allows to create message that replies to another message
read / write
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
- tts ↔ bool?
-
Set to true if message should be TTS
read / write
Methods
-
addAttachment(
AttachmentBuilder attachment) → void - Add attachment
-
addBytesAttachment(
List< int> bytes, String name, {bool spoiler = false}) → void - Add attachment from specified bytes
-
addEmbed(
FutureOr< void> builder(EmbedBuilder embed)) → FutureOr<void> - Allows to add embed to message. Warning: Completes future synchronously!
-
addFileAttachment(
File file, {String? name, bool spoiler = false}) → void - Add attachment from specified file
-
addPathAttachment(
String path, {String? name, bool spoiler = false}) → void - Add attachment at specified path
-
append(
Object text) → void - Allows to append
-
appendBold(
Object text) → void - Appends bold text to message
-
appendClearCharacter(
) → void - Appends clear character. Can be used to skip first line in message body.
-
appendCode(
Object language, Object code) → void - Appends code block to message
-
appendCodeSimple(
Object text) → void - Appends simple code to message
-
appendItalics(
Object text) → void - Appends italic text to message
-
appendMention(
Mentionable mentionable) → void - Appends Mentionable object to message
-
appendNewLine(
) → void - Appends empty line to message
-
appendSpoiler(
Object text) → void - Appends spoiler to message
-
appendStrike(
Object text) → void - Appends strikeout text to message
-
appendTimestamp(
DateTime dateTime, {TimeStampStyle style = TimeStampStyle.def}) → void -
Appends timestamp to message from
dateTime
-
appendWithDecoration(
Object text, MessageDecoration decoration) → void - Appends formatted text to message
-
build(
[AllowedMentions? defaultAllowedMentions]) → RawApiMap -
canBeUsedAsNewMessage(
) → bool - Returns if this instance of message builder can be used when editing message
-
getMappedFiles(
) → Iterable< MultipartFile> -
hasFiles(
) → bool -
limitLength(
{int length = 2000, String? ellipsis = '...'}) → void -
Limits the length of the content of the builder to
length
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited
-
send(
ISend entity) → Future< IMessage> - Sends message
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- clearCharacter → const String
-
Clear character which can be used to skip first line in message body or sanitize message content
""