import { Client, Message } from "discord.js"; import { Awaitable } from "../../utils"; import { ICommandConfig as MessageCommandConfig, ICommandDefinition as MessageCommandDefinition, IParameter as MessageCommandParameter, TOption as MessageCommandOption, TSignature as MessageCommandSignature } from "knub-command-manager"; import { Lock } from "../../locks/LockManager"; import { AnyPluginData, GuildPluginData } from "../../plugins/PluginData"; import { MessageCommandBlueprint } from "./messageCommandBlueprint"; import { BasePluginType } from "../../plugins/pluginTypes"; import { GuildMessage } from "../../types"; export type MessageCommandSignatureOrArray> = MessageCommandSignature> | Array>>; export declare function getDefaultMessageCommandPrefix(client: Client): RegExp; export type ContextualCommandMessage> = TPluginData extends GuildPluginData ? GuildMessage : Message; export interface MessageCommandMeta, TArguments> { args: TArguments; message: ContextualCommandMessage; command: MessageCommandDefinition; pluginData: TPluginData; lock?: Lock; } /** * Command signatures are objects where each property contains a parameter/option object. * Each parameter/option object in turn contains a `type` function. ArgsFromSignature maps the signature object * to the return types of said type functions. For example, if the signature had a "name" property with a type function * that returns a string, ArgsFromSignature would return `{ name: string }`. */ type MessageCommandArgsFromSignature> = { [K in keyof T]: T[K] extends MessageCommandParameter | MessageCommandOption ? ParameterOrOptionType : never; }; /** * Higher level wrapper for ArgsFromSignature that also supports multiple signatures, * returning a union type of possible sets of arguments. */ export type ArgsFromSignatureOrArray> = ArgsFromSignatureUnion[number]>; type ArgsFromSignatureUnion> = T extends any ? MessageCommandArgsFromSignature : never; type SignatureToArray = T extends any[] ? T : [T]; type PromiseType = T extends PromiseLike ? U : T; type ParameterOrOptionType | MessageCommandOption> = T extends MessageCommandParameter ? T["rest"] extends true ? Array>> : PromiseType> : PromiseType>; export type CommandFn, _TSignature extends MessageCommandSignatureOrArray> = (meta: MessageCommandMeta>) => Awaitable; export interface CommandContext> { message: Message; pluginData: TPluginData; lock?: Lock; } export interface CommandExtraData> { blueprint: MessageCommandBlueprint; _lock?: Lock; } export type PluginCommandDefinition = MessageCommandDefinition, CommandExtraData>; export type PluginCommandConfig = MessageCommandConfig, CommandExtraData>; /** * Returns a readable command signature string for the given command. * Trigger is passed as a string instead of using the "triggers" property of the command to allow choosing which * trigger of potentially multiple ones to show and in what format. */ export declare function getMessageCommandSignature(command: PluginCommandDefinition, overrideTrigger?: string, overrideSignature?: MessageCommandSignature): string; /** * Command pre-filter to restrict the command to the plugin's guilds, unless * allowed for DMs */ export declare function restrictCommandSource(cmd: PluginCommandDefinition, context: CommandContext): boolean; /** * Command pre-filter to restrict the command by specifying a required * permission */ export declare function checkCommandPermission>(cmd: PluginCommandDefinition, context: CommandContext): Promise; /** * Command post-filter to check if the command's on cooldown and, if not, to put * it on cooldown */ export declare function checkCommandCooldown>(cmd: PluginCommandDefinition, context: CommandContext): Promise; /** * Command post-filter to wait for and trigger any locks the command has, and to * interrupt command execution if the lock gets interrupted before it */ export declare function checkCommandLocks>(cmd: PluginCommandDefinition, context: CommandContext): Promise; export {};