diff --git a/src/composer.ts b/src/composer.ts index 52765807..293bcc23 100644 --- a/src/composer.ts +++ b/src/composer.ts @@ -11,7 +11,7 @@ import { type PreCheckoutQueryContext, type ReactionContext, type ShippingQueryContext, - type StringWithSuggestions, + type StringWithCommandSuggestions, } from "./context.ts"; import { type Filter, type FilterQuery } from "./filter.ts"; import { @@ -380,10 +380,8 @@ export class Composer implements MiddlewareObj { * @param command The command to look for * @param middleware The middleware to register */ - command( - command: MaybeArray< - StringWithSuggestions - >, + command( + command: MaybeArray, ...middleware: Array> ): Composer> { return this.filter(Context.has.command(command), ...middleware); diff --git a/src/context.ts b/src/context.ts index f7bd5e73..3c51922c 100644 --- a/src/context.ts +++ b/src/context.ts @@ -32,9 +32,13 @@ import { // === Util types export type MaybeArray = T | T[]; -export type StringWithSuggestions = +/** permits `string` but gives hints */ +export type StringWithCommandSuggestions = | (string & Record) - | S; // permits `string` but gives hints + | "start" + | "help" + | "settings" + | "privacy"; type Other, X extends string = never> = OtherApi< RawApi, @@ -76,10 +80,8 @@ interface StaticHas { * * @param command The command to match */ - command( - command: MaybeArray< - StringWithSuggestions - >, + command( + command: MaybeArray, ): (ctx: C) => ctx is CommandContext; /** * Generates a predicate function that can test context objects for @@ -819,10 +821,8 @@ export class Context implements RenamedUpdate { * * @param command The command to match */ - hasCommand( - command: MaybeArray< - StringWithSuggestions - >, + hasCommand( + command: MaybeArray, ): this is CommandContextCore { return Context.has.command(command)(this); }