Skip to main content

Interface ISocketMessageChannel

Represents a generic WebSocket-based channel that can send and receive messages.

Assembly: Discord.Net.WebSocket.dll​
View Source​
Declaration
public interface ISocketMessageChannel : IMessageChannel, IChannel, ISnowflakeEntity, IEntity<ulong>

Properties​

CachedMessages​

Gets all messages in this channel's cache.

View Source​
Declaration
IReadOnlyCollection<SocketMessage> CachedMessages { get; }

Methods​

SendMessageAsync(String, Boolean, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[])​

Sends a message to this message channel.

View Source​
Declaration
Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null)
Returns​

System.Threading.Tasks.Task<Discord.Rest.RestUserMessage>: A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.

Parameters​
TypeNameDescription
System.StringtextThe message to be sent.
System.BooleanisTTSDetermines whether the message should be read aloud by Discord or not.
Discord.EmbedembedThe Discord.EmbedType.Rich Discord.Embed to be sent.
Discord.RequestOptionsoptionsThe options to be used when sending the request.
Discord.AllowedMentionsallowedMentions

Specifies if notifications are sent for mentioned users and roles in the message <code data-dev-comment-type="paramref" class="paramref">text</code>. If null, all mentioned roles and users will be notified. | | Discord.MessageReference | messageReference | The message references to be included. Used to reply to specific messages. | | Discord.MessageComponent | component | The message components to be included with this message. Used for interactions. | | Discord.ISticker[] | stickers | A collection of stickers to send with the message. | | Discord.Embed[] | embeds | A array of Discord.Embeds to send with this response. Max 10. |

SendFileAsync(String, String, Boolean, Embed, RequestOptions, Boolean, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[])​

Sends a file to this message channel with an optional caption.

View Source​
Declaration
Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null)
Returns​

System.Threading.Tasks.Task<Discord.Rest.RestUserMessage>: A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.

Parameters​
TypeNameDescription
System.StringfilePathThe file path of the file.
System.StringtextThe message to be sent.
System.BooleanisTTSWhether the message should be read aloud by Discord or not.
Discord.EmbedembedThe Discord.EmbedType.Rich Discord.Embed to be sent.
Discord.RequestOptionsoptionsThe options to be used when sending the request.
System.BooleanisSpoilerWhether the message attachment should be hidden as a spoiler.
Discord.AllowedMentionsallowedMentions

Specifies if notifications are sent for mentioned users and roles in the message <code data-dev-comment-type="paramref" class="paramref">text</code>. If null, all mentioned roles and users will be notified. | | Discord.MessageReference | messageReference | The message references to be included. Used to reply to specific messages. | | Discord.MessageComponent | component | The message components to be included with this message. Used for interactions. | | Discord.ISticker[] | stickers | A collection of stickers to send with the file. | | Discord.Embed[] | embeds | A array of Discord.Embeds to send with this response. Max 10. |

SendFileAsync(Stream, String, String, Boolean, Embed, RequestOptions, Boolean, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[])​

Sends a file to this message channel with an optional caption.

View Source​
Declaration
Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null)
Returns​

System.Threading.Tasks.Task<Discord.Rest.RestUserMessage>: A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.

Parameters​
TypeNameDescription
System.IO.StreamstreamThe System.IO.Stream of the file to be sent.
System.StringfilenameThe name of the attachment.
System.StringtextThe message to be sent.
System.BooleanisTTSWhether the message should be read aloud by Discord or not.
Discord.EmbedembedThe Discord.EmbedType.Rich Discord.Embed to be sent.
Discord.RequestOptionsoptionsThe options to be used when sending the request.
System.BooleanisSpoilerWhether the message attachment should be hidden as a spoiler.
Discord.AllowedMentionsallowedMentions

Specifies if notifications are sent for mentioned users and roles in the message <code data-dev-comment-type="paramref" class="paramref">text</code>. If null, all mentioned roles and users will be notified. | | Discord.MessageReference | messageReference | The message references to be included. Used to reply to specific messages. | | Discord.MessageComponent | component | The message components to be included with this message. Used for interactions. | | Discord.ISticker[] | stickers | A collection of stickers to send with the file. | | Discord.Embed[] | embeds | A array of Discord.Embeds to send with this response. Max 10. |

GetCachedMessage(UInt64)​

Gets a cached message from this channel.

View Source​
Declaration
SocketMessage GetCachedMessage(ulong id)
Returns​

Discord.WebSocket.SocketMessage: A WebSocket-based message object; null if it does not exist in the cache or if caching is not enabled.

Parameters​
TypeNameDescription
System.UInt64idThe snowflake identifier of the message.

GetCachedMessages(Int32)​

Gets the last N cached messages from this message channel.

View Source​
Declaration
IReadOnlyCollection<SocketMessage> GetCachedMessages(int limit = 100)
Returns​

System.Collections.Generic.IReadOnlyCollection<Discord.WebSocket.SocketMessage>: A read-only collection of WebSocket-based messages.

Parameters​
TypeNameDescription
System.Int32limitThe number of messages to get.

GetCachedMessages(UInt64, Direction, Int32)​

Gets the last N cached messages starting from a certain message in this message channel.

View Source​
Declaration
IReadOnlyCollection<SocketMessage> GetCachedMessages(ulong fromMessageId, Direction dir, int limit = 100)
Returns​

System.Collections.Generic.IReadOnlyCollection<Discord.WebSocket.SocketMessage>: A read-only collection of WebSocket-based messages.

Parameters​
TypeNameDescription
System.UInt64fromMessageIdThe message ID to start the fetching from.
Discord.DirectiondirThe direction of which the message should be gotten from.
System.Int32limitThe number of messages to get.

GetCachedMessages(IMessage, Direction, Int32)​

Gets the last N cached messages starting from a certain message in this message channel.

View Source​
Declaration
IReadOnlyCollection<SocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = 100)
Returns​

System.Collections.Generic.IReadOnlyCollection<Discord.WebSocket.SocketMessage>: A read-only collection of WebSocket-based messages.

Parameters​
TypeNameDescription
Discord.IMessagefromMessageThe message to start the fetching from.
Discord.DirectiondirThe direction of which the message should be gotten from.
System.Int32limitThe number of messages to get.

GetPinnedMessagesAsync(RequestOptions)​

Gets a read-only collection of pinned messages in this channel.

View Source​
Declaration
Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
Returns​

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<Discord.Rest.RestMessage>>: A task that represents the asynchronous get operation for retrieving pinned messages in this channel. The task result contains a read-only collection of messages found in the pinned messages.

Parameters​
TypeNameDescription
Discord.RequestOptionsoptionsThe options to be used when sending the request.