Class RestMessage
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
JsonMessageclient
RestClient
Properties
Activity
Sent with Rich Presence-related chat embeds.
public MessageActivity? Activity { get; }
Property Value
Application
Sent with Rich Presence-related chat embeds.
public Application? Application { get; }
Property Value
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
Attachments
A list of Attachment objects indexed by their IDs, containing any files attached in the message.
public IReadOnlyList<Attachment> Attachments { get; }
Property Value
Author
The User object of the message's author.
public User Author { get; }
Property Value
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
ChannelId
The ID of the channel the message was sent in.
public ulong ChannelId { get; }
Property Value
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
Content
The text contents of the message.
public string Content { get; }
Property Value
EditedAt
When the message was edited (or null if never).
public DateTimeOffset? EditedAt { get; }
Property Value
Embeds
A list of Embed objects containing any embedded content present in the message.
public IReadOnlyList<Embed> Embeds { get; }
Property Value
Flags
A MessageFlags object indicating the message's applied flags.
public MessageFlags Flags { get; }
Property Value
Id
The ID of the message.
public override ulong Id { get; }
Property Value
Interaction
Sent if the message is a response to an IInteraction.
[Obsolete("Replaced by 'InteractionMetadata'")]
public MessageInteraction? Interaction { get; }
Property Value
InteractionMetadata
Sent if the message is sent as a result of an IInteraction.
public MessageInteractionMetadata? InteractionMetadata { get; }
Property Value
IsPinned
Whether this message is pinned in a channel.
public bool IsPinned { get; }
Property Value
IsTts
Whether the message was a Text-To-Speech message.
public bool IsTts { get; }
Property Value
MentionEveryone
Whether the message mentions @everyone.
public bool MentionEveryone { get; }
Property Value
MentionedChannels
A list of GuildChannelMention objects indexed by their IDs, containing channels specifically mentioned in the message.
public IReadOnlyList<GuildChannelMention> MentionedChannels { get; }
Property Value
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
MentionedUsers
A list of User objects indexed by their IDs, containing users specifically mentioned in the message.
public IReadOnlyList<User> MentionedUsers { get; }
Property Value
MessageReference
Contains data showing the source of a crosspost, channel follow add, pin, or message reply.
public MessageReference? MessageReference { get; }
Property Value
MessageSnapshots
A list of messages associated with the message reference.
public IReadOnlyList<MessageSnapshot> MessageSnapshots { get; }
Property Value
Nonce
Used for validating that a message was sent.
public string? Nonce { get; }
Property Value
Poll
public MessagePoll? Poll { get; }
Property Value
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
ReferencedMessage
The message associated with the MessageReference.
public RestMessage? ReferencedMessage { get; }
Property Value
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
RoleSubscriptionData
Data of the role subscription purchase or renewal that prompted this RoleSubscriptionPurchase message.
public RoleSubscriptionData? RoleSubscriptionData { get; }
Property Value
StartedThread
The GuildThread that was started from this message.
public GuildThread? StartedThread { get; }
Property Value
Stickers
Contains stickers contained in the message, if any.
public IReadOnlyList<MessageSticker> Stickers { get; }
Property Value
Type
The type of the message.
public MessageType Type { get; }
Property Value
WebhookId
If the message was generated by a Webhook, this is the webhook's ID.
public ulong? WebhookId { get; }
Property Value
Methods
AddReactionAsync(ReactionEmojiProperties, RestRequestProperties?, CancellationToken)
public Task AddReactionAsync(ReactionEmojiProperties emoji, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
emoji
ReactionEmojiPropertiesproperties
RestRequestPropertiescancellationToken
CancellationToken
Returns
CreateGuildThreadAsync(GuildThreadFromMessageProperties, RestRequestProperties?, CancellationToken)
public Task<GuildThread> CreateGuildThreadAsync(GuildThreadFromMessageProperties threadFromMessageProperties, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
threadFromMessageProperties
GuildThreadFromMessagePropertiesproperties
RestRequestPropertiescancellationToken
CancellationToken
Returns
CrosspostAsync(RestRequestProperties?, CancellationToken)
public Task<RestMessage> CrosspostAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
properties
RestRequestPropertiescancellationToken
CancellationToken
Returns
DeleteAllReactionsAsync(ReactionEmojiProperties, RestRequestProperties?, CancellationToken)
public Task DeleteAllReactionsAsync(ReactionEmojiProperties emoji, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
emoji
ReactionEmojiPropertiesproperties
RestRequestPropertiescancellationToken
CancellationToken
Returns
DeleteAllReactionsAsync(RestRequestProperties?, CancellationToken)
public Task DeleteAllReactionsAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
properties
RestRequestPropertiescancellationToken
CancellationToken
Returns
DeleteAsync(RestRequestProperties?, CancellationToken)
public Task DeleteAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
properties
RestRequestPropertiescancellationToken
CancellationToken
Returns
DeleteReactionAsync(ReactionEmojiProperties, RestRequestProperties?, CancellationToken)
public Task DeleteReactionAsync(ReactionEmojiProperties emoji, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
emoji
ReactionEmojiPropertiesproperties
RestRequestPropertiescancellationToken
CancellationToken
Returns
DeleteReactionAsync(ReactionEmojiProperties, ulong, RestRequestProperties?, CancellationToken)
public Task DeleteReactionAsync(ReactionEmojiProperties emoji, ulong userId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
emoji
ReactionEmojiPropertiesuserId
ulongproperties
RestRequestPropertiescancellationToken
CancellationToken
Returns
EndPollAsync(RestRequestProperties?, CancellationToken)
public Task<RestMessage> EndPollAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
properties
RestRequestPropertiescancellationToken
CancellationToken
Returns
GetAsync(RestRequestProperties?, CancellationToken)
public Task<RestMessage> GetAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
properties
RestRequestPropertiescancellationToken
CancellationToken
Returns
GetPollAnswerVotersAsync(int, PaginationProperties<ulong>?, RestRequestProperties?)
public IAsyncEnumerable<User> GetPollAnswerVotersAsync(int answerId, PaginationProperties<ulong>? paginationProperties = null, RestRequestProperties? properties = null)
Parameters
answerId
intpaginationProperties
PaginationProperties<ulong>properties
RestRequestProperties
Returns
GetReactionsAsync(ReactionEmojiProperties, MessageReactionsPaginationProperties?, RestRequestProperties?)
public IAsyncEnumerable<User> GetReactionsAsync(ReactionEmojiProperties emoji, MessageReactionsPaginationProperties? paginationProperties = null, RestRequestProperties? properties = null)
Parameters
emoji
ReactionEmojiPropertiespaginationProperties
MessageReactionsPaginationPropertiesproperties
RestRequestProperties
Returns
ModifyAsync(Action<MessageOptions>, RestRequestProperties?, CancellationToken)
public Task<RestMessage> ModifyAsync(Action<MessageOptions> action, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
action
Action<MessageOptions>properties
RestRequestPropertiescancellationToken
CancellationToken
Returns
PinAsync(RestRequestProperties?, CancellationToken)
public Task PinAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
properties
RestRequestPropertiescancellationToken
CancellationToken
Returns
ReplyAsync(ReplyMessageProperties, RestRequestProperties?, CancellationToken)
public Task<RestMessage> ReplyAsync(ReplyMessageProperties replyMessage, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
replyMessage
ReplyMessagePropertiesproperties
RestRequestPropertiescancellationToken
CancellationToken
Returns
SendAsync(MessageProperties, RestRequestProperties?, CancellationToken)
public Task<RestMessage> SendAsync(MessageProperties message, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
message
MessagePropertiesproperties
RestRequestPropertiescancellationToken
CancellationToken
Returns
UnpinAsync(RestRequestProperties?, CancellationToken)
public Task UnpinAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
properties
RestRequestPropertiescancellationToken
CancellationToken