On this page

MessageDraft object

MessageDraft represents a message that has not been published yet. Message drafts allow you to mention users, reference channels, and add URLs to a message.

Properties

MessageDraft has the following properties:

1public class MessageDraft
2{
3 public string Text { get; }
4 public List<MessageElement> MessageElements { get; }
5 public bool ShouldSearchForSuggestions { get; set; }
6 public List<ChatInputFile> Files { get; set; }
7 public Message QuotedMessage { get; set; }
8}
ParameterDescription
Text
Type: string
The current text of the draft.
MessageElements
Type: List<MessageElement>
The current message elements.
ShouldSearchForSuggestions
Type: bool
Whether the MessageDraft should search for suggestions whenever the text is changed.
Files
Type: List<ChatInputFile>
List of files to attach to the message. Refer to Files for more details.
QuotedMessage
Type: Message
A message to quote in this draft. When set, the sent message will include the quoted message metadata.

Events

The MessageDraft object has the following events:

1// Event triggered when a message draft is updated
2public event Action<List<MessageElement>, List<SuggestedMention>> OnDraftUpdated;

Example

Insert suggested mentions when updating a message draft.

1

Methods

You can call the following methods on the MessageDraft object.

Click on each method for more details.

Standard methods

Streaming methods

Real-time updates are delivered via a C# event listener that you subscribe to directly. The OnDraftUpdated event fires each time the draft content changes.

Use case

MessageDraft methods enable users to prepare draft messages with: