Skip to content

Commit

Permalink
fix: minor improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
en9inerd committed Feb 21, 2024
1 parent 4d9f438 commit a2e8dad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/decorators/params-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { NewMessageEvent } from 'telegram/events/NewMessage.js';
import { DecoratorException } from '../exceptions.js';
import { commandParamsSchema } from '../keys.js';
import { CommandParamsSchema, ExtendedMessage, ValidatedCommandParams } from '../types.js';
import { CommandParamsSchema, MessageWithParams, ValidatedCommandParams } from '../types.js';

export function paramsValidation<This, Args extends any[], Return>(
target: (this: This, ...args: Args) => Return,
Expand Down Expand Up @@ -69,7 +69,7 @@ export function paramsValidation<This, Args extends any[], Return>(
return;
}

(<ExtendedMessage>event.message).params = validatedParams;
(<MessageWithParams>event.message).params = validatedParams;
}

return await target.apply(this, args);
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type CommandParamsSchema = Dict<ParamSchema>;

export type ValidatedCommandParams = Dict<string | number | boolean>;

export type ExtendedMessage = Api.Message & { params?: ValidatedCommandParams };
export type MessageWithParams<T = unknown> = Api.Message & { params?: T };

export type ExtendedCommand = Command & Record<symbol, Map<string, EventInterface>> & Record<string, CommandHandler>;

Expand Down

0 comments on commit a2e8dad

Please sign in to comment.