Search Results for

    Show / Hide Table of Contents

    Interface IMessage

    Represents a message object.

    Inherited Members
    ISnowflakeEntity.CreatedAt
    IEntity<UInt64>.Id
    IDeletable.DeleteAsync(RequestOptions)
    Namespace: Discord
    Assembly: Discord.Net.Core.dll
    Syntax
    public interface IMessage : ISnowflakeEntity, IEntity<ulong>, IDeletable

    Properties

    | Improve this Doc View Source

    Activity

    Gets the activity associated with a message.

    Declaration
    MessageActivity Activity { get; }
    Property Value
    Type Description
    MessageActivity

    A message's activity, if any is associated.

    Remarks

    Sent with Rich Presence-related chat embeds. This often refers to activity that requires end-user's interaction, such as a Spotify Invite activity.

    | Improve this Doc View Source

    Application

    Gets the application associated with a message.

    Declaration
    MessageApplication Application { get; }
    Property Value
    Type Description
    MessageApplication

    A message's application, if any is associated.

    Remarks

    Sent with Rich-Presence-related chat embeds.

    | Improve this Doc View Source

    Attachments

    Gets all attachments included in this message.

    Declaration
    IReadOnlyCollection<IAttachment> Attachments { get; }
    Property Value
    Type Description
    IReadOnlyCollection<IAttachment>

    A read-only collection of attachments.

    Remarks

    This property gets a read-only collection of attachments associated with this message. Depending on the user's end-client, a sent message may contain one or more attachments. For example, mobile users may attach more than one file in their message, while the desktop client only allows for one.

    | Improve this Doc View Source

    Author

    Gets the author of this message.

    Declaration
    IUser Author { get; }
    Property Value
    Type Description
    IUser
    | Improve this Doc View Source

    Channel

    Gets the source channel of the message.

    Declaration
    IMessageChannel Channel { get; }
    Property Value
    Type Description
    IMessageChannel
    | Improve this Doc View Source

    CleanContent

    Gets the clean content for this message.

    Declaration
    string CleanContent { get; }
    Property Value
    Type Description
    String

    A string that contains the body of the message stripped of mentions, markdown, emojis and pings; note that this field may be empty if there is an embed.

    Remarks

    This will be empty if the privileged MessageContent is disabled.

    | Improve this Doc View Source

    Components

    The IMessageComponent's attached to this message

    Declaration
    IReadOnlyCollection<IMessageComponent> Components { get; }
    Property Value
    Type Description
    IReadOnlyCollection<IMessageComponent>
    | Improve this Doc View Source

    Content

    Gets the content for this message.

    Declaration
    string Content { get; }
    Property Value
    Type Description
    String

    A string that contains the body of the message; note that this field may be empty if there is an embed.

    Remarks

    This will be empty if the privileged MessageContent is disabled.

    | Improve this Doc View Source

    EditedTimestamp

    Gets the time of this message's last edit.

    Declaration
    DateTimeOffset? EditedTimestamp { get; }
    Property Value
    Type Description
    Nullable<DateTimeOffset>

    Time of when the message was last edited; null if the message is never edited.

    | Improve this Doc View Source

    Embeds

    Gets all embeds included in this message.

    Declaration
    IReadOnlyCollection<IEmbed> Embeds { get; }
    Property Value
    Type Description
    IReadOnlyCollection<IEmbed>

    A read-only collection of embed objects.

    Remarks

    This property gets a read-only collection of embeds associated with this message. Depending on the message, a sent message may contain one or more embeds. This is usually true when multiple link previews are generated; however, only one Rich Embed can be featured.

    | Improve this Doc View Source

    Flags

    Gets the flags related to this message.

    Declaration
    MessageFlags? Flags { get; }
    Property Value
    Type Description
    Nullable<MessageFlags>

    A message's flags, if any is associated.

    Remarks

    This value is determined by bitwise OR-ing MessageFlags values together.

    | Improve this Doc View Source

    Interaction

    Gets the interaction this message is a response to.

    Declaration
    IMessageInteraction Interaction { get; }
    Property Value
    Type Description
    IMessageInteraction

    A IMessageInteraction if the message is a response to an interaction; otherwise null.

    | Improve this Doc View Source

    IsPinned

    Gets the value that indicates whether this message is pinned.

    Declaration
    bool IsPinned { get; }
    Property Value
    Type Description
    Boolean

    true if this message was added to its channel's pinned messages; otherwise false.

    | Improve this Doc View Source

    IsSuppressed

    Gets the value that indicates whether or not this message's embeds are suppressed.

    Declaration
    bool IsSuppressed { get; }
    Property Value
    Type Description
    Boolean

    true if the embeds in this message have been suppressed (made invisible); otherwise false.

    | Improve this Doc View Source

    IsTTS

    Gets the value that indicates whether this message was meant to be read-aloud by Discord.

    Declaration
    bool IsTTS { get; }
    Property Value
    Type Description
    Boolean

    true if this message was sent as a text-to-speech message; otherwise false.

    | Improve this Doc View Source

    MentionedChannelIds

    Gets the IDs of channels mentioned in this message.

    Declaration
    IReadOnlyCollection<ulong> MentionedChannelIds { get; }
    Property Value
    Type Description
    IReadOnlyCollection<UInt64>

    A read-only collection of channel IDs.

    | Improve this Doc View Source

    MentionedEveryone

    Gets the value that indicates whether this message mentioned everyone.

    Declaration
    bool MentionedEveryone { get; }
    Property Value
    Type Description
    Boolean

    true if this message mentioned everyone; otherwise false.

    | Improve this Doc View Source

    MentionedRoleIds

    Gets the IDs of roles mentioned in this message.

    Declaration
    IReadOnlyCollection<ulong> MentionedRoleIds { get; }
    Property Value
    Type Description
    IReadOnlyCollection<UInt64>

    A read-only collection of role IDs.

    | Improve this Doc View Source

    MentionedUserIds

    Gets the IDs of users mentioned in this message.

    Declaration
    IReadOnlyCollection<ulong> MentionedUserIds { get; }
    Property Value
    Type Description
    IReadOnlyCollection<UInt64>

    A read-only collection of user IDs.

    | Improve this Doc View Source

    Reactions

    Gets all reactions included in this message.

    Declaration
    IReadOnlyDictionary<IEmote, ReactionMetadata> Reactions { get; }
    Property Value
    Type Description
    IReadOnlyDictionary<IEmote, ReactionMetadata>
    | Improve this Doc View Source

    Reference

    Gets the reference to the original message if it is a crosspost, channel follow add, pin, or reply message.

    Declaration
    MessageReference Reference { get; }
    Property Value
    Type Description
    MessageReference

    A message's reference, if any is associated.

    Remarks

    Sent with cross-posted messages, meaning they were published from news channels and received by subscriber channels, channel follow adds, pins, and message replies.

    | Improve this Doc View Source

    Source

    Gets the source type of this message.

    Declaration
    MessageSource Source { get; }
    Property Value
    Type Description
    MessageSource
    | Improve this Doc View Source

    Stickers

    Gets all stickers items included in this message.

    Declaration
    IReadOnlyCollection<IStickerItem> Stickers { get; }
    Property Value
    Type Description
    IReadOnlyCollection<IStickerItem>

    A read-only collection of sticker item objects.

    | Improve this Doc View Source

    Tags

    Gets all tags included in this message's content.

    Declaration
    IReadOnlyCollection<ITag> Tags { get; }
    Property Value
    Type Description
    IReadOnlyCollection<ITag>
    | Improve this Doc View Source

    Timestamp

    Gets the time this message was sent.

    Declaration
    DateTimeOffset Timestamp { get; }
    Property Value
    Type Description
    DateTimeOffset

    Time of when the message was sent.

    | Improve this Doc View Source

    Type

    Gets the type of this message.

    Declaration
    MessageType Type { get; }
    Property Value
    Type Description
    MessageType

    Methods

    | Improve this Doc View Source

    AddReactionAsync(IEmote, RequestOptions)

    Adds a reaction to this message.

    Declaration
    Task AddReactionAsync(IEmote emote, RequestOptions options = null)
    Parameters
    Type Name Description
    IEmote emote

    The emoji used to react to this message.

    RequestOptions options

    The options to be used when sending the request.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation for adding a reaction to this message.

    Examples

    The following example adds the reaction, 💕, to the message.

    await msg.AddReactionAsync(new Emoji("\U0001f495"));
    See Also
    IEmote
    | Improve this Doc View Source

    GetReactionUsersAsync(IEmote, Int32, RequestOptions)

    Gets all users that reacted to a message with a given emote.

    Declaration
    IAsyncEnumerable<IReadOnlyCollection<IUser>> GetReactionUsersAsync(IEmote emoji, int limit, RequestOptions options = null)
    Parameters
    Type Name Description
    IEmote emoji

    The emoji that represents the reaction that you wish to get.

    Int32 limit

    The number of users to request.

    RequestOptions options

    The options to be used when sending the request.

    Returns
    Type Description
    IAsyncEnumerable<IReadOnlyCollection<IUser>>

    Paged collection of users.

    Remarks

    important

    The returned collection is an asynchronous enumerable object; one must call FlattenAsync<T>(IAsyncEnumerable<IEnumerable<T>>) to access the users as a collection.

    warning

    Do not fetch too many users at once! This may cause unwanted preemptive rate limit or even actual rate limit, causing your bot to freeze!

    This method will attempt to fetch the number of reactions specified under limit. The library will attempt to split up the requests according to your limit and MaxUserReactionsPerBatch. In other words, should the user request 500 reactions, and the MaxUserReactionsPerBatch constant is 100, the request will be split into 5 individual requests; thus returning 5 individual asynchronous responses, hence the need of flattening.

    Examples

    The following example gets the users that have reacted with the emoji 💕 to the message.

    var emoji = new Emoji("\U0001f495");
    var reactedUsers = await message.GetReactionUsersAsync(emoji, 100).FlattenAsync();
    | Improve this Doc View Source

    RemoveAllReactionsAsync(RequestOptions)

    Removes all reactions from this message.

    Declaration
    Task RemoveAllReactionsAsync(RequestOptions options = null)
    Parameters
    Type Name Description
    RequestOptions options

    The options to be used when sending the request.

    Returns
    Type Description
    Task

    A task that represents the asynchronous removal operation.

    | Improve this Doc View Source

    RemoveAllReactionsForEmoteAsync(IEmote, RequestOptions)

    Removes all reactions with a specific emoji from this message.

    Declaration
    Task RemoveAllReactionsForEmoteAsync(IEmote emote, RequestOptions options = null)
    Parameters
    Type Name Description
    IEmote emote

    The emoji used to react to this message.

    RequestOptions options

    The options to be used when sending the request.

    Returns
    Type Description
    Task

    A task that represents the asynchronous removal operation.

    | Improve this Doc View Source

    RemoveReactionAsync(IEmote, IUser, RequestOptions)

    Removes a reaction from message.

    Declaration
    Task RemoveReactionAsync(IEmote emote, IUser user, RequestOptions options = null)
    Parameters
    Type Name Description
    IEmote emote

    The emoji used to react to this message.

    IUser user

    The user that added the emoji.

    RequestOptions options

    The options to be used when sending the request.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation for removing a reaction to this message.

    Examples

    The following example removes the reaction, 💕, added by the message author from the message.

    await msg.RemoveReactionAsync(new Emoji("\U0001f495"), msg.Author);
    See Also
    IEmote
    | Improve this Doc View Source

    RemoveReactionAsync(IEmote, UInt64, RequestOptions)

    Removes a reaction from message.

    Declaration
    Task RemoveReactionAsync(IEmote emote, ulong userId, RequestOptions options = null)
    Parameters
    Type Name Description
    IEmote emote

    The emoji used to react to this message.

    UInt64 userId

    The ID of the user that added the emoji.

    RequestOptions options

    The options to be used when sending the request.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation for removing a reaction to this message.

    Examples

    The following example removes the reaction, 💕, added by the user with ID 84291986575613952 from the message.

    await msg.RemoveReactionAsync(new Emoji("\U0001f495"), 84291986575613952);
    See Also
    IEmote

    Extension Methods

    MessageExtensions.GetJumpUrl(IMessage)

    Theme

    • Improve this Doc
    • View Source
    In This Article
    Back to top Discord.Net (c) 2015-2022 3.9.0