Class: CommandContext
Hierarchy
-
BaseContext↳CommandContext
Table of contents
Constructors
Properties
Methods
- decorate
- defer
- deleteReply
- editReply
- fetchReply
- followUp
- getAttachmentOption
- getBooleanOption
- getChannelOption
- getIntegerOption
- getMemberOption
- getNumberOption
- getRoleOption
- getStringOption
- getUserOption
- inGuild
- reply
- replyModal
Constructors
constructor
• new CommandContext(client, data): CommandContext
Constructs a new instance of the APIApplicationCommandInteractionData class.
Parameters
| Name | Type | Description |
|---|---|---|
client | YorClient | The client object. |
data | APIChatInputApplicationCommandInteraction | The data used to initialize the instance. |
Returns
CommandContext
Overrides
BaseContext.constructorDefined in
src/structures/Contexts/CommandContext.ts:50Properties
API
•Private API: YorClientAPI
Defined in
src/structures/Contexts/CommandContext.ts:42applicationId
•Readonly applicationId: string
Defined in
src/structures/Contexts/CommandContext.ts:33channel
• channel:Channel
Defined in
src/structures/Contexts/CommandContext.ts:35client
• client:YorClient
Inherited from
BaseContext.clientDefined in
src/structures/Base.ts:4interactionId
•Readonly interactionId: string
Defined in
src/structures/Contexts/CommandContext.ts:34member
• member:undefined | Member
Defined in
src/structures/Contexts/CommandContext.ts:37raw
•Readonly raw: APIChatInputApplicationCommandInteraction
Defined in
src/structures/Contexts/CommandContext.ts:31subcommand
•Optional subcommand: APIApplicationCommandInteractionDataSubcommandOption
Defined in
src/structures/Contexts/CommandContext.ts:40subcommandGroup
•Optional subcommandGroup: APIApplicationCommandInteractionDataSubcommandGroupOption
Defined in
src/structures/Contexts/CommandContext.ts:39token
•Readonly token: string
Defined in
src/structures/Contexts/CommandContext.ts:32user
• user:undefined | User
Defined in
src/structures/Contexts/CommandContext.ts:36Methods
decorate
▸ decorate(name, data): unknown
Decorates the object with a new property.
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the property. |
data | unknown | The data to assign to the property. |
Returns
unknown
The decorated object.
Inherited from
BaseContext.decorateDefined in
src/structures/Contexts/BaseContext.ts:22defer
▸ defer(ephemeral?): Promise<void>
Defers the execution of the function.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
ephemeral | boolean | false | Whether 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:86deleteReply
▸ 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:155editReply
▸ editReply(data): Promise<APIMessage>
Edits a reply.
Parameters
| Name | Type | Description |
|---|---|---|
data | Omit<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:129fetchReply
▸ 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:164followUp
▸ followUp(data): Promise<APIMessage>
Calls the followUp method of the API class with the provided data.
Parameters
| Name | Type | Description |
|---|---|---|
data | Omit<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:201getAttachmentOption
▸ getAttachmentOption<T>(name, index?, required?): T extends true ? APIAttachment : null | APIAttachment
Retrieves the value of the attachment option from the interaction data.
Type parameters
| Name | Type |
|---|---|
T | extends boolean |
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
name | string | undefined | The name of the attachment option. |
index | 0 | 2 | 1 | 0 | The index of the attachment option. |
required? | T | undefined | Whether 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:732getBooleanOption
▸ getBooleanOption<T>(name, index?, required?): T extends true ? boolean : null | boolean
Retrieves a boolean option from the command’s options.
Type parameters
| Name | Type |
|---|---|
T | extends boolean |
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
name | string | undefined | The name of the option to retrieve. |
index | 0 | 2 | 1 | 0 | (Optional) The index of the option to retrieve. Defaults to 0. |
required? | T | undefined | (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:403getChannelOption
▸ getChannelOption<T>(name, index?, required?): T extends true ? Channel : null | Channel
Retrieves a channel option from the command’s options.
Type parameters
| Name | Type |
|---|---|
T | extends boolean |
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
name | string | undefined | The name of the option to retrieve. |
index | 0 | 2 | 1 | 0 | (Optional) The index of the option to retrieve. Defaults to 0. |
required? | T | undefined | (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:595getIntegerOption
▸ getIntegerOption<T>(name, index?, required?): T extends true ? number : null | number
Retrieves an integer option from the API.
Type parameters
| Name | Type |
|---|---|
T | extends boolean |
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
name | string | undefined | The name of the option. |
index | 0 | 2 | 1 | 0 | The index of the option. |
required? | T | undefined | Whether 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:345getMemberOption
▸ getMemberOption<T>(name, index?, required?): T extends true ? Member : null | Member
Retrieves a user option from the command’s options.
Type parameters
| Name | Type |
|---|---|
T | extends boolean |
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
name | string | undefined | The name of the option to retrieve. |
index | 0 | 2 | 1 | 0 | (Optional) The index of the option to retrieve. Defaults to 0. |
required? | T | undefined | (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:662getNumberOption
▸ getNumberOption<T>(name, index?, required?): T extends true ? number : null | number
Retrieves a number option from the command’s options.
Type parameters
| Name | Type |
|---|---|
T | extends boolean |
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
name | string | undefined | The name of the option to retrieve. |
index | 0 | 2 | 1 | 0 | (Optional) The index of the option to retrieve. Defaults to 0. |
required? | T | undefined | (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:287getRoleOption
▸ getRoleOption<T>(name, index?, required?): T extends true ? Role : null | Role
Retrieves a role option from the command’s options.
Type parameters
| Name | Type |
|---|---|
T | extends boolean |
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
name | string | undefined | The name of the option to retrieve. |
index | 0 | 2 | 1 | 0 | (Optional) The index of the option to retrieve. Defaults to 0. |
required? | T | undefined | (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:528getStringOption
▸ getStringOption<T>(name, index?, required?): T extends true ? string : null | string
Retrieves a string option from the command’s options.
Type parameters
| Name | Type |
|---|---|
T | extends boolean |
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
name | string | undefined | The name of the option to retrieve. |
index | 0 | 2 | 1 | 0 | (Optional) The index of the option to retrieve. Defaults to 0. |
required? | T | undefined | (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:227getUserOption
▸ getUserOption<T>(name, index?, required?): T extends true ? User : null | User
Retrieves a user option from the command’s options.
Type parameters
| Name | Type |
|---|---|
T | extends boolean |
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
name | string | undefined | The name of the option to retrieve. |
index | 0 | 2 | 1 | 0 | (Optional) The index of the option to retrieve. Defaults to 0. |
required? | T | undefined | (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:461inGuild
▸ 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:215reply
▸ reply(data): Promise<void>
Replies to an interaction.
Parameters
| Name | Type | Description |
|---|---|---|
data | Omit<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:106replyModal
▸ replyModal(data): Promise<void>
Reply to a modal.
Parameters
| Name | Type | Description |
|---|---|---|
data | APIModalInteractionResponseCallbackData | The data for creating the modal. |
Returns
Promise<void>
A promise that resolves when the modal is created.
