Class SocketUserMessage
Represents a WebSocket-based message sent by a user.
public class SocketUserMessage : SocketMessage, IUserMessage, IMessage, ISnowflakeEntity, IEntity<ulong>, IDeletable
- Inheritance
-
SocketUserMessage
- Implements
- Inherited Members
- Extension Methods
Properties
Attachments
Returns all attachments included in this message.
public override IReadOnlyCollection<Attachment> Attachments { get; }
Property Value
- IReadOnlyCollection<Attachment>
Collection of attachments.
EditedTimestamp
Gets the time of this message's last edit.
public override DateTimeOffset? EditedTimestamp { get; }
Property Value
- DateTimeOffset?
Time of when the message was last edited; null if the message is never edited.
Embeds
Returns all embeds included in this message.
public override IReadOnlyCollection<Embed> Embeds { get; }
Property Value
- IReadOnlyCollection<Embed>
Collection of embed objects.
ForwardedMessages
Gets a collection of partial messages that were forwarded with this message.
public IReadOnlyCollection<MessageSnapshot> ForwardedMessages { get; }
Property Value
InteractionMetadata
Gets the interaction metadata for the interaction this message is a response to.
public IMessageInteractionMetadata InteractionMetadata { get; }
Property Value
Remarks
Will be null if the message is not a response to an interaction.
IsPinned
Gets the value that indicates whether this message is pinned.
public override bool IsPinned { get; }
Property Value
IsSuppressed
Gets the value that indicates whether or not this message's embeds are suppressed.
public override bool IsSuppressed { get; }
Property Value
IsTTS
Gets the value that indicates whether this message was meant to be read-aloud by Discord.
public override bool IsTTS { get; }
Property Value
MentionedChannels
Returns the channels mentioned in this message.
public override IReadOnlyCollection<SocketGuildChannel> MentionedChannels { get; }
Property Value
- IReadOnlyCollection<SocketGuildChannel>
Collection of WebSocket-based guild channels.
MentionedEveryone
Gets the value that indicates whether this message mentioned everyone.
public override bool MentionedEveryone { get; }
Property Value
MentionedRoleIds
Gets the IDs of roles mentioned in this message.
public override IReadOnlyCollection<ulong> MentionedRoleIds { get; }
Property Value
- IReadOnlyCollection<ulong>
A read-only collection of role IDs.
MentionedRoles
Returns the roles mentioned in this message.
public override IReadOnlyCollection<SocketRole> MentionedRoles { get; }
Property Value
- IReadOnlyCollection<SocketRole>
Collection of WebSocket-based roles.
Remarks
This collection may be missing values due to the guild being missing from cache (i.e. in user app interaction context). In that case you can use the MentionedRoleIds property.
Poll
Gets the poll sent with this message.
public Poll? Poll { get; }
Property Value
- Poll?
Remarks
Will be null if the message has no poll.
ReferencedMessage
Gets the referenced message if it is a crosspost, channel follow add, pin, or reply message.
public IUserMessage ReferencedMessage { get; }
Property Value
- IUserMessage
The referenced message, if any is associated and still exists.
ResolvedData
Gets the resolved data if the message has components. null otherwise.
public MessageResolvedData ResolvedData { get; }
Property Value
Stickers
public override IReadOnlyCollection<SocketSticker> Stickers { get; }
Property Value
Tags
Gets all tags included in this message's content.
public override IReadOnlyCollection<ITag> Tags { get; }
Property Value
Methods
CrosspostAsync(RequestOptions)
Publishes (crossposts) this message.
public Task CrosspostAsync(RequestOptions options = null)
Parameters
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task
A task that represents the asynchronous operation for publishing this message.
Remarks
warning
This call will throw an InvalidOperationException if attempted in a non-news channel.
Exceptions
- InvalidOperationException
This operation may only be called on a INewsChannel channel.
EndPollAsync(RequestOptions)
Immediately ends the poll.
public Task EndPollAsync(RequestOptions options = null)
Parameters
options
RequestOptionsThe options to be used when sending the request.
Returns
Remarks
You cannot end polls from other users.
GetPollAnswerVotersAsync(uint, int?, ulong?, RequestOptions)
Get users that voted for this specific answer.
public IAsyncEnumerable<IReadOnlyCollection<IUser>> GetPollAnswerVotersAsync(uint answerId, int? limit = null, ulong? afterId = null, RequestOptions options = null)
Parameters
answerId
uintThe id on the answer to fetch voters for
limit
int?The number of users to request.
afterId
ulong?The id of a user to start after.
options
RequestOptionsThe options to be used when sending the request.
Returns
ModifyAsync(Action<MessageProperties>, RequestOptions)
Modifies this message.
public Task ModifyAsync(Action<MessageProperties> func, RequestOptions options = null)
Parameters
func
Action<MessageProperties>A delegate containing the properties to modify the message with.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task
A task that represents the asynchronous modification operation.
Examples
The following example replaces the content of the message with Hello World!
.
await msg.ModifyAsync(x => x.Content = "Hello World!");
Remarks
This method modifies this message with the specified properties. To see an example of this method and what properties are available, please refer to MessageProperties.
Exceptions
- InvalidOperationException
Only the author of a message may modify the message.
- ArgumentOutOfRangeException
Message content is too long, length must be less or equal to MaxMessageSize.
PinAsync(RequestOptions)
Adds this message to its channel's pinned messages.
public Task PinAsync(RequestOptions options = null)
Parameters
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task
A task that represents the asynchronous operation for pinning this message.
Resolve(TagHandling, TagHandling, TagHandling, TagHandling, TagHandling)
Transforms this message's text into a human-readable form by resolving its tags.
public string Resolve(TagHandling userHandling = TagHandling.Name, TagHandling channelHandling = TagHandling.Name, TagHandling roleHandling = TagHandling.Name, TagHandling everyoneHandling = TagHandling.Ignore, TagHandling emojiHandling = TagHandling.Name)
Parameters
userHandling
TagHandlingDetermines how the user tag should be handled.
channelHandling
TagHandlingDetermines how the channel tag should be handled.
roleHandling
TagHandlingDetermines how the role tag should be handled.
everyoneHandling
TagHandlingDetermines how the @everyone tag should be handled.
emojiHandling
TagHandlingDetermines how the emoji tag should be handled.
Returns
Resolve(int, TagHandling, TagHandling, TagHandling, TagHandling, TagHandling)
public string Resolve(int startIndex, TagHandling userHandling = TagHandling.Name, TagHandling channelHandling = TagHandling.Name, TagHandling roleHandling = TagHandling.Name, TagHandling everyoneHandling = TagHandling.Ignore, TagHandling emojiHandling = TagHandling.Name)
Parameters
startIndex
intuserHandling
TagHandlingchannelHandling
TagHandlingroleHandling
TagHandlingeveryoneHandling
TagHandlingemojiHandling
TagHandling
Returns
UnpinAsync(RequestOptions)
Removes this message from its channel's pinned messages.
public Task UnpinAsync(RequestOptions options = null)
Parameters
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task
A task that represents the asynchronous operation for unpinning this message.