Yor.ts | classes/YorClient
Class: YorClient
Table of contents
Constructors
Properties
Methods
- createMiddleware
- deployCommands
- handleInteraction
- handleInteractionRequest
- registerCommand
- registerCommands
- registerComponent
- registerComponents
- registerMessageCommand
- registerModal
- registerModals
- registerUserCommand
- unregisterAllCommands
- unregisterCommand
- unregisterCommands
- unregisterComponent
- unregisterComponents
- unregisterMessageCommand
- unregisterModal
- unregisterModals
- unregisterUserCommand
Constructors
constructor
• new YorClient(options
): YorClient
Creates a new instance of the class.
Parameters
Name | Type | Description |
---|---|---|
options | YorClientOptions | The configuration options for the client. |
Returns
Defined in
src/structures/YorClient.ts:95
Properties
api
• api: YorClientAPI
Defined in
src/structures/YorClient.ts:83
commands
• Readonly
commands: Collection
<string
, YorSlashCommand
>
Defined in
src/structures/YorClient.ts:67
components
• Readonly
components: Collection
<string
, YorInteractionComponent
>
Defined in
src/structures/YorClient.ts:68
messageCommands
• Readonly
messageCommands: Collection
<string
, YorMessageContextMenuCommand
>
Defined in
src/structures/YorClient.ts:73
middlewares
• middlewares: Record
<MiddlewareFunctionNames
, ((context
: CommandContext
) => void
| Promise
<void
> | (context
: MessageContextMenuCommandInteraction
) => void
| Promise
<void
> | (context
: CommandContext
) => void
| Promise
<void
> | (context
: ComponentContext
) => void
| Promise
<void
> | (context
: ModalContext
) => void
| Promise
<void
> | (context
: AutocompleteCommandContext
) => void
| Promise
<void
>)[]>
Defined in
src/structures/YorClient.ts:85
modals
• Readonly
modals: Collection
<string
, YorInteractionModal
>
Defined in
src/structures/YorClient.ts:72
options
• Readonly
options: YorClientOptions
Defined in
src/structures/YorClient.ts:66
rest
• rest: REST
Defined in
src/structures/YorClient.ts:82
userCommands
• Readonly
userCommands: Collection
<string
, YorUserContextMenuCommand
>
Defined in
src/structures/YorClient.ts:77
Methods
createMiddleware
▸ createMiddleware<T
>(name
, middleware
): void
Creates middleware for a given name and adds it to the middlewares array.
Type parameters
Name | Type |
---|---|
T | extends MiddlewareFunctionNames |
Parameters
Name | Type | Description |
---|---|---|
name | T | The name of the middleware. |
middleware | MiddlewareFunction <T > | The middleware function. |
Returns
void
Defined in
src/structures/YorClient.ts:410
deployCommands
▸ deployCommands(guild?
): Promise
<RESTPutAPIApplicationCommandsResult
>
Deploys the commands to the API application and returns the result.
Parameters
Name | Type |
---|---|
guild? | string |
Returns
Promise
<RESTPutAPIApplicationCommandsResult
>
The result of the deployment.
Defined in
src/structures/YorClient.ts:246
handleInteraction
▸ handleInteraction(request
): Promise
<APIInteractionResponse
>
Handles an interaction request from the API.
Parameters
Name | Type | Description |
---|---|---|
request | Request | The request object containing the interaction data. |
Returns
Promise
<APIInteractionResponse
>
- An object containing a promise for the response.
Defined in
src/structures/YorClient.ts:423
handleInteractionRequest
▸ handleInteractionRequest(data
): Promise
<{ type
: InteractionResponseType
= InteractionResponseType.PONG }>
Handles the interaction request.
Parameters
Name | Type | Description |
---|---|---|
data | APIInteraction | The interaction data. |
Returns
Promise
<{ type
: InteractionResponseType
= InteractionResponseType.PONG }>
Defined in
src/structures/YorClient.ts:459
registerCommand
▸ registerCommand(command
): Collection
<string
, YorSlashCommand
>
Registers a slash command.
Parameters
Name | Type | Description |
---|---|---|
command | YorSlashCommand | The slash command to register. |
Returns
Collection
<string
, YorSlashCommand
>
- The updated commands collection.
Defined in
src/structures/YorClient.ts:119
registerCommands
▸ registerCommands(commands
): Collection
<string
, YorSlashCommand
>
Registers the provided slash commands.
Parameters
Name | Type | Description |
---|---|---|
commands | YorSlashCommand [] | The slash commands to register. |
Returns
Collection
<string
, YorSlashCommand
>
- The updated commands map.
Defined in
src/structures/YorClient.ts:137
registerComponent
▸ registerComponent(component
): Collection
<string
, YorInteractionComponent
>
Registers a component in the collection.
Parameters
Name | Type | Description |
---|---|---|
component | YorInteractionComponent | The component to register. |
Returns
Collection
<string
, YorInteractionComponent
>
- The updated collection of components.
Defined in
src/structures/YorClient.ts:274
registerComponents
▸ registerComponents(components
): Collection
<string
, YorInteractionComponent
>
Registers the given components in the collection.
Parameters
Name | Type | Description |
---|---|---|
components | YorInteractionComponent [] | The components to register. |
Returns
Collection
<string
, YorInteractionComponent
>
- The updated collection of components.
Defined in
src/structures/YorClient.ts:293
registerMessageCommand
▸ registerMessageCommand(command
): Collection
<string
, YorMessageContextMenuCommand
>
Registers a message command.
Parameters
Name | Type | Description |
---|---|---|
command | YorMessageContextMenuCommand | The message command to register. |
Returns
Collection
<string
, YorMessageContextMenuCommand
>
- The updated message commands collection.
Defined in
src/structures/YorClient.ts:195
registerModal
▸ registerModal(modal
): Collection
<string
, YorInteractionModal
>
Registers a modal in the collection.
Parameters
Name | Type | Description |
---|---|---|
modal | YorInteractionModal | The modal to be registered. |
Returns
Collection
<string
, YorInteractionModal
>
- The updated collection of modals.
Defined in
src/structures/YorClient.ts:344
registerModals
▸ registerModals(modals
): Collection
<string
, YorInteractionModal
>
Registers the given modals in the collection.
Parameters
Name | Type | Description |
---|---|---|
modals | YorInteractionModal [] | The modals to be registered. |
Returns
Collection
<string
, YorInteractionModal
>
- The updated collection of modals.
Defined in
src/structures/YorClient.ts:361
registerUserCommand
▸ registerUserCommand(command
): Collection
<string
, YorUserContextMenuCommand
>
Registers a user command.
Parameters
Name | Type | Description |
---|---|---|
command | YorUserContextMenuCommand | The user command to register. |
Returns
Collection
<string
, YorUserContextMenuCommand
>
- The updated user commands collection.
Defined in
src/structures/YorClient.ts:221
unregisterAllCommands
▸ unregisterAllCommands(): Collection
<string
, YorSlashCommand
>
Unregisters all slash commands.
Returns
Collection
<string
, YorSlashCommand
>
- The updated commands map.
Defined in
src/structures/YorClient.ts:184
unregisterCommand
▸ unregisterCommand(command
): Collection
<string
, YorSlashCommand
>
Unregisters a slash command.
Parameters
Name | Type | Description |
---|---|---|
command | YorSlashCommand | The slash command to unregister. |
Returns
Collection
<string
, YorSlashCommand
>
- The updated commands collection.
Defined in
src/structures/YorClient.ts:157
unregisterCommands
▸ unregisterCommands(commands
): Collection
<string
, YorSlashCommand
>
Unregisters the provided slash commands.
Parameters
Name | Type | Description |
---|---|---|
commands | YorSlashCommand [] | The slash commands to unregister. |
Returns
Collection
<string
, YorSlashCommand
>
- The updated commands map.
Defined in
src/structures/YorClient.ts:170
unregisterComponent
▸ unregisterComponent(component
): Collection
<string
, YorInteractionComponent
>
Deletes the specified component from the collection and returns the updated collection.
Parameters
Name | Type | Description |
---|---|---|
component | YorInteractionComponent | The component to unregister. |
Returns
Collection
<string
, YorInteractionComponent
>
- The updated collection of components.
Defined in
src/structures/YorClient.ts:314
unregisterComponents
▸ unregisterComponents(components
): Collection
<string
, YorInteractionComponent
>
Unregisters components from the collection.
Parameters
Name | Type | Description |
---|---|---|
components | YorInteractionComponent [] | The components to unregister. |
Returns
Collection
<string
, YorInteractionComponent
>
- The updated components collection.
Defined in
src/structures/YorClient.ts:328
unregisterMessageCommand
▸ unregisterMessageCommand(command
): Collection
<string
, YorMessageContextMenuCommand
>
Unregisters a message command.
Parameters
Name | Type | Description |
---|---|---|
command | YorMessageContextMenuCommand | The message command to unregister. |
Returns
Collection
<string
, YorMessageContextMenuCommand
>
- The updated message commands collection.
Defined in
src/structures/YorClient.ts:208
unregisterModal
▸ unregisterModal(modal
): Collection
<string
, YorInteractionModal
>
Deletes the specified modal from the collection and returns the updated collection.
Parameters
Name | Type | Description |
---|---|---|
modal | YorInteractionModal | The modal to unregister. |
Returns
Collection
<string
, YorInteractionModal
>
- The updated collection of modals.
Defined in
src/structures/YorClient.ts:380
unregisterModals
▸ unregisterModals(modals
): Collection
<string
, YorInteractionModal
>
Unregisters modals from the collection.
Parameters
Name | Type | Description |
---|---|---|
modals | YorInteractionModal [] | The modals to unregister. |
Returns
Collection
<string
, YorInteractionModal
>
- The updated collection of modals.
Defined in
src/structures/YorClient.ts:394
unregisterUserCommand
▸ unregisterUserCommand(command
): Collection
<string
, YorUserContextMenuCommand
>
Unregisters a user command.
Parameters
Name | Type | Description |
---|---|---|
command | YorUserContextMenuCommand | The user command to unregister. |
Returns
Collection
<string
, YorUserContextMenuCommand
>
- The updated user commands collection.
Defined in
Was this page helpful?