Interface ISocketMessageChannel
Represents a generic WebSocket-based channel that can send and receive messages.
Inherited Members
Namespace: Discord.WebSocket
Assembly: Discord.Net.WebSocket.dll
Syntax
public interface ISocketMessageChannel : IMessageChannel, IChannel, ISnowflakeEntity, IEntity<ulong>
Properties
| Improve this Doc View SourceCachedMessages
Gets all messages in this channel's cache.
Declaration
IReadOnlyCollection<SocketMessage> CachedMessages { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IReadOnlyCollection<SocketMessage> | A read-only collection of WebSocket-based messages. |
Methods
| Improve this Doc View SourceGetCachedMessage(UInt64)
Gets a cached message from this channel.
Declaration
SocketMessage GetCachedMessage(ulong id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | id | The snowflake identifier of the message. |
Returns
| Type | Description |
|---|---|
| SocketMessage | A WebSocket-based message object; |
Remarks
warning
This method requires the use of cache, which is not enabled by default; if caching is not enabled,
this method will always return null. Please refer to
MessageCacheSize for more details.
This method retrieves the message from the local WebSocket cache and does not send any additional request to Discord. This message may be a message that has been deleted.
GetCachedMessages(IMessage, Direction, Int32)
Gets the last N cached messages starting from a certain message in this message channel.
Declaration
IReadOnlyCollection<SocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = 100)
Parameters
| Type | Name | Description |
|---|---|---|
| IMessage | fromMessage | The message to start the fetching from. |
| Direction | dir | The direction of which the message should be gotten from. |
| System.Int32 | limit | The number of messages to get. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IReadOnlyCollection<SocketMessage> | A read-only collection of WebSocket-based messages. |
Remarks
warning
This method requires the use of cache, which is not enabled by default; if caching is not enabled, this method will always return an empty collection. Please refer to MessageCacheSize for more details.
This method retrieves the message(s) from the local WebSocket cache and does not send any additional request to Discord. This read-only collection may include messages that have been deleted. The maximum number of messages that can be retrieved from this method depends on the MessageCacheSize set.
GetCachedMessages(Int32)
Gets the last N cached messages from this message channel.
Declaration
IReadOnlyCollection<SocketMessage> GetCachedMessages(int limit = 100)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | limit | The number of messages to get. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IReadOnlyCollection<SocketMessage> | A read-only collection of WebSocket-based messages. |
Remarks
warning
This method requires the use of cache, which is not enabled by default; if caching is not enabled, this method will always return an empty collection. Please refer to MessageCacheSize for more details.
This method retrieves the message(s) from the local WebSocket cache and does not send any additional request to Discord. This read-only collection may include messages that have been deleted. The maximum number of messages that can be retrieved from this method depends on the MessageCacheSize set.
GetCachedMessages(UInt64, Direction, Int32)
Gets the last N cached messages starting from a certain message in this message channel.
Declaration
IReadOnlyCollection<SocketMessage> GetCachedMessages(ulong fromMessageId, Direction dir, int limit = 100)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | fromMessageId | The message ID to start the fetching from. |
| Direction | dir | The direction of which the message should be gotten from. |
| System.Int32 | limit | The number of messages to get. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IReadOnlyCollection<SocketMessage> | A read-only collection of WebSocket-based messages. |
Remarks
warning
This method requires the use of cache, which is not enabled by default; if caching is not enabled, this method will always return an empty collection. Please refer to MessageCacheSize for more details.
This method retrieves the message(s) from the local WebSocket cache and does not send any additional request to Discord. This read-only collection may include messages that have been deleted. The maximum number of messages that can be retrieved from this method depends on the MessageCacheSize set.
GetPinnedMessagesAsync(RequestOptions)
Gets a read-only collection of pinned messages in this channel.
Declaration
Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<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. |
Remarks
This method follows the same behavior as described in GetPinnedMessagesAsync(RequestOptions). Please visit its documentation for more details on this method.
SendFileAsync(Stream, String, String, Boolean, Embed, RequestOptions, Boolean)
Sends a file to this message channel with an optional caption.
Declaration
Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | stream | The System.IO.Stream of the file to be sent. |
| System.String | filename | The name of the attachment. |
| System.String | text | The message to be sent. |
| System.Boolean | isTTS | Whether the message should be read aloud by Discord or not. |
| Embed | embed | |
| RequestOptions | options | The options to be used when sending the request. |
| System.Boolean | isSpoiler | Whether the message attachment should be hidden as a spoiler. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<RestUserMessage> | A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. |
Remarks
This method follows the same behavior as described in SendFileAsync(Stream, String, String, Boolean, Embed, RequestOptions, Boolean). Please visit its documentation for more details on this method.
SendFileAsync(String, String, Boolean, Embed, RequestOptions, Boolean)
Sends a file to this message channel with an optional caption.
Declaration
Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | filePath | The file path of the file. |
| System.String | text | The message to be sent. |
| System.Boolean | isTTS | Whether the message should be read aloud by Discord or not. |
| Embed | embed | |
| RequestOptions | options | The options to be used when sending the request. |
| System.Boolean | isSpoiler | Whether the message attachment should be hidden as a spoiler. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<RestUserMessage> | A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. |
Remarks
This method follows the same behavior as described in SendFileAsync(String, String, Boolean, Embed, RequestOptions, Boolean). Please visit its documentation for more details on this method.
SendMessageAsync(String, Boolean, Embed, RequestOptions)
Sends a message to this message channel.
Declaration
Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | The message to be sent. |
| System.Boolean | isTTS | Determines whether the message should be read aloud by Discord or not. |
| Embed | embed | |
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<RestUserMessage> | A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. |
Remarks
This method follows the same behavior as described in SendMessageAsync(String, Boolean, Embed, RequestOptions). Please visit its documentation for more details on this method.