MessageDraft object
MessageDraft
is an object that refers to a single message that has not been published yet. Message drafts allow you to mention users, reference channels, and add URLs to a message.
Properties
The MessageDraft
object has no properties.
Events
The MessageDraft
object has the following events:
// Event triggered when a message draft is updated
public event Action<List<MessageElement>, List<SuggestedMention>> OnDraftUpdated;
Example
Insert suggested mentions when updating a message draft.
messageDraft.SetSearchForSuggestions(true);
messageDraft.OnDraftUpdated += (elements, mentions) =>
{
if (!mentions.Any())
{
return;
}
messageDraft.InsertSuggestedMention(mentions[0], mentions[0].ReplaceTo);
};
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
For example, you can use the MessageDraft
object methods to let users work on the created draft messages to prepare the final content. They can enrich that content with links, mention other channel members with @
, or reference channels with #
.