Message object
Message is an object that refers to a single message published on a chat channel.
Properties
The Message object has the following properties:
public class Message : UniqueChatEntity {
public string Id { get; protected set; }
public string MessageText { get; }
public string OriginalMessageText { get; }
public string TimeToken { get; }
public string ChannelId { get; }
public string UserId { get; }
public string Meta { get; }
public bool IsDeleted { get; }
public List<User> MentionedUsers { get; }
public List<Channel> ReferencedChannels { get; }
public List<TextLink> TextLinks { get; }
public string MessageActions { get; }
public List<MessageAction> Reactions { get; }
}
| Parameter | Description |
|---|---|
IdType: string | Unique identifier for the message which is a message timetoken. |
MessageTextType: string | Text content of the message. This is the main content sent by the user. |
OriginalMessageTextType: string | Original text content of the message, before any edits. |
TimeTokenType: string | A timestamp that helps order messages in a conversation. |
ChannelIdType: string | Unique identifier for the channel or group in which the message was sent. |
UserIdType: string | Unique ID of the user who sent the message. Do not confuse this with the username of the user. |
MetaType: string | Extra information added to the message giving additional context. This object can be of any type and can consist of a list of key-value pairs. |
IsDeletedType: bool | Indicates whether the message has been deleted. If the message has been deleted, this property will be true. |
MentionedUsersType: List<User> | List of users mentioned in the message. |
ReferencedChannelsType: List<Channel> | List of channels referenced in the message. |
TextLinksType: List<TextLink> | List of links included in the message. |
MessageActionsType: string | Any action associated with the message (like edited or deleted). |
ReactionsType: List<MessageAction> | All message reactions added to the message by other users. |
Events
The Message object has the following event:
// Event triggered when a message is updated
public event Action<Message> OnMessageUpdated;
Example
An event that is triggered when a message is updated by the server.
message.OnMessageUpdated += (message) =>
{
Console.WriteLine("Message was edited!");
};
Methods
You can call the following methods on the Message object.
Click on each method for more details.
AddListenerToMessagesUpdate()CreateThread()Delete()IsDeletedHasThread()EditMessageText()Forward()TryGetThread()ReferencedChannelsHasUserReaction()ToggleReaction()Pin()TryGetQuotedMessage()Reactions()removeThread()Report()Restore()OnMessageUpdatedMessageTextSetListeningForUpdates()TextLinks
Use case
For example, you can use the Message object methods to: