yor.ts / Exports / CommandContext

Class: CommandContext

Hierarchy

  • BaseContext CommandContext

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new CommandContext(client, data): CommandContext Constructs a new instance of the APIApplicationCommandInteractionData class.

Parameters

NameTypeDescription
clientYorClientThe client object.
dataAPIChatInputApplicationCommandInteractionThe data used to initialize the instance.

Returns

CommandContext

Overrides

BaseContext.constructor

Defined in

src/structures/Contexts/CommandContext.ts:50

Properties

API

Private API: YorClientAPI

Defined in

src/structures/Contexts/CommandContext.ts:42

applicationId

Readonly applicationId: string

Defined in

src/structures/Contexts/CommandContext.ts:33

channel

channel: Channel

Defined in

src/structures/Contexts/CommandContext.ts:35

client

client: YorClient

Inherited from

BaseContext.client

Defined in

src/structures/Base.ts:4

interactionId

Readonly interactionId: string

Defined in

src/structures/Contexts/CommandContext.ts:34

member

member: undefined | Member

Defined in

src/structures/Contexts/CommandContext.ts:37

raw

Readonly raw: APIChatInputApplicationCommandInteraction

Defined in

src/structures/Contexts/CommandContext.ts:31

subcommand

Optional subcommand: APIApplicationCommandInteractionDataSubcommandOption

Defined in

src/structures/Contexts/CommandContext.ts:40

subcommandGroup

Optional subcommandGroup: APIApplicationCommandInteractionDataSubcommandGroupOption

Defined in

src/structures/Contexts/CommandContext.ts:39

token

Readonly token: string

Defined in

src/structures/Contexts/CommandContext.ts:32

user

user: undefined | User

Defined in

src/structures/Contexts/CommandContext.ts:36

Methods

decorate

decorate(name, data): unknown Decorates the object with a new property.

Parameters

NameTypeDescription
namestringThe name of the property.
dataunknownThe data to assign to the property.

Returns

unknown The decorated object.

Inherited from

BaseContext.decorate

Defined in

src/structures/Contexts/BaseContext.ts:22

defer

defer(ephemeral?): Promise<void> Defers the execution of the function.

Parameters

NameTypeDefault valueDescription
ephemeralbooleanfalseWhether the message is ephemeral or not.

Returns

Promise<void> A promise that resolves when the deferral is complete.

Defined in

src/structures/Contexts/CommandContext.ts:86

deleteReply

deleteReply(): Promise<void> Deletes a reply.

Returns

Promise<void> A promise that resolves when the reply is deleted.

Defined in

src/structures/Contexts/CommandContext.ts:155

editReply

editReply(data): Promise<APIMessage> Edits a reply.

Parameters

NameTypeDescription
dataOmit<RESTPostAPIWebhookWithTokenJSONBody, "username" | "avatar_url"> & { flags?: MessageFlags } & { files?: RawFile[] }The data for editing the reply.

Returns

Promise<APIMessage> A promise that resolves when the reply is edited.

Defined in

src/structures/Contexts/CommandContext.ts:129

fetchReply

fetchReply(): Promise<APIMessage> Fetches the reply asynchronously.

Returns

Promise<APIMessage> A promise that resolves when the original reply is fetched.

Defined in

src/structures/Contexts/CommandContext.ts:164

followUp

followUp(data): Promise<APIMessage> Calls the followUp method of the API class with the provided data.

Parameters

NameTypeDescription
dataOmit<RESTPostAPIWebhookWithTokenJSONBody, "username" | "avatar_url"> & { flags?: MessageFlags } & { files?: RawFile[] }The data to be passed to the followUp method.

Returns

Promise<APIMessage> A promise that resolves to an APIMessage object.

Defined in

src/structures/Contexts/CommandContext.ts:201

getAttachmentOption

getAttachmentOption<T>(name, index?, required?): T extends true ? APIAttachment : null | APIAttachment Retrieves the value of the attachment option from the interaction data.

Type parameters

NameType
Textends boolean

Parameters

NameTypeDefault valueDescription
namestringundefinedThe name of the attachment option.
index0 | 2 | 10The index of the attachment option.
required?TundefinedWhether the attachment option is required.

Returns

T extends true ? APIAttachment : null | APIAttachment The value of the attachment option, or null if it doesn’t exist. Throws If the attachment option is required but doesn’t exist.

Defined in

src/structures/Contexts/CommandContext.ts:732

getBooleanOption

getBooleanOption<T>(name, index?, required?): T extends true ? boolean : null | boolean Retrieves a boolean option from the command’s options.

Type parameters

NameType
Textends boolean

Parameters

NameTypeDefault valueDescription
namestringundefinedThe name of the option to retrieve.
index0 | 2 | 10(Optional) The index of the option to retrieve. Defaults to 0.
required?Tundefined(Optional) Specifies if the option is required. Defaults to false.

Returns

T extends true ? boolean : null | boolean
  • The value of the option, or null if the option is not found and not required.

Defined in

src/structures/Contexts/CommandContext.ts:403

getChannelOption

getChannelOption<T>(name, index?, required?): T extends true ? Channel : null | Channel Retrieves a channel option from the command’s options.

Type parameters

NameType
Textends boolean

Parameters

NameTypeDefault valueDescription
namestringundefinedThe name of the option to retrieve.
index0 | 2 | 10(Optional) The index of the option to retrieve. Defaults to 0.
required?Tundefined(Optional) Specifies if the option is required. Defaults to false.

Returns

T extends true ? Channel : null | Channel
  • The value of the option, or null if the option is not found and not required.

Defined in

src/structures/Contexts/CommandContext.ts:595

getIntegerOption

getIntegerOption<T>(name, index?, required?): T extends true ? number : null | number Retrieves an integer option from the API.

Type parameters

NameType
Textends boolean

Parameters

NameTypeDefault valueDescription
namestringundefinedThe name of the option.
index0 | 2 | 10The index of the option.
required?TundefinedWhether the option is required or not.

Returns

T extends true ? number : null | number
  • The value of the option.

Defined in

src/structures/Contexts/CommandContext.ts:345

getMemberOption

getMemberOption<T>(name, index?, required?): T extends true ? Member : null | Member Retrieves a user option from the command’s options.

Type parameters

NameType
Textends boolean

Parameters

NameTypeDefault valueDescription
namestringundefinedThe name of the option to retrieve.
index0 | 2 | 10(Optional) The index of the option to retrieve. Defaults to 0.
required?Tundefined(Optional) Specifies if the option is required. Defaults to false.

Returns

T extends true ? Member : null | Member
  • The value of the option, or null if the option is not found and not required.

Defined in

src/structures/Contexts/CommandContext.ts:662

getNumberOption

getNumberOption<T>(name, index?, required?): T extends true ? number : null | number Retrieves a number option from the command’s options.

Type parameters

NameType
Textends boolean

Parameters

NameTypeDefault valueDescription
namestringundefinedThe name of the option to retrieve.
index0 | 2 | 10(Optional) The index of the option to retrieve. Defaults to 0.
required?Tundefined(Optional) Specifies if the option is required. Defaults to false.

Returns

T extends true ? number : null | number
  • The value of the option, or null if the option is not found and not required.

Defined in

src/structures/Contexts/CommandContext.ts:287

getRoleOption

getRoleOption<T>(name, index?, required?): T extends true ? Role : null | Role Retrieves a role option from the command’s options.

Type parameters

NameType
Textends boolean

Parameters

NameTypeDefault valueDescription
namestringundefinedThe name of the option to retrieve.
index0 | 2 | 10(Optional) The index of the option to retrieve. Defaults to 0.
required?Tundefined(Optional) Specifies if the option is required. Defaults to false.

Returns

T extends true ? Role : null | Role
  • The value of the option, or null if the option is not found and not required.

Defined in

src/structures/Contexts/CommandContext.ts:528

getStringOption

getStringOption<T>(name, index?, required?): T extends true ? string : null | string Retrieves a string option from the command’s options.

Type parameters

NameType
Textends boolean

Parameters

NameTypeDefault valueDescription
namestringundefinedThe name of the option to retrieve.
index0 | 2 | 10(Optional) The index of the option to retrieve. Defaults to 0.
required?Tundefined(Optional) Specifies if the option is required. Defaults to false.

Returns

T extends true ? string : null | string
  • The value of the option, or null if the option is not found and not required.

Defined in

src/structures/Contexts/CommandContext.ts:227

getUserOption

getUserOption<T>(name, index?, required?): T extends true ? User : null | User Retrieves a user option from the command’s options.

Type parameters

NameType
Textends boolean

Parameters

NameTypeDefault valueDescription
namestringundefinedThe name of the option to retrieve.
index0 | 2 | 10(Optional) The index of the option to retrieve. Defaults to 0.
required?Tundefined(Optional) Specifies if the option is required. Defaults to false.

Returns

T extends true ? User : null | User
  • The value of the option, or null if the option is not found and not required.

Defined in

src/structures/Contexts/CommandContext.ts:461

inGuild

inGuild(): boolean Checks if the instance is in a guild.

Returns

boolean Returns true if the instance is in a guild, otherwise false.

Defined in

src/structures/Contexts/CommandContext.ts:215

reply

reply(data): Promise<void> Replies to an interaction.

Parameters

NameTypeDescription
dataOmit<RESTPostAPIWebhookWithTokenJSONBody, "username" | "avatar_url"> & { flags?: MessageFlags } & { files?: RawFile[] }The data for creating the reply.

Returns

Promise<void> A promise that resolves when the reply is sent.

Defined in

src/structures/Contexts/CommandContext.ts:106

replyModal

replyModal(data): Promise<void> Reply to a modal.

Parameters

NameTypeDescription
dataAPIModalInteractionResponseCallbackDataThe data for creating the modal.

Returns

Promise<void> A promise that resolves when the modal is created.

Defined in

src/structures/Contexts/CommandContext.ts:177