Skip to content

Commit

Permalink
fix: register default scope handler last
Browse files Browse the repository at this point in the history
  • Loading branch information
roziscoding authored Nov 6, 2024
1 parent 4421272 commit 8d850b9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class Command<C extends Context = Context> implements MiddlewareObj<C> {
{ name: string | RegExp; description: string }
> = new Map();
private _composer: Composer<C> = new Composer<C>();
private _defaultScopeComposer = new Composer<C>();
private _options: CommandOptions = {
prefix: "/",
matchOnlyAtStart: true,
Expand Down Expand Up @@ -274,7 +275,7 @@ export class Command<C extends Context = Context> implements MiddlewareObj<C> {
if (middlewareArray) {
switch (scope.type) {
case "default":
this._composer
this._defaultScopeComposer
.filter(Command.hasCommand(this.names, optionsObject))
.use(...middlewareArray);
break;
Expand Down Expand Up @@ -445,6 +446,9 @@ export class Command<C extends Context = Context> implements MiddlewareObj<C> {
}

middleware() {
return this._composer.middleware();
return new Composer<C>()
.use(this._composer)
.use(this._defaultScopeComposer)
.middleware();
}
}

0 comments on commit 8d850b9

Please sign in to comment.