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}
| Parameter | Description |
|---|---|
TextType: string | The current text of the draft. |
MessageElementsType: List<MessageElement> | The current message elements. |
ShouldSearchForSuggestionsType: bool | Whether the MessageDraft should search for suggestions whenever the text is changed. |
FilesType: List<ChatInputFile> | List of files to attach to the message. Refer to Files for more details. |
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.
AddMention()RemoveMention()InsertText()RemoveText()InsertSuggestedMention()Send()Update()- Add a message draft listener
- Remove a message draft listener
Use case
MessageDraft methods enable users to prepare draft messages with:
- Links
- User mentions with
@ - Channel references with
#