generated from didinele/typescript-docker-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
123 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,69 @@ | ||
import type { APIInteraction } from '@discordjs/core'; | ||
import type { | ||
APIApplicationCommandAutocompleteInteraction, | ||
APIApplicationCommandInteraction, | ||
APIApplicationCommandInteractionDataIntegerOption, | ||
APIApplicationCommandInteractionDataNumberOption, | ||
APIApplicationCommandInteractionDataStringOption, | ||
APIInteraction, | ||
APIMessageComponentInteraction, | ||
APIModalSubmitInteraction, | ||
RESTPostAPIApplicationCommandsJSONBody, | ||
} from '@discordjs/core'; | ||
import type { InteractionOptionResolver } from '@sapphire/discord-utilities'; | ||
|
||
export interface ResolvedCommandIdentifier { | ||
root: ApplicationCommandIdentifier; | ||
subcommand?: ApplicationCommandIdentifier; | ||
} | ||
|
||
/** | ||
* The identifier of a command. | ||
* `name:group:subcommand` | ||
*/ | ||
export type ApplicationCommandIdentifier = `${string}:${string}:${string}`; | ||
|
||
/** | ||
* Callback responsible for handling application commands. | ||
*/ | ||
export type ApplicationCommandHandler = ( | ||
interaction: APIApplicationCommandInteraction, | ||
options: InteractionOptionResolver, | ||
) => Promise<void>; | ||
|
||
/** | ||
* Callback responsible for handling components. | ||
*/ | ||
export type ComponentHandler = (interaction: APIMessageComponentInteraction, args: string[]) => Promise<void>; | ||
|
||
// [command]:argName | ||
export type AutocompleteIdentifier = `${ApplicationCommandIdentifier}:${string}`; | ||
|
||
/** | ||
* Callback responsible for handling autocompletes. | ||
*/ | ||
export type AutocompleteHandler = ( | ||
interaction: APIApplicationCommandAutocompleteInteraction, | ||
option: | ||
| APIApplicationCommandInteractionDataIntegerOption | ||
| APIApplicationCommandInteractionDataNumberOption | ||
| APIApplicationCommandInteractionDataStringOption, | ||
) => Promise<void>; | ||
|
||
/** | ||
* Callback responsible for handling modals. | ||
*/ | ||
export type ModalHandler = (interaction: APIModalSubmitInteraction, args: string[]) => Promise<void>; | ||
|
||
export interface RegisterOptions { | ||
applicationCommands?: [ApplicationCommandIdentifier, ApplicationCommandHandler][]; | ||
autocomplete?: [AutocompleteIdentifier, AutocompleteHandler][]; | ||
components?: [string, ComponentHandler][]; | ||
interactions?: RESTPostAPIApplicationCommandsJSONBody[]; | ||
modals?: [string, ModalHandler][]; | ||
} | ||
|
||
export abstract class ICommandHandler { | ||
public abstract handle(interaction: APIInteraction): Promise<void>; | ||
public abstract register(options: RegisterOptions): void; | ||
public abstract deployCommands(): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.