Table of Contents

Class RestMessage

Namespace
NetCord.Rest
Assembly
NetCord.dll

Represents a message sent in a channel within Discord.

public class RestMessage : ClientEntity, IEntity, ISpanFormattable, IFormattable, IEquatable<Entity>, IJsonModel<JsonMessage>
Inheritance
RestMessage
Implements
Derived
Inherited Members

Constructors

RestMessage(JsonMessage, RestClient)

public RestMessage(JsonMessage jsonModel, RestClient client)

Parameters

jsonModel JsonMessage
client RestClient

Properties

Activity

Sent with Rich Presence-related chat embeds.

public MessageActivity? Activity { get; }

Property Value

MessageActivity

Application

Sent with Rich Presence-related chat embeds.

public Application? Application { get; }

Property Value

Application

ApplicationId

If the message is an IInteraction response/followup or an application-owned Webhook, the ID of the Application.

public ulong? ApplicationId { get; }

Property Value

ulong?

Attachments

A list of Attachment objects indexed by their IDs, containing any files attached in the message.

public IReadOnlyList<Attachment> Attachments { get; }

Property Value

IReadOnlyList<Attachment>

Author

The User object of the message's author.

public User Author { get; }

Property Value

User

Remarks

The author object follows the structure of the user object, but is only a valid user in the case where the message is generated by a user or bot user. If the message is generated by a Webhook, the author object corresponds to the webhook's id, username, and avatar. You can tell if a message is generated by a webhook by checking for the WebhookId on the message object.

Call

public MessageCall? Call { get; }

Property Value

MessageCall

ChannelId

The ID of the channel the message was sent in.

public ulong ChannelId { get; }

Property Value

ulong

Components

A list of IComponent objects, contains components like Buttons, ActionRows, or other interactive components if any are present.

public IReadOnlyList<IComponent> Components { get; }

Property Value

IReadOnlyList<IComponent>

Content

The text contents of the message.

public string Content { get; }

Property Value

string

EditedAt

When the message was edited (or null if never).

public DateTimeOffset? EditedAt { get; }

Property Value

DateTimeOffset?

Embeds

A list of Embed objects containing any embedded content present in the message.

public IReadOnlyList<Embed> Embeds { get; }

Property Value

IReadOnlyList<Embed>

Flags

A MessageFlags object indicating the message's applied flags.

public MessageFlags Flags { get; }

Property Value

MessageFlags

Id

The ID of the message.

public override ulong Id { get; }

Property Value

ulong

Interaction

Sent if the message is a response to an IInteraction.

[Obsolete("Replaced by 'InteractionMetadata'")]
public MessageInteraction? Interaction { get; }

Property Value

MessageInteraction

InteractionMetadata

Sent if the message is sent as a result of an IInteraction.

public MessageInteractionMetadata? InteractionMetadata { get; }

Property Value

MessageInteractionMetadata

IsPinned

Whether this message is pinned in a channel.

public bool IsPinned { get; }

Property Value

bool

IsTts

Whether the message was a Text-To-Speech message.

public bool IsTts { get; }

Property Value

bool

MentionEveryone

Whether the message mentions @everyone.

public bool MentionEveryone { get; }

Property Value

bool

MentionedChannels

A list of GuildChannelMention objects indexed by their IDs, containing channels specifically mentioned in the message.

public IReadOnlyList<GuildChannelMention> MentionedChannels { get; }

Property Value

IReadOnlyList<GuildChannelMention>

Remarks

Not all channel mentions in a message will appear in MentionedChannels. Only TextChannels visible to everyone in a lurkable guild will ever be included. Only crossposted messages (via Channel Following) currently include MentionedChannels at all. If no Mentions in the message meet these requirements, this field will not be sent.

MentionedRoleIds

A list of IDs corresponding to roles specifically mentioned in the message.

public IReadOnlyList<ulong> MentionedRoleIds { get; }

Property Value

IReadOnlyList<ulong>

MentionedUsers

A list of User objects indexed by their IDs, containing users specifically mentioned in the message.

public IReadOnlyList<User> MentionedUsers { get; }

Property Value

IReadOnlyList<User>

MessageReference

Contains data showing the source of a crosspost, channel follow add, pin, or message reply.

public MessageReference? MessageReference { get; }

Property Value

MessageReference

MessageSnapshots

A list of messages associated with the message reference.

public IReadOnlyList<MessageSnapshot> MessageSnapshots { get; }

Property Value

IReadOnlyList<MessageSnapshot>

Nonce

Used for validating that a message was sent.

public string? Nonce { get; }

Property Value

string

Poll

public MessagePoll? Poll { get; }

Property Value

MessagePoll

Position

A generally increasing integer (there may be gaps or duplicates) that represents the approximate position of the message in a GuildThread. It can be used to estimate the relative position of the message in a thread in tandem with the TotalMessageSent property of the parent thread.

public int? Position { get; }

Property Value

int?

Reactions

A list of MessageReaction objects containing all reactions to the message.

public IReadOnlyList<MessageReaction> Reactions { get; }

Property Value

IReadOnlyList<MessageReaction>

ReferencedMessage

The message associated with the MessageReference.

public RestMessage? ReferencedMessage { get; }

Property Value

RestMessage

Remarks

This field is only returned for messages with a MessageType of Reply or ThreadStarterMessage. If the message is a reply but the ReferencedMessage field is not present, the backend did not attempt to fetch the message that was being replied to, so its state is unknown. If the field exists but is null, the referenced message was deleted.

ResolvedData

Data for Users, GuildUsers, IGuildChannels, and Roles in the message's auto-populated select Menus.

public InteractionResolvedData? ResolvedData { get; }

Property Value

InteractionResolvedData

RoleSubscriptionData

Data of the role subscription purchase or renewal that prompted this RoleSubscriptionPurchase message.

public RoleSubscriptionData? RoleSubscriptionData { get; }

Property Value

RoleSubscriptionData

StartedThread

The GuildThread that was started from this message.

public GuildThread? StartedThread { get; }

Property Value

GuildThread

Stickers

Contains stickers contained in the message, if any.

public IReadOnlyList<MessageSticker> Stickers { get; }

Property Value

IReadOnlyList<MessageSticker>

Type

The type of the message.

public MessageType Type { get; }

Property Value

MessageType

WebhookId

If the message was generated by a Webhook, this is the webhook's ID.

public ulong? WebhookId { get; }

Property Value

ulong?

Methods

AddReactionAsync(ReactionEmojiProperties, RestRequestProperties?, CancellationToken)

public Task AddReactionAsync(ReactionEmojiProperties emoji, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

emoji ReactionEmojiProperties
properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task

CreateGuildThreadAsync(GuildThreadFromMessageProperties, RestRequestProperties?, CancellationToken)

public Task<GuildThread> CreateGuildThreadAsync(GuildThreadFromMessageProperties threadFromMessageProperties, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

threadFromMessageProperties GuildThreadFromMessageProperties
properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task<GuildThread>

CrosspostAsync(RestRequestProperties?, CancellationToken)

public Task<RestMessage> CrosspostAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task<RestMessage>

DeleteAllReactionsAsync(ReactionEmojiProperties, RestRequestProperties?, CancellationToken)

public Task DeleteAllReactionsAsync(ReactionEmojiProperties emoji, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

emoji ReactionEmojiProperties
properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task

DeleteAllReactionsAsync(RestRequestProperties?, CancellationToken)

public Task DeleteAllReactionsAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task

DeleteAsync(RestRequestProperties?, CancellationToken)

public Task DeleteAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task

DeleteReactionAsync(ReactionEmojiProperties, RestRequestProperties?, CancellationToken)

public Task DeleteReactionAsync(ReactionEmojiProperties emoji, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

emoji ReactionEmojiProperties
properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task

DeleteReactionAsync(ReactionEmojiProperties, ulong, RestRequestProperties?, CancellationToken)

public Task DeleteReactionAsync(ReactionEmojiProperties emoji, ulong userId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

emoji ReactionEmojiProperties
userId ulong
properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task

EndPollAsync(RestRequestProperties?, CancellationToken)

public Task<RestMessage> EndPollAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task<RestMessage>

GetAsync(RestRequestProperties?, CancellationToken)

public Task<RestMessage> GetAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task<RestMessage>

GetPollAnswerVotersAsync(int, PaginationProperties<ulong>?, RestRequestProperties?)

public IAsyncEnumerable<User> GetPollAnswerVotersAsync(int answerId, PaginationProperties<ulong>? paginationProperties = null, RestRequestProperties? properties = null)

Parameters

answerId int
paginationProperties PaginationProperties<ulong>
properties RestRequestProperties

Returns

IAsyncEnumerable<User>

GetReactionsAsync(ReactionEmojiProperties, MessageReactionsPaginationProperties?, RestRequestProperties?)

public IAsyncEnumerable<User> GetReactionsAsync(ReactionEmojiProperties emoji, MessageReactionsPaginationProperties? paginationProperties = null, RestRequestProperties? properties = null)

Parameters

emoji ReactionEmojiProperties
paginationProperties MessageReactionsPaginationProperties
properties RestRequestProperties

Returns

IAsyncEnumerable<User>

ModifyAsync(Action<MessageOptions>, RestRequestProperties?, CancellationToken)

public Task<RestMessage> ModifyAsync(Action<MessageOptions> action, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

action Action<MessageOptions>
properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task<RestMessage>

PinAsync(RestRequestProperties?, CancellationToken)

public Task PinAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task

ReplyAsync(ReplyMessageProperties, RestRequestProperties?, CancellationToken)

public Task<RestMessage> ReplyAsync(ReplyMessageProperties replyMessage, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

replyMessage ReplyMessageProperties
properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task<RestMessage>

SendAsync(MessageProperties, RestRequestProperties?, CancellationToken)

public Task<RestMessage> SendAsync(MessageProperties message, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

message MessageProperties
properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task<RestMessage>

UnpinAsync(RestRequestProperties?, CancellationToken)

public Task UnpinAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task