From d5b4b381416f5bfdb186e52f12867911c53b9d76 Mon Sep 17 00:00:00 2001 From: GamesTwoLifeTwoLife Date: Tue, 12 Mar 2024 14:46:51 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=9E=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D1=82=D0=B8=D0=BF=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Додано нові типи, оновлено існуючі типи та змінено типи. --- typings.ts | 100 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 32 deletions(-) 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