import { Component, ComponentAPI } from '@ayanaware/bento'; import { CommandInteraction, Message } from 'eris'; import { PossiblyTranslatable } from '../interfaces/Translatable'; import { AnyCommandContext } from './CommandContext'; import { OptionType } from './constants/OptionType'; import { SuppressorType } from './constants/SuppressorType'; import type { Command } from './interfaces/Command'; import { CommandDefinition, CommandPermissionDefaults } from './interfaces/CommandDefinition'; import type { AnyCommandOption, AnyValueCommandOption, CommandOptionSubCommand, CommandOptionSubCommandGroup } from './interfaces/CommandOption'; import type { Resolver } from './interfaces/Resolver'; import type { Suppressor } from './interfaces/Suppressor'; import type { CommandEntity } from './interfaces/entity/CommandEntity'; import type { ResolverEntity } from './interfaces/entity/ResolverEntity'; import type { SuppressorEntity } from './interfaces/entity/SuppressorEntity'; export interface CommandDetails { /** The command */ command: Command; /** Command Definition */ definition: CommandDefinition; /** Command category */ category?: string; /** Command permissions */ permissions: Array; } export interface CommandPermissionDetails { /** The permission name */ permission: string; /** Default state of this permission */ defaults: CommandPermissionDefaults; /** Is this a hidden permission */ hidden: boolean; /** Subcommand path for this permission */ path?: Array; } export declare class CommandManager implements Component { name: string; api: ComponentAPI; defaultPrefix: string; ignoreMode: string; private readonly interface; private readonly discord; private readonly commands; private readonly aliases; private readonly resolvers; private readonly suppressors; onLoad(): Promise; onChildLoad(entity: CommandEntity | ResolverEntity | SuppressorEntity): Promise; onChildUnload(entity: CommandEntity | ResolverEntity | SuppressorEntity): Promise; /** * Add Resolver * @param resolver OptionResolver */ addResolver(resolver: Resolver): void; /** * Remove Resolver * @param type OptionType or string */ removeResolver(type: OptionType | string): void; getResolvers(): Map>; findResolver(type: OptionType | string): Resolver; private executeResolver; /** * Add Suppressor * @param suppressor Suppressor */ addSuppressor(suppressor: Suppressor): void; /** * Remove Suppressors * @param type SuppressorType or string */ removeSuppressor(type: SuppressorType | string): void; private executeSuppressors; /** * Get prefix for a guild * @param snowflake guildId * @returns prefix */ getPrefix(snowflake?: string): Promise; /** * Set prefix for a guild * @param snowflake guildId * @param prefix new prefix */ setPrefix(snowflake: string, prefix: string): Promise; /** * Get primary name of command alias or option name * @param name string or array of string and translatables. First element is always a string * @returns string */ getPrimaryName(name: string | [string, ...Array]): string; /** * Get all translations for a possibly translatable * @param item Array * @returns Array of Tuple [string, Array<{ lang: string }>] */ getItemTranslations(items: PossiblyTranslatable | Array, normalize?: boolean): Promise]>>; /** * Get all commands and their details */ getCommands(): Map; getCategorizedCommands(): Map>; isSubCommand(option: AnyCommandOption): option is CommandOptionSubCommand; isSubCommandGroup(option: AnyCommandOption): option is CommandOptionSubCommandGroup; isAnySubCommand(option: AnyCommandOption): option is CommandOptionSubCommand | CommandOptionSubCommandGroup; /** * Add command * @param command Command */ addCommand(command: Command): Promise; /** * Remove Command * @param command Command */ removeCommand(command: Command | string): void; /** * Find Command by alias * @param alias Alias * @returns Command */ findCommand(alias: string): Command; /** * Get all valid command related permissions, include all and categories * @returns Map of permission => CommandPermissionDetails */ getPermissions(): Map; /** * Runs pre-flight checks such as perms & suppressors before executing command * @param command Command * @param ctx CommandContext * @returns boolean, if false you should not execute the command */ prepareCommand(command: Command, ctx: AnyCommandContext): Promise; executeCommand(command: Command, ctx: AnyCommandContext, options: Record): Promise; getPermissionDetails(command: Command): Array; getTypePreview(option: AnyValueCommandOption): string; fufillInteractionOptions(ctx: AnyCommandContext, definition: CommandDefinition, data: CommandInteraction['data']): Promise>; private processInteractionOptions; /** * Matches up input text with options * @param options Array of CommandOption * @param input User input */ fufillTextOptions(ctx: AnyCommandContext, definition: CommandDefinition, input: string): Promise>; private processTextOptions; private resolveOption; private handleInteractionCreate; handleMessageCreate(message: Message): Promise; }