From 8d850b9779575ef16e931248cef4927c7f09e130 Mon Sep 17 00:00:00 2001 From: Roz <3948961+roziscoding@users.noreply.github.com> Date: Wed, 6 Nov 2024 12:38:11 -0300 Subject: [PATCH] fix: register default scope handler last --- src/command.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/command.ts b/src/command.ts index 90cfedb..0a6b60d 100644 --- a/src/command.ts +++ b/src/command.ts @@ -38,6 +38,7 @@ export class Command implements MiddlewareObj { { name: string | RegExp; description: string } > = new Map(); private _composer: Composer = new Composer(); + private _defaultScopeComposer = new Composer(); private _options: CommandOptions = { prefix: "/", matchOnlyAtStart: true, @@ -274,7 +275,7 @@ export class Command implements MiddlewareObj { if (middlewareArray) { switch (scope.type) { case "default": - this._composer + this._defaultScopeComposer .filter(Command.hasCommand(this.names, optionsObject)) .use(...middlewareArray); break; @@ -445,6 +446,9 @@ export class Command implements MiddlewareObj { } middleware() { - return this._composer.middleware(); + return new Composer() + .use(this._composer) + .use(this._defaultScopeComposer) + .middleware(); } }