> ## Documentation Index
> Fetch the complete documentation index at: https://yor.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Yor.ts | classes/YorClient

[yor.ts](../README) / [Exports](../modules) / YorClient

# Class: YorClient

## Table of contents

### Constructors

* [constructor](YorClient#constructor)

### Properties

* [api](YorClient#api)
* [commands](YorClient#commands)
* [components](YorClient#components)
* [messageCommands](YorClient#messagecommands)
* [middlewares](YorClient#middlewares)
* [modals](YorClient#modals)
* [options](YorClient#options)
* [rest](YorClient#rest)
* [userCommands](YorClient#usercommands)

### Methods

* [createMiddleware](YorClient#createmiddleware)
* [deployCommands](YorClient#deploycommands)
* [handleInteraction](YorClient#handleinteraction)
* [handleInteractionRequest](YorClient#handleinteractionrequest)
* [registerCommand](YorClient#registercommand)
* [registerCommands](YorClient#registercommands)
* [registerComponent](YorClient#registercomponent)
* [registerComponents](YorClient#registercomponents)
* [registerMessageCommand](YorClient#registermessagecommand)
* [registerModal](YorClient#registermodal)
* [registerModals](YorClient#registermodals)
* [registerUserCommand](YorClient#registerusercommand)
* [unregisterAllCommands](YorClient#unregisterallcommands)
* [unregisterCommand](YorClient#unregistercommand)
* [unregisterCommands](YorClient#unregistercommands)
* [unregisterComponent](YorClient#unregistercomponent)
* [unregisterComponents](YorClient#unregistercomponents)
* [unregisterMessageCommand](YorClient#unregistermessagecommand)
* [unregisterModal](YorClient#unregistermodal)
* [unregisterModals](YorClient#unregistermodals)
* [unregisterUserCommand](YorClient#unregisterusercommand)

## Constructors

### constructor

• **new YorClient**(`options`): [`YorClient`](YorClient)

Creates a new instance of the class.

#### Parameters

| Name      | Type                                                 | Description                               |
| :-------- | :--------------------------------------------------- | :---------------------------------------- |
| `options` | [`YorClientOptions`](../interfaces/YorClientOptions) | The configuration options for the client. |

#### Returns

[`YorClient`](YorClient)

#### Defined in

[src/structures/YorClient.ts:95](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L95)

## Properties

### api

• **api**: [`YorClientAPI`](YorClientAPI)

#### Defined in

[src/structures/YorClient.ts:83](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L83)

***

### commands

• `Readonly` **commands**: `Collection`\<`string`, [`YorSlashCommand`](YorSlashCommand)>

#### Defined in

[src/structures/YorClient.ts:67](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L67)

***

### components

• `Readonly` **components**: `Collection`\<`string`, [`YorInteractionComponent`](YorInteractionComponent)>

#### Defined in

[src/structures/YorClient.ts:68](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L68)

***

### messageCommands

• `Readonly` **messageCommands**: `Collection`\<`string`, [`YorMessageContextMenuCommand`](YorMessageContextMenuCommand)>

#### Defined in

[src/structures/YorClient.ts:73](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L73)

***

### middlewares

• **middlewares**: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<[`MiddlewareFunctionNames`](../modules#middlewarefunctionnames), ((`context`: [`CommandContext`](CommandContext)) => `void` | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`> | (`context`: [`MessageContextMenuCommandInteraction`](MessageContextMenuCommandInteraction)) => `void` | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`> | (`context`: [`CommandContext`](CommandContext)) => `void` | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`> | (`context`: [`ComponentContext`](ComponentContext)) => `void` | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`> | (`context`: [`ModalContext`](ModalContext)) => `void` | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`> | (`context`: [`AutocompleteCommandContext`](AutocompleteCommandContext)) => `void` | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`>)\[]>

#### Defined in

[src/structures/YorClient.ts:85](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L85)

***

### modals

• `Readonly` **modals**: `Collection`\<`string`, [`YorInteractionModal`](YorInteractionModal)>

#### Defined in

[src/structures/YorClient.ts:72](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L72)

***

### options

• `Readonly` **options**: [`YorClientOptions`](../interfaces/YorClientOptions)

#### Defined in

[src/structures/YorClient.ts:66](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L66)

***

### rest

• **rest**: `REST`

#### Defined in

[src/structures/YorClient.ts:82](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L82)

***

### userCommands

• `Readonly` **userCommands**: `Collection`\<`string`, [`YorUserContextMenuCommand`](YorUserContextMenuCommand)>

#### Defined in

[src/structures/YorClient.ts:77](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L77)

## 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`](../modules#middlewarefunctionnames) |

#### Parameters

| Name         | Type                                                        | Description                 |
| :----------- | :---------------------------------------------------------- | :-------------------------- |
| `name`       | `T`                                                         | The name of the middleware. |
| `middleware` | [`MiddlewareFunction`](../modules#middlewarefunction)\<`T`> | The middleware function.    |

#### Returns

`void`

#### Defined in

[src/structures/YorClient.ts:410](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L410)

***

### deployCommands

▸ **deployCommands**(`guild?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`RESTPutAPIApplicationCommandsResult`>

Deploys the commands to the API application and returns the result.

#### Parameters

| Name     | Type     |
| :------- | :------- |
| `guild?` | `string` |

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`RESTPutAPIApplicationCommandsResult`>

The result of the deployment.

#### Defined in

[src/structures/YorClient.ts:246](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L246)

***

### handleInteraction

▸ **handleInteraction**(`request`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`APIInteractionResponse`>

Handles an interaction request from the API.

#### Parameters

| Name      | Type                                                            | Description                                         |
| :-------- | :-------------------------------------------------------------- | :-------------------------------------------------- |
| `request` | [`Request`](https://developer.mozilla.org/docs/Web/API/Request) | The request object containing the interaction data. |

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`APIInteractionResponse`>

* An object containing a promise for the response.

#### Defined in

[src/structures/YorClient.ts:423](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L423)

***

### handleInteractionRequest

▸ **handleInteractionRequest**(`data`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<\{ `type`: `InteractionResponseType` = InteractionResponseType.PONG }>

Handles the interaction request.

#### Parameters

| Name   | Type             | Description           |
| :----- | :--------------- | :-------------------- |
| `data` | `APIInteraction` | The interaction data. |

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<\{ `type`: `InteractionResponseType` = InteractionResponseType.PONG }>

#### Defined in

[src/structures/YorClient.ts:459](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L459)

***

### registerCommand

▸ **registerCommand**(`command`): `Collection`\<`string`, [`YorSlashCommand`](YorSlashCommand)>

Registers a slash command.

#### Parameters

| Name      | Type                                 | Description                    |
| :-------- | :----------------------------------- | :----------------------------- |
| `command` | [`YorSlashCommand`](YorSlashCommand) | The slash command to register. |

#### Returns

`Collection`\<`string`, [`YorSlashCommand`](YorSlashCommand)>

* The updated commands collection.

#### Defined in

[src/structures/YorClient.ts:119](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L119)

***

### registerCommands

▸ **registerCommands**(`commands`): `Collection`\<`string`, [`YorSlashCommand`](YorSlashCommand)>

Registers the provided slash commands.

#### Parameters

| Name       | Type                                    | Description                     |
| :--------- | :-------------------------------------- | :------------------------------ |
| `commands` | [`YorSlashCommand`](YorSlashCommand)\[] | The slash commands to register. |

#### Returns

`Collection`\<`string`, [`YorSlashCommand`](YorSlashCommand)>

* The updated commands map.

#### Defined in

[src/structures/YorClient.ts:137](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L137)

***

### registerComponent

▸ **registerComponent**(`component`): `Collection`\<`string`, [`YorInteractionComponent`](YorInteractionComponent)>

Registers a component in the collection.

#### Parameters

| Name        | Type                                                 | Description                |
| :---------- | :--------------------------------------------------- | :------------------------- |
| `component` | [`YorInteractionComponent`](YorInteractionComponent) | The component to register. |

#### Returns

`Collection`\<`string`, [`YorInteractionComponent`](YorInteractionComponent)>

* The updated collection of components.

#### Defined in

[src/structures/YorClient.ts:274](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L274)

***

### registerComponents

▸ **registerComponents**(`components`): `Collection`\<`string`, [`YorInteractionComponent`](YorInteractionComponent)>

Registers the given components in the collection.

#### Parameters

| Name         | Type                                                    | Description                 |
| :----------- | :------------------------------------------------------ | :-------------------------- |
| `components` | [`YorInteractionComponent`](YorInteractionComponent)\[] | The components to register. |

#### Returns

`Collection`\<`string`, [`YorInteractionComponent`](YorInteractionComponent)>

* The updated collection of components.

#### Defined in

[src/structures/YorClient.ts:293](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L293)

***

### registerMessageCommand

▸ **registerMessageCommand**(`command`): `Collection`\<`string`, [`YorMessageContextMenuCommand`](YorMessageContextMenuCommand)>

Registers a message command.

#### Parameters

| Name      | Type                                                           | Description                      |
| :-------- | :------------------------------------------------------------- | :------------------------------- |
| `command` | [`YorMessageContextMenuCommand`](YorMessageContextMenuCommand) | The message command to register. |

#### Returns

`Collection`\<`string`, [`YorMessageContextMenuCommand`](YorMessageContextMenuCommand)>

* The updated message commands collection.

#### Defined in

[src/structures/YorClient.ts:195](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L195)

***

### registerModal

▸ **registerModal**(`modal`): `Collection`\<`string`, [`YorInteractionModal`](YorInteractionModal)>

Registers a modal in the collection.

#### Parameters

| Name    | Type                                         | Description                 |
| :------ | :------------------------------------------- | :-------------------------- |
| `modal` | [`YorInteractionModal`](YorInteractionModal) | The modal to be registered. |

#### Returns

`Collection`\<`string`, [`YorInteractionModal`](YorInteractionModal)>

* The updated collection of modals.

#### Defined in

[src/structures/YorClient.ts:344](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L344)

***

### registerModals

▸ **registerModals**(`modals`): `Collection`\<`string`, [`YorInteractionModal`](YorInteractionModal)>

Registers the given modals in the collection.

#### Parameters

| Name     | Type                                            | Description                  |
| :------- | :---------------------------------------------- | :--------------------------- |
| `modals` | [`YorInteractionModal`](YorInteractionModal)\[] | The modals to be registered. |

#### Returns

`Collection`\<`string`, [`YorInteractionModal`](YorInteractionModal)>

* The updated collection of modals.

#### Defined in

[src/structures/YorClient.ts:361](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L361)

***

### registerUserCommand

▸ **registerUserCommand**(`command`): `Collection`\<`string`, [`YorUserContextMenuCommand`](YorUserContextMenuCommand)>

Registers a user command.

#### Parameters

| Name      | Type                                                     | Description                   |
| :-------- | :------------------------------------------------------- | :---------------------------- |
| `command` | [`YorUserContextMenuCommand`](YorUserContextMenuCommand) | The user command to register. |

#### Returns

`Collection`\<`string`, [`YorUserContextMenuCommand`](YorUserContextMenuCommand)>

* The updated user commands collection.

#### Defined in

[src/structures/YorClient.ts:221](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L221)

***

### unregisterAllCommands

▸ **unregisterAllCommands**(): `Collection`\<`string`, [`YorSlashCommand`](YorSlashCommand)>

Unregisters all slash commands.

#### Returns

`Collection`\<`string`, [`YorSlashCommand`](YorSlashCommand)>

* The updated commands map.

#### Defined in

[src/structures/YorClient.ts:184](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L184)

***

### unregisterCommand

▸ **unregisterCommand**(`command`): `Collection`\<`string`, [`YorSlashCommand`](YorSlashCommand)>

Unregisters a slash command.

#### Parameters

| Name      | Type                                 | Description                      |
| :-------- | :----------------------------------- | :------------------------------- |
| `command` | [`YorSlashCommand`](YorSlashCommand) | The slash command to unregister. |

#### Returns

`Collection`\<`string`, [`YorSlashCommand`](YorSlashCommand)>

* The updated commands collection.

#### Defined in

[src/structures/YorClient.ts:157](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L157)

***

### unregisterCommands

▸ **unregisterCommands**(`commands`): `Collection`\<`string`, [`YorSlashCommand`](YorSlashCommand)>

Unregisters the provided slash commands.

#### Parameters

| Name       | Type                                    | Description                       |
| :--------- | :-------------------------------------- | :-------------------------------- |
| `commands` | [`YorSlashCommand`](YorSlashCommand)\[] | The slash commands to unregister. |

#### Returns

`Collection`\<`string`, [`YorSlashCommand`](YorSlashCommand)>

* The updated commands map.

#### Defined in

[src/structures/YorClient.ts:170](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L170)

***

### unregisterComponent

▸ **unregisterComponent**(`component`): `Collection`\<`string`, [`YorInteractionComponent`](YorInteractionComponent)>

Deletes the specified component from the collection and returns the updated collection.

#### Parameters

| Name        | Type                                                 | Description                  |
| :---------- | :--------------------------------------------------- | :--------------------------- |
| `component` | [`YorInteractionComponent`](YorInteractionComponent) | The component to unregister. |

#### Returns

`Collection`\<`string`, [`YorInteractionComponent`](YorInteractionComponent)>

* The updated collection of components.

#### Defined in

[src/structures/YorClient.ts:314](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L314)

***

### unregisterComponents

▸ **unregisterComponents**(`components`): `Collection`\<`string`, [`YorInteractionComponent`](YorInteractionComponent)>

Unregisters components from the collection.

#### Parameters

| Name         | Type                                                    | Description                   |
| :----------- | :------------------------------------------------------ | :---------------------------- |
| `components` | [`YorInteractionComponent`](YorInteractionComponent)\[] | The components to unregister. |

#### Returns

`Collection`\<`string`, [`YorInteractionComponent`](YorInteractionComponent)>

* The updated components collection.

#### Defined in

[src/structures/YorClient.ts:328](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L328)

***

### unregisterMessageCommand

▸ **unregisterMessageCommand**(`command`): `Collection`\<`string`, [`YorMessageContextMenuCommand`](YorMessageContextMenuCommand)>

Unregisters a message command.

#### Parameters

| Name      | Type                                                           | Description                        |
| :-------- | :------------------------------------------------------------- | :--------------------------------- |
| `command` | [`YorMessageContextMenuCommand`](YorMessageContextMenuCommand) | The message command to unregister. |

#### Returns

`Collection`\<`string`, [`YorMessageContextMenuCommand`](YorMessageContextMenuCommand)>

* The updated message commands collection.

#### Defined in

[src/structures/YorClient.ts:208](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L208)

***

### unregisterModal

▸ **unregisterModal**(`modal`): `Collection`\<`string`, [`YorInteractionModal`](YorInteractionModal)>

Deletes the specified modal from the collection and returns the updated collection.

#### Parameters

| Name    | Type                                         | Description              |
| :------ | :------------------------------------------- | :----------------------- |
| `modal` | [`YorInteractionModal`](YorInteractionModal) | The modal to unregister. |

#### Returns

`Collection`\<`string`, [`YorInteractionModal`](YorInteractionModal)>

* The updated collection of modals.

#### Defined in

[src/structures/YorClient.ts:380](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L380)

***

### unregisterModals

▸ **unregisterModals**(`modals`): `Collection`\<`string`, [`YorInteractionModal`](YorInteractionModal)>

Unregisters modals from the collection.

#### Parameters

| Name     | Type                                            | Description               |
| :------- | :---------------------------------------------- | :------------------------ |
| `modals` | [`YorInteractionModal`](YorInteractionModal)\[] | The modals to unregister. |

#### Returns

`Collection`\<`string`, [`YorInteractionModal`](YorInteractionModal)>

* The updated collection of modals.

#### Defined in

[src/structures/YorClient.ts:394](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L394)

***

### unregisterUserCommand

▸ **unregisterUserCommand**(`command`): `Collection`\<`string`, [`YorUserContextMenuCommand`](YorUserContextMenuCommand)>

Unregisters a user command.

#### Parameters

| Name      | Type                                                     | Description                     |
| :-------- | :------------------------------------------------------- | :------------------------------ |
| `command` | [`YorUserContextMenuCommand`](YorUserContextMenuCommand) | The user command to unregister. |

#### Returns

`Collection`\<`string`, [`YorUserContextMenuCommand`](YorUserContextMenuCommand)>

* The updated user commands collection.

#### Defined in

[src/structures/YorClient.ts:234](https://github.com/OreOreki/yor.ts/blob/ff21935/src/structures/YorClient.ts#L234)
