Interface IMessageChannel
- Namespace
- Kook
- Assembly
- Kook.Net.Core.dll
Represents a channel that can send and receive messages.
public interface IMessageChannel : IChannel, IEntity<ulong>
- Inherited Members
- Extension Methods
Methods
DeleteMessageAsync(IMessage, RequestOptions?)
Deletes a message based on the provided message in this channel.
Task DeleteMessageAsync(IMessage message, RequestOptions? options = null)
Parameters
message
IMessageThe message that would be removed.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task
A task that represents the asynchronous removal operation.
DeleteMessageAsync(Guid, RequestOptions?)
Deletes a message.
Task DeleteMessageAsync(Guid messageId, RequestOptions? options = null)
Parameters
messageId
GuidThe identifier of the message that would be removed.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task
A task that represents the asynchronous removal operation.
GetMessageAsync(Guid, CacheMode, RequestOptions?)
Gets a message from this message channel.
Task<IMessage?> GetMessageAsync(Guid id, CacheMode mode = CacheMode.AllowDownload, RequestOptions? options = null)
Parameters
id
GuidThe identifier of the message.
mode
CacheModeThe CacheMode that determines whether the object should be fetched from cache.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task<IMessage>
A task that represents an asynchronous get operation for retrieving the message. The task result contains the retrieved message;
null
if no message is found with the specified identifier.
GetMessagesAsync(IMessage, Direction, int, CacheMode, RequestOptions?)
Gets a collection of messages in this channel.
IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage referenceMessage, Direction dir, int limit = 50, CacheMode mode = CacheMode.AllowDownload, RequestOptions? options = null)
Parameters
referenceMessage
IMessageThe starting message to get the messages from.
dir
DirectionThe direction of the messages to be gotten from.
limit
intThe numbers of message to be gotten from.
mode
CacheModeThe CacheMode that determines whether the object should be fetched from cache.
options
RequestOptionsThe options to be used when sending the request.
Returns
- IAsyncEnumerable<IReadOnlyCollection<IMessage>>
Paged collection of messages.
Remarks
important
The returned collection is an asynchronous enumerable object; one must call FlattenAsync<T>(IAsyncEnumerable<IEnumerable<T>>) to access the individual messages as a collection.
warning
Do not fetch too many messages at once! This may cause unwanted preemptive rate limit or even actual rate limit, causing your bot to freeze!
limit
around
the message referenceMessage
depending on the dir
. The library will
attempt to split up the requests according to your limit
and
MaxMessagesPerBatch. In other words, should the user request 500 messages,
and the MaxMessagesPerBatch constant is 100
, the request will
be split into 5 individual requests; thus returning 5 individual asynchronous responses, hence the need
of flattening.
GetMessagesAsync(Guid, Direction, int, CacheMode, RequestOptions?)
Gets a collection of messages in this channel.
IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(Guid referenceMessageId, Direction dir, int limit = 50, CacheMode mode = CacheMode.AllowDownload, RequestOptions? options = null)
Parameters
referenceMessageId
GuidThe ID of the starting message to get the messages from.
dir
DirectionThe direction of the messages to be gotten from.
limit
intThe numbers of message to be gotten from.
mode
CacheModeThe CacheMode that determines whether the object should be fetched from cache.
options
RequestOptionsThe options to be used when sending the request.
Returns
- IAsyncEnumerable<IReadOnlyCollection<IMessage>>
Paged collection of messages.
Remarks
important
The returned collection is an asynchronous enumerable object; one must call FlattenAsync<T>(IAsyncEnumerable<IEnumerable<T>>) to access the individual messages as a collection.
warning
Do not fetch too many messages at once! This may cause unwanted preemptive rate limit or even actual rate limit, causing your bot to freeze!
limit
around
the message referenceMessageId
depending on the dir
. The library will
attempt to split up the requests according to your limit
and
MaxMessagesPerBatch. In other words, should the user request 500 messages,
and the MaxMessagesPerBatch constant is 100
, the request will
be split into 5 individual requests; thus returning 5 individual asynchronous responses, hence the need
of flattening.
GetMessagesAsync(int, CacheMode, RequestOptions?)
Gets the last N messages from this message channel.
IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = 50, CacheMode mode = CacheMode.AllowDownload, RequestOptions? options = null)
Parameters
limit
intThe numbers of message to be gotten from.
mode
CacheModeThe CacheMode that determines whether the object should be fetched from cache.
options
RequestOptionsThe options to be used when sending the request.
Returns
- IAsyncEnumerable<IReadOnlyCollection<IMessage>>
Paged collection of messages.
Remarks
important
The returned collection is an asynchronous enumerable object; one must call FlattenAsync<T>(IAsyncEnumerable<IEnumerable<T>>) to access the individual messages as a collection.
warning
Do not fetch too many messages at once! This may cause unwanted preemptive rate limit or even actual rate limit, causing your bot to freeze!
limit
. The
library will attempt to split up the requests according to your limit
and
MaxMessagesPerBatch. In other words, should the user request 500 messages,
and the MaxMessagesPerBatch constant is 100
, the request will
be split into 5 individual requests; thus returning 5 individual asynchronous responses, hence the need
of flattening.
ModifyMessageAsync(Guid, Action<MessageProperties>, RequestOptions?)
Modifies a message.
Task ModifyMessageAsync(Guid messageId, Action<MessageProperties> func, RequestOptions? options = null)
Parameters
messageId
GuidThe identifier of the message that would be changed.
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.
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.
SendCardAsync(ICard, IQuote?, IUser?, RequestOptions?)
Sends a card message to this message channel.
Task<Cacheable<IUserMessage, Guid>> SendCardAsync(ICard card, IQuote? quote = null, IUser? ephemeralUser = null, RequestOptions? options = null)
Parameters
card
ICardThe card to be sent.
quote
IQuoteThe message quote to be included. Used to reply to specific messages.
ephemeralUser
IUserThe user only who can see the message. Leave null to let everyone see the message.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task<Cacheable<IUserMessage, Guid>>
A task that represents an asynchronous send operation for delivering the message. The task result contains the identifier and timestamp of the sent message.
SendCardsAsync(IEnumerable<ICard>, IQuote?, IUser?, RequestOptions?)
Sends a card message to this message channel.
Task<Cacheable<IUserMessage, Guid>> SendCardsAsync(IEnumerable<ICard> cards, IQuote? quote = null, IUser? ephemeralUser = null, RequestOptions? options = null)
Parameters
cards
IEnumerable<ICard>The cards to be sent.
quote
IQuoteThe message quote to be included. Used to reply to specific messages.
ephemeralUser
IUserThe user only who can see the message. Leave null to let everyone see the message.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task<Cacheable<IUserMessage, Guid>>
A task that represents an asynchronous send operation for delivering the message. The task result contains the identifier and timestamp of the sent message.
SendFileAsync(FileAttachment, IQuote?, IUser?, RequestOptions?)
Sends a file to this message channel.
Task<Cacheable<IUserMessage, Guid>> SendFileAsync(FileAttachment attachment, IQuote? quote = null, IUser? ephemeralUser = null, RequestOptions? options = null)
Parameters
attachment
FileAttachmentThe attachment containing the file.
quote
IQuoteThe message quote to be included. Used to reply to specific messages.
ephemeralUser
IUserThe user only who can see the message. Leave null to let everyone see the message.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task<Cacheable<IUserMessage, Guid>>
A task that represents an asynchronous send operation for delivering the message. The task result contains the identifier and timestamp of the sent message.
Remarks
This method sends a file as if you are uploading a file directly from your Kook client.
SendFileAsync(Stream, string, AttachmentType, IQuote?, IUser?, RequestOptions?)
Sends a file to this message channel.
Task<Cacheable<IUserMessage, Guid>> SendFileAsync(Stream stream, string filename, AttachmentType type = AttachmentType.File, IQuote? quote = null, IUser? ephemeralUser = null, RequestOptions? options = null)
Parameters
stream
StreamThe stream of the file.
filename
stringThe name of the file.
type
AttachmentTypeThe type of the file.
quote
IQuoteThe message quote to be included. Used to reply to specific messages.
ephemeralUser
IUserThe user only who can see the message. Leave null to let everyone see the message.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task<Cacheable<IUserMessage, Guid>>
A task that represents an asynchronous send operation for delivering the message. The task result contains the identifier and timestamp of the sent message.
Remarks
This method sends a file as if you are uploading a file directly from your Kook client.
SendFileAsync(string, string?, AttachmentType, IQuote?, IUser?, RequestOptions?)
Sends a file to this message channel.
Task<Cacheable<IUserMessage, Guid>> SendFileAsync(string path, string? filename = null, AttachmentType type = AttachmentType.File, IQuote? quote = null, IUser? ephemeralUser = null, RequestOptions? options = null)
Parameters
path
stringThe file path of the file.
filename
stringThe name of the file.
type
AttachmentTypeThe type of the file.
quote
IQuoteThe message quote to be included. Used to reply to specific messages.
ephemeralUser
IUserThe user only who can see the message. Leave null to let everyone see the message.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task<Cacheable<IUserMessage, Guid>>
A task that represents an asynchronous send operation for delivering the message. The task result contains the identifier and timestamp of the sent message.
Remarks
This method sends a file as if you are uploading a file directly from your Kook client.
SendTextAsync(string, IQuote?, IUser?, RequestOptions?)
Sends a text message to this message channel.
Task<Cacheable<IUserMessage, Guid>> SendTextAsync(string text, IQuote? quote = null, IUser? ephemeralUser = null, RequestOptions? options = null)
Parameters
text
stringThe message to be sent.
quote
IQuoteThe message quote to be included. Used to reply to specific messages.
ephemeralUser
IUserThe user only who can see the message. Leave null to let everyone see the message.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task<Cacheable<IUserMessage, Guid>>
A task that represents an asynchronous send operation for delivering the message. The task result contains the identifier and timestamp of the sent message.