MessageDraftV2 object

MessageDraftV2 is an object that refers to a single message that has not been published yet.

Message draft versions

The message draft feature comes in two versions. Although version 1 is not deprecated, we recommend that you use version 2.

Version 2 lets you work with user mentions, channel references, and links (collectively called "message elements") in a more generic manner than version 1. For more information on message drafts, refer to Drafts (v2) and Drafts (v1).

The MessageDraftV2 object has the following properties:

class MessageDraftV2 {
channel: Channel,
value: string,
quotedMessage?: Message,
config: MessageDraftConfig,
files?: FileList | File[] | SendFileParameters["file"][];
}
ParameterTypeDescription
channelChannelThe channel the draft message is being created on.
valuestringMessage that includes mentions.
quotedMessageMessage or undefinedObject added to a draft message when you quote another message.
configMessageDraftConfigConfiguration of the message containing mentions - what is the user source (channel members or app's keyset users), whether the typing indicator is enabled, and what is the maximum number of user names mentioned in one message (the default value is 10 and max is 100).
filesFileList or File[] or SendFileParameters["file"][], or undefinedOne or multiple files attached to the draft text message. They can take the form of a read-only files property of the HTML <input /> element (when a user has selected one or more files from their device), or through a drag-and-drop operation (FileList). Alternatively, that can be an array of file objects (File[]) or PubNub-specific `SendFileParameters["file"][].
icon

Message draft configuration


Methods


You can call the following methods on the MessageDraft object.

Click on each method for more details.

Use case

For example, you can use the MessageDraftV2 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 #.

Last updated on
On this page