Table of Contents

Class UserExtensions

Namespace
Kook
Assembly
Kook.Net.Core.dll

An extension class for various Kook user objects.

public static class UserExtensions
Inheritance
UserExtensions
Inherited Members

Methods

BanAsync(IGuildUser, int, string?, RequestOptions?)

Bans the user from the guild and optionally prunes their recent messages.

public static Task BanAsync(this IGuildUser user, int pruneDays = 0, string? reason = null, RequestOptions? options = null)

Parameters

user IGuildUser

The user to ban.

pruneDays int

The number of days to remove messages from this user for - must be between [0, 7]

reason string

The reason of the ban to be written in the audit log.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous operation for banning a user.

Exceptions

ArgumentException

pruneDays is not between 0 to 7.

SendCardAsync(IUser, ICard, IQuote?, RequestOptions?)

Sends a card message message via DM.

public static Task<Cacheable<IUserMessage, Guid>> SendCardAsync(this IUser user, ICard card, IQuote? quote = null, RequestOptions? options = null)

Parameters

user IUser

The user to send the DM to.

card ICard

The card to be sent.

quote IQuote

The message quote to be included. Used to reply to specific messages.

options RequestOptions

The request options for this async request.

Returns

Task<Cacheable<IUserMessage, Guid>>

SendCardsAsync(IUser, IEnumerable<ICard>, IQuote?, RequestOptions?)

Sends a card message message via DM.

public static Task<Cacheable<IUserMessage, Guid>> SendCardsAsync(this IUser user, IEnumerable<ICard> cards, IQuote? quote = null, RequestOptions? options = null)

Parameters

user IUser

The user to send the DM to.

cards IEnumerable<ICard>

The cards to be sent.

quote IQuote

The message quote to be included. Used to reply to specific messages.

options RequestOptions

The request options for this async request.

Returns

Task<Cacheable<IUserMessage, Guid>>

SendFileAsync(IUser, FileAttachment, IQuote?, RequestOptions?)

Sends a file via DM.

public static Task<Cacheable<IUserMessage, Guid>> SendFileAsync(this IUser user, FileAttachment attachment, IQuote? quote = null, RequestOptions? options = null)

Parameters

user IUser

The user to send the DM to.

attachment FileAttachment

The attachment containing the file.

quote IQuote

The message quote to be included. Used to reply to specific messages.

options RequestOptions

The options to be used when sending the request.

Returns

Task<Cacheable<IUserMessage, Guid>>

SendFileAsync(IUser, Stream, string, AttachmentType, IQuote?, RequestOptions?)

Sends a file via DM.

public static Task<Cacheable<IUserMessage, Guid>> SendFileAsync(this IUser user, Stream stream, string filename, AttachmentType type = AttachmentType.File, IQuote? quote = null, RequestOptions? options = null)

Parameters

user IUser

The user to send the DM to.

stream Stream

The stream of the file.

filename string

The name of the file.

type AttachmentType

The type of the file.

quote IQuote

The message quote to be included. Used to reply to specific messages.

options RequestOptions

The options to be used when sending the request.

Returns

Task<Cacheable<IUserMessage, Guid>>

SendFileAsync(IUser, string, string?, AttachmentType, IQuote?, RequestOptions?)

Sends a file via DM.

public static Task<Cacheable<IUserMessage, Guid>> SendFileAsync(this IUser user, string path, string? filename = null, AttachmentType type = AttachmentType.File, IQuote? quote = null, RequestOptions? options = null)

Parameters

user IUser

The user to send the DM to.

path string

The file path of the file.

filename string

The name of the file.

type AttachmentType

The type of the file.

quote IQuote

The message quote to be included. Used to reply to specific messages.

options RequestOptions

The options to be used when sending the request.

Returns

Task<Cacheable<IUserMessage, Guid>>

SendTextAsync(IUser, string, IQuote?, RequestOptions?)

Sends a text message via DM.

public static Task<Cacheable<IUserMessage, Guid>> SendTextAsync(this IUser user, string content, IQuote? quote = null, RequestOptions? options = null)

Parameters

user IUser

The user to send the DM to.

content string

The KMarkdown content to be sent.

quote IQuote

The message quote to be included. Used to reply to specific messages.

options RequestOptions

The options to be used when sending the request.

Returns

Task<Cacheable<IUserMessage, Guid>>