import { XOR, getFilesList, getInteractionResponders, getMessageResponders, type SubCommand as Sub } from "@elara-services/utils"; import type { AutocompleteInteraction, ChatInputCommandInteraction, ContextMenuCommandBuilder, GuildMember, Message, MessageContextMenuCommandInteraction, SlashCommandBuilder as SBuild, SlashCommandOptionsOnlyBuilder, UserContextMenuCommandInteraction } from "discord.js"; import { Interact } from "./pager"; export type CachedInt = ChatInputCommandInteraction; export type AnyBuilder = XOR; export type Defer = XOR<{ silent: boolean; }, { filter: (i: I) => boolean; }>; export type Status = { status: true; } | { status: false; message: string; }; export type Pre = Promise | Status | boolean; export interface IntOptions { roles?: string[]; users?: string[]; channels?: string[]; permissions?: (member: GuildMember) => Status; } export interface PageData { id: string; deferUpdate: boolean; data: unknown; handler: AddPageData["handler"]; } export interface AddPageData { id?: string; deferUpdate?: boolean; data?: unknown; handler?: () => Promise | unknown; } export type OnlyOptions = { guild?: boolean; threads?: boolean; text?: boolean; voice?: boolean; dms?: boolean; /** Guild ids to register the commands in only. */ guilds?: string[]; }; export interface DisableOptions extends IntOptions { until?: Date | string; } export interface Common { enabled?: boolean; defer?: Defer; aliases?: string[]; locked?: IntOptions; disabled?: DisableOptions; only?: OnlyOptions; execute: (i: T, r: getInteractionResponders, ctx: Interact) => Promise | unknown; pre?: (interaction: T, cmd: SlashCommand) => Pre; autocomplete?: (i: AutocompleteInteraction) => Promise | unknown; } export interface SubCommand extends Sub, Omit, "aliases"> { } export interface SlashCommand extends Common { command: Partial | ((builder: Partial) => Partial); } export interface UserContextMenuCommand extends Common { command: Partial; } export interface MessageContextMenuCommand extends Common { command: Partial; } export interface PrefixCommand { name: string; enabled?: boolean; aliases?: string[]; locked?: IntOptions; disabled?: DisableOptions; only?: OnlyOptions; execute(message: Message, responder: getMessageResponders): Promise | unknown; pre?: (message: Message, cmd: PrefixCommand) => Pre; } export { getFilesList };