diff --git a/packages/client/src/client.ts b/packages/client/src/client.ts index a31046ea..e5bb71da 100644 --- a/packages/client/src/client.ts +++ b/packages/client/src/client.ts @@ -975,59 +975,55 @@ export interface TelegramClient extends BaseTelegramClient { /** * Set a score of a user in a game * - * @param chatId Chat where the game was found - * @param message ID of the message where the game was found - * @param userId ID of the user who has scored - * @param score The new score (must be >0) * @param params * @returns The modified message */ - setGameScore( - chatId: InputPeerLike, - message: number, - userId: InputPeerLike, - score: number, - params?: { - /** - * When `true`, the game message will not be modified - * to include the new score - */ - noEdit?: boolean + setGameScore(params: { + /** Chat where the game was found */ + chatId: InputPeerLike + /** ID of the message where the game was found */ + message: number + /** ID of the user who has scored */ + userId: InputPeerLike + /** The new score (must be >0) */ + score: number + /** + * When `true`, the game message will not be modified + * to include the new score + */ + noEdit?: boolean - /** - * Whether to allow user's score to decrease. - * This can be useful when fixing mistakes or banning cheaters - */ - force?: boolean - } - ): Promise + /** + * Whether to allow user's score to decrease. + * This can be useful when fixing mistakes or banning cheaters + */ + force?: boolean + }): Promise /** * Set a score of a user in a game contained in * an inline message * - * @param messageId ID of the inline message - * @param userId ID of the user who has scored - * @param score The new score (must be >0) * @param params */ - setInlineGameScore( - messageId: string | tl.TypeInputBotInlineMessageID, - userId: InputPeerLike, - score: number, - params?: { - /** - * When `true`, the game message will not be modified - * to include the new score - */ - noEdit?: boolean + setInlineGameScore(params: { + /** ID of the inline message */ + messageId: string | tl.TypeInputBotInlineMessageID + /** ID of the user who has scored */ + userId: InputPeerLike + /** The new score (must be >0) */ + score: number + /** + * When `true`, the game message will not be modified + * to include the new score + */ + noEdit?: boolean - /** - * Whether to allow user's score to decrease. - * This can be useful when fixing mistakes or banning cheaters - */ - force?: boolean - } - ): Promise + /** + * Whether to allow user's score to decrease. + * This can be useful when fixing mistakes or banning cheaters + */ + force?: boolean + }): Promise /** * Set or delete commands for the current bot and the given scope * diff --git a/packages/client/src/methods/bots/set-game-score.ts b/packages/client/src/methods/bots/set-game-score.ts index 86b127ff..2ff10503 100644 --- a/packages/client/src/methods/bots/set-game-score.ts +++ b/packages/client/src/methods/bots/set-game-score.ts @@ -8,21 +8,21 @@ import { normalizeToInputUser } from '../../utils/peer-utils' /** * Set a score of a user in a game * - * @param chatId Chat where the game was found - * @param message ID of the message where the game was found - * @param userId ID of the user who has scored - * @param score The new score (must be >0) * @param params * @returns The modified message * @internal */ export async function setGameScore( this: TelegramClient, - chatId: InputPeerLike, - message: number, - userId: InputPeerLike, - score: number, - params?: { + params: { + /** Chat where the game was found */ + chatId: InputPeerLike + /** ID of the message where the game was found */ + message: number + /** ID of the user who has scored */ + userId: InputPeerLike + /** The new score (must be >0) */ + score: number /** * When `true`, the game message will not be modified * to include the new score @@ -36,7 +36,7 @@ export async function setGameScore( force?: boolean }, ): Promise { - if (!params) params = {} + const { chatId, message, userId, score, noEdit, force } = params const user = normalizeToInputUser(await this.resolvePeer(userId), userId) const chat = await this.resolvePeer(chatId) @@ -47,8 +47,8 @@ export async function setGameScore( id: message, userId: user, score, - editMessage: !params.noEdit, - force: params.force, + editMessage: !noEdit, + force, }) return this._findMessageInUpdate(res, true) @@ -58,18 +58,18 @@ export async function setGameScore( * Set a score of a user in a game contained in * an inline message * - * @param messageId ID of the inline message - * @param userId ID of the user who has scored - * @param score The new score (must be >0) * @param params * @internal */ export async function setInlineGameScore( this: TelegramClient, - messageId: string | tl.TypeInputBotInlineMessageID, - userId: InputPeerLike, - score: number, - params?: { + params: { + /** ID of the inline message */ + messageId: string | tl.TypeInputBotInlineMessageID + /** ID of the user who has scored */ + userId: InputPeerLike + /** The new score (must be >0) */ + score: number /** * When `true`, the game message will not be modified * to include the new score @@ -83,7 +83,7 @@ export async function setInlineGameScore( force?: boolean }, ): Promise { - if (!params) params = {} + const { messageId, userId, score, noEdit, force } = params const user = normalizeToInputUser(await this.resolvePeer(userId), userId) @@ -95,8 +95,8 @@ export async function setInlineGameScore( id, userId: user, score, - editMessage: !params.noEdit, - force: params.force, + editMessage: !noEdit, + force: force, }, { dcId: id.dcId }, )