diff --git a/typings.ts b/typings.ts index 610946b..5817373 100644 --- a/typings.ts +++ b/typings.ts @@ -1,23 +1,24 @@ import * as Discord from "discord.js"; +declare type i18next = typeof import("i18next"); declare type GuildDB = typeof import("./db/guilds"); declare type UserDB = typeof import("./db/users"); +export type ComponentType = "button" | "selectmenu" | "autocomplete" | "modalSubmit" + /** - * Модифікований вбудований клієнт із підтримкою обробників команд/подій. + * @description Modified built-in client with support for command/event handlers. */ export interface MainClient extends Discord.Client { commands: Discord.Collection; cooldowns: Discord.Collection>; - buttons: Discord.Collection; - selectMenus: Discord.Collection; - modals: Discord.Collection; - autocompletes: Discord.Collection; + components: Discord.Collection; dbguild: GuildDB; dbuser: UserDB; + i18n: i18next; }; /** - * Представляє команду програми. + * @description Represents the program command. */ export interface Command { data: Discord.SlashCommandBuilder | Discord.ContextMenuCommandBuilder; @@ -32,45 +33,80 @@ export interface Command { }; /** - * Представляє кнопки програми. + * @description Represents a component of the program. */ -export interface ButtonInteraction { - id: string; +export interface Component { + name: string; + type: ComponentType; options: { - cooldown?: number, - ownerOnly?: boolean + cooldown?: number; + ownerOnly?: boolean; + devGuildOnly?: boolean; + bot_permissions?: [Discord.PermissionResolvable] | []; }; - execute(interaction: Discord.ButtonInteraction & { client: MainClient }): void | Promise; -}; + execute(interaction: Discord.ButtonInteraction | Discord.AnySelectMenuInteraction | Discord.ModalSubmitInteraction | Discord.AutocompleteInteraction): Promise; +} /** - * Представляє меню вибору програми. + * @description Represents a button component of the program. */ -export interface SelectMenuInteraction { - id: string; - options: { - cooldown?: number, - ownerOnly?: boolean - }; +export interface Button extends Component { + execute(interaction: Discord.ButtonInteraction): Promise; +} - execute(interaction: Discord.AnySelectMenuInteraction & { client: MainClient }): void | Promise; -}; +/** + * @description Represents a any select menu component of the program. + */ +export interface SelectMenu extends Component { + execute(interaction: Discord.StringSelectMenuInteraction | Discord.UserSelectMenuInteraction | Discord.MentionableSelectMenuInteraction | Discord.ChannelSelectMenuInteraction | Discord.RoleSelectMenuInteraction): Promise; +} /** - * Представляє модальні вікна програми. + * @description Represents a string select menu component of the program. */ -export interface ModalInteraction { - id: string; +export interface StringSelectMenu extends SelectMenu { + execute(interaction: Discord.StringSelectMenuInteraction): Promise; +} - execute(interaction: Discord.ModalSubmitInteraction & { client: MainClient }): void | Promise; -}; +/** + * @description Represents a user select menu component of the program. + */ +export interface UserSelectMenu extends SelectMenu { + execute(interaction: Discord.UserSelectMenuInteraction): Promise; +} /** - * Представляє автозаповнення програми. + * @description Represents a mentionable select menu component of the program. */ -export interface AutocompleteInteraction { - name: string; +export interface MentionableSelectMenu extends SelectMenu { + execute(interaction: Discord.MentionableSelectMenuInteraction): Promise; +} - execute(interaction: Discord.AutocompleteInteraction & { client: MainClient }): void | Promise; -}; +/** + * @description Represents a channel select menu component of the program. + */ +export interface ChannelSelectMenu extends SelectMenu { + execute(interaction: Discord.ChannelSelectMenuInteraction): Promise; +} + +/** + * @description Represents a role select menu component of the program. + */ +export interface RoleSelectMenu extends SelectMenu { + execute(interaction: Discord.RoleSelectMenuInteraction): Promise; +} + +/** + * @description Represents a modal submit component of the program. + */ +export interface Modal extends Component { + execute(interaction: Discord.ModalSubmitInteraction): Promise; +} + +/** + * @description Represents a autocomplete component of the program. + */ +export interface Autocomplete extends Component { + execute(interaction: Discord.AutocompleteInteraction): Promise; +} \ No newline at end of file