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
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
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
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
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
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
Parameters
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
Parameters
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
Parameters
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
Parameters
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
Parameters
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
Parameters
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
Parameters
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
Parameters
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
Parameters
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
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
Returns
Promise<void>
A promise that resolves when the modal is created.
