From db7d3af6e01d9cc0857cc699b40b697a8a9d7ed7 Mon Sep 17 00:00:00 2001 From: Sempai-07 Date: Sat, 20 Dec 2025 14:28:09 +0200 Subject: [PATCH 01/10] Fix(TransactionPartner): find module Chat --- src/structures/invoice/TransactionPartner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/invoice/TransactionPartner.js b/src/structures/invoice/TransactionPartner.js index a299f4d..42e7a5e 100644 --- a/src/structures/invoice/TransactionPartner.js +++ b/src/structures/invoice/TransactionPartner.js @@ -143,7 +143,7 @@ class TransactionPartner extends Base { } /** - * @returns {this is this & { withdrawal?: undefined; user?: undefined; paidMedia?: PaidMedia[]; paidMediaPayload?: string; gift?: Gift; subscriptionPeriod?: number; affiliate?: AffiliateInfo; sponsorUser?: undefined; commissionRate?: undefined; requestCount?: undefined; chat: import("../misc/Chat").Chat; premiumSubscriptionDuration?: undefined; }} + * @returns {this is this & { withdrawal?: undefined; user?: undefined; paidMedia?: PaidMedia[]; paidMediaPayload?: string; gift?: Gift; subscriptionPeriod?: number; affiliate?: AffiliateInfo; sponsorUser?: undefined; commissionRate?: undefined; requestCount?: undefined; chat: import("../chat/Chat").Chat; premiumSubscriptionDuration?: undefined; }} */ isChat() { return Boolean("chat" in this && this.chat); From 67cb0fa2dcdf5d526c5178ca54c08f2bba79263c Mon Sep 17 00:00:00 2001 From: Sempai-07 Date: Sat, 27 Dec 2025 22:47:55 +0200 Subject: [PATCH 02/10] Typings fixed export --- typings/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 403b6d0..009ebba 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -13216,4 +13216,4 @@ export declare class StarTransactions { export declare const version: "4.11.0"; -export * from "./telegram/index"; +export * from "./telegram/index"; \ No newline at end of file From 8c36298080442b93cd89941a0e591f2d377f601f Mon Sep 17 00:00:00 2001 From: Sempai-07 Date: Sun, 28 Dec 2025 11:20:02 +0200 Subject: [PATCH 03/10] Refactor: use Collection instead of Array --- src/structures/checklist/Checklist.js | 42 ++++-- src/structures/invoice/TransactionPartner.js | 14 +- src/structures/media/paid/PaidMediaInfo.js | 15 +- src/structures/message/MessageEntities.js | 73 +++++---- .../passport/EncryptedPassportElement.js | 23 ++- src/structures/passport/PassportData.js | 13 +- typings/index.d.ts | 139 ++++++++++-------- 7 files changed, 195 insertions(+), 124 deletions(-) diff --git a/src/structures/checklist/Checklist.js b/src/structures/checklist/Checklist.js index 2ac2973..2b5ab98 100644 --- a/src/structures/checklist/Checklist.js +++ b/src/structures/checklist/Checklist.js @@ -2,6 +2,25 @@ const { Base } = require("../Base"); const { ChecklistTask } = require("./ChecklistTask"); const { MessageEntities } = require("../message/MessageEntities"); +const { Collection } = require("@telegram.ts/collection"); + +/** + * Type guard for completed tasks + * @param {ChecklistTask} task + * @returns {task is ChecklistTask & { completionUnixTime: number; completionTimestamp: number; isCompleted: true; completedByUser: import("../misc/User").User }} + */ +function isCompletedTask(task) { + return task.isCompleted === true; +} + +/** + * Type guard for pending tasks + * @param {ChecklistTask} task + * @returns {task is ChecklistTask & { completionUnixTime: undefined; completionTimestamp: undefined; isCompleted: false; completedByUser: undefined }} + */ +function isPendingTask(task) { + return task.isCompleted === false; +} class Checklist extends Base { /** @@ -23,8 +42,13 @@ class Checklist extends Base { ); } - /** List of tasks in the checklist */ - this.tasks = data.tasks.map((task) => new ChecklistTask(client, task)); + /** + * Collection of tasks in the checklist + * @type {import("@telegram.ts/collection").ReadonlyCollection} + */ + this.tasks = new Collection( + data.tasks.map((task, index) => [index, new ChecklistTask(client, task)]), + ); if ("others_can_add_tasks" in data) { /** True, if users other than the creator of the list can add tasks to the list */ @@ -39,18 +63,18 @@ class Checklist extends Base { /** * Get completed tasks - * @type {ChecklistTask[]} + * @type {import("@telegram.ts/collection").ReadonlyCollection} */ get completedTasks() { - return this.tasks.filter((task) => task.isCompleted); + return this.tasks.filter(isCompletedTask); } /** * Get pending tasks - * @type {ChecklistTask[]} + * @type {import("@telegram.ts/collection").ReadonlyCollection} */ get pendingTasks() { - return this.tasks.filter((task) => !task.isCompleted); + return this.tasks.filter(isPendingTask); } /** @@ -58,7 +82,7 @@ class Checklist extends Base { * @type {number} */ get totalTasks() { - return this.tasks.length; + return this.tasks.size; } /** @@ -66,7 +90,7 @@ class Checklist extends Base { * @type {number} */ get completedTasksCount() { - return this.completedTasks.length; + return this.completedTasks.size; } /** @@ -74,7 +98,7 @@ class Checklist extends Base { * @returns {IterableIterator} */ *[Symbol.iterator]() { - for (const task of this.tasks) { + for (const task of this.tasks.values()) { yield task; } } diff --git a/src/structures/invoice/TransactionPartner.js b/src/structures/invoice/TransactionPartner.js index 42e7a5e..546fca9 100644 --- a/src/structures/invoice/TransactionPartner.js +++ b/src/structures/invoice/TransactionPartner.js @@ -4,6 +4,7 @@ const { Gift } = require("../gift/Gift"); const { PaidMedia } = require("../media/paid/PaidMedia"); const { AffiliateInfo } = require("./AffiliateInfo"); const { RevenueWithdrawalState } = require("./RevenueWithdrawalState"); +const { Collection } = require("@telegram.ts/collection"); class TransactionPartner extends Base { /** @@ -48,10 +49,13 @@ class TransactionPartner extends Base { if ("paid_media" in data) { /** * Information about the paid media bought by the user. Can be available only for “invoice_payment” transactions. - * @type {PaidMedia[] | undefined} + * @type {import("@telegram.ts/collection").ReadonlyCollection | undefined} */ - this.paidMedia = data.paid_media.map( - (media) => new PaidMedia(this.client, media), + this.paidMedia = new Collection( + data.paid_media.map((media, index) => [ + index, + new PaidMedia(this.client, media), + ]), ); } @@ -136,14 +140,14 @@ class TransactionPartner extends Base { } /** - * @returns {this is this & { withdrawal?: undefined; user: import("../misc/User").User; paidMedia?: PaidMedia[]; paidMediaPayload?: string; gift?: Gift; subscriptionPeriod?: number; affiliate?: AffiliateInfo; sponsorUser?: undefined; commissionRate?: undefined; requestCount?: undefined; chat?: undefined; premiumSubscriptionDuration?: number; }} + * @returns {this is this & { withdrawal?: undefined; user: import("../misc/User").User; paidMedia?: import("@telegram.ts/collection").ReadonlyCollection; paidMediaPayload?: string; gift?: Gift; subscriptionPeriod?: number; affiliate?: AffiliateInfo; sponsorUser?: undefined; commissionRate?: undefined; requestCount?: undefined; chat?: undefined; premiumSubscriptionDuration?: number; }} */ isUser() { return Boolean("user" in this && this.user); } /** - * @returns {this is this & { withdrawal?: undefined; user?: undefined; paidMedia?: PaidMedia[]; paidMediaPayload?: string; gift?: Gift; subscriptionPeriod?: number; affiliate?: AffiliateInfo; sponsorUser?: undefined; commissionRate?: undefined; requestCount?: undefined; chat: import("../chat/Chat").Chat; premiumSubscriptionDuration?: undefined; }} + * @returns {this is this & { withdrawal?: undefined; user?: undefined; paidMedia?: undefined; paidMediaPayload?: string; gift?: Gift; subscriptionPeriod?: number; affiliate?: AffiliateInfo; sponsorUser?: undefined; commissionRate?: undefined; requestCount?: undefined; chat: import("../chat/Chat").Chat; premiumSubscriptionDuration?: undefined; }} */ isChat() { return Boolean("chat" in this && this.chat); diff --git a/src/structures/media/paid/PaidMediaInfo.js b/src/structures/media/paid/PaidMediaInfo.js index ec9d761..c57509c 100644 --- a/src/structures/media/paid/PaidMediaInfo.js +++ b/src/structures/media/paid/PaidMediaInfo.js @@ -1,5 +1,6 @@ // @ts-check const { PaidMedia } = require("./PaidMedia"); +const { Collection } = require("@telegram.ts/collection"); class PaidMediaInfo { /** @@ -10,8 +11,16 @@ class PaidMediaInfo { /** The number of Telegram Stars that must be paid to buy access to the media */ this.starCount = data.star_count; - /** Information about the paid media */ - this.media = data.paid_media.map((media) => new PaidMedia(client, media)); + /** + * Information about the paid media + * @type {import("@telegram.ts/collection").ReadonlyCollection} + */ + this.media = new Collection( + data.paid_media.map((media, index) => [ + index, + new PaidMedia(client, media), + ]), + ); } /** @@ -19,7 +28,7 @@ class PaidMediaInfo { * @returns {IterableIterator} */ *[Symbol.iterator]() { - for (const media of this.media) { + for (const media of this.media.values()) { yield media; } } diff --git a/src/structures/message/MessageEntities.js b/src/structures/message/MessageEntities.js index 3cada3f..c6e8910 100644 --- a/src/structures/message/MessageEntities.js +++ b/src/structures/message/MessageEntities.js @@ -1,6 +1,7 @@ // @ts-check const { Base } = require("../Base"); const { User } = require("../misc/User"); +const { Collection } = require("@telegram.ts/collection"); /** * Represents a search result for a specific message entity type. @@ -12,7 +13,7 @@ const { User } = require("../misc/User"); */ class MessageEntities extends Base { - /** @type {import("@telegram.ts/types").MessageEntity[]} */ + /** @type {Collection} */ #entities; /** @@ -29,13 +30,14 @@ class MessageEntities extends Base { */ this.searchText = searchText; - /** @type {import("@telegram.ts/types").MessageEntity[]} */ - this.#entities = entities; + this.#entities = new Collection( + entities.map((entity, index) => [index, entity]), + ); } /** * Retrieves all mention entities from the message. - * @returns {SearchResult[]} An array of objects representing mention entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of mention entities. */ get mention() { return this.searchEntity("mention"); @@ -43,7 +45,7 @@ class MessageEntities extends Base { /** * Retrieves all hashtag entities from the message. - * @returns {SearchResult[]} An array of objects representing hashtag entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of hashtag entities. */ get hashtag() { return this.searchEntity("hashtag"); @@ -51,7 +53,7 @@ class MessageEntities extends Base { /** * Retrieves all cashtag entities from the message. - * @returns {SearchResult[]} An array of objects representing cashtag entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of cashtag entities. */ get cashtag() { return this.searchEntity("cashtag"); @@ -59,7 +61,7 @@ class MessageEntities extends Base { /** * Retrieves all bot command entities from the message. - * @returns {SearchResult[]} An array of objects representing bot command entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of bot command entities. */ get botCommand() { return this.searchEntity("bot_command"); @@ -67,7 +69,7 @@ class MessageEntities extends Base { /** * Retrieves all URL entities from the message. - * @returns {SearchResult[]} An array of objects representing URL entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of URL entities. */ get url() { return this.searchEntity("url"); @@ -75,7 +77,7 @@ class MessageEntities extends Base { /** * Retrieves all email entities from the message. - * @returns {SearchResult[]} An array of objects representing email entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of email entities. */ get email() { return this.searchEntity("email"); @@ -83,7 +85,7 @@ class MessageEntities extends Base { /** * Retrieves all phone number entities from the message. - * @returns {SearchResult[]} An array of objects representing phone number entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of phone number entities. */ get phoneNumber() { return this.searchEntity("phone_number"); @@ -91,7 +93,7 @@ class MessageEntities extends Base { /** * Retrieves all bold entities from the message. - * @returns {SearchResult[]} An array of objects representing bold entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of bold entities. */ get bold() { return this.searchEntity("bold"); @@ -99,7 +101,7 @@ class MessageEntities extends Base { /** * Retrieves all italic entities from the message. - * @returns {SearchResult[]} An array of objects representing italic entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of italic entities. */ get italic() { return this.searchEntity("italic"); @@ -107,7 +109,7 @@ class MessageEntities extends Base { /** * Retrieves all underline entities from the message. - * @returns {SearchResult[]} An array of objects representing underline entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of underline entities. */ get underline() { return this.searchEntity("underline"); @@ -115,7 +117,7 @@ class MessageEntities extends Base { /** * Retrieves all strikethrough entities from the message. - * @returns {SearchResult[]} An array of objects representing strikethrough entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of strikethrough entities. */ get strikethrough() { return this.searchEntity("strikethrough"); @@ -123,7 +125,7 @@ class MessageEntities extends Base { /** * Retrieves all spoiler entities from the message. - * @returns {SearchResult[]} An array of objects representing spoiler entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of spoiler entities. */ get spoiler() { return this.searchEntity("spoiler"); @@ -131,7 +133,7 @@ class MessageEntities extends Base { /** * Retrieves all blockquote entities from the message. - * @returns {SearchResult[]} An array of objects representing blockquote entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of blockquote entities. */ get blockquote() { return this.searchEntity("blockquote"); @@ -139,7 +141,7 @@ class MessageEntities extends Base { /** * Retrieves all code entities from the message. - * @returns {SearchResult[]} An array of objects representing code entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of code entities. */ get code() { return this.searchEntity("code"); @@ -147,7 +149,7 @@ class MessageEntities extends Base { /** * Retrieves all pre entities from the message. - * @returns {(SearchResult & { language?: string })[]} An array of objects representing pre entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of pre entities. */ get pre() { return this.searchEntity("pre"); @@ -155,7 +157,7 @@ class MessageEntities extends Base { /** * Retrieves all text link entities from the message. - * @returns {(SearchResult & { url: string })[]} An array of objects representing text link entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of text link entities. */ get textLink() { return this.searchEntity("text_link").filter((entity) => "url" in entity); @@ -163,7 +165,7 @@ class MessageEntities extends Base { /** * Retrieves all text mention entities from the message. - * @returns {(SearchResult & { user: User })[]} An array of objects representing text mention entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of text mention entities. */ get textMention() { return this.searchEntity("text_mention").filter( @@ -173,7 +175,7 @@ class MessageEntities extends Base { /** * Retrieves all custom emoji entities from the message. - * @returns {(SearchResult & { customEmojiId: string })[]} An array of objects representing custom emoji entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of custom emoji entities. */ get customEmoji() { return this.searchEntity("custom_emoji").filter( @@ -184,16 +186,15 @@ class MessageEntities extends Base { /** * Searches for a specific type of entity in the message. * @param {"mention" | "hashtag" | "cashtag" | "bot_command" | "url" | "email" | "phone_number" | "bold" | "italic" | "underline" | "strikethrough" | "spoiler" | "blockquote" | "code" | "pre" | "text_link" | "text_mention" | "custom_emoji"} searchType - The type of entity to search for. - * @returns {(SearchResult & ({ language?: string } | { url: string } | { user: User } | { customEmojiId: string }))[]} An array of objects representing the found entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of found entities. */ searchEntity(searchType) { - /** @type {(SearchResult & ({ language?: string } | { url: string } | { user: User } | { customEmojiId: string }))[]} */ - const entities = []; + const results = new Collection(); this.#entities.forEach((entity, index) => { const { offset, length, type } = entity; if (type === searchType) { - entities.push({ + results.set(index, { index, offset, length, @@ -207,7 +208,8 @@ class MessageEntities extends Base { }); } }); - return entities; + + return results; } /** @@ -238,23 +240,20 @@ class MessageEntities extends Base { "customEmoji", ]; - /** @type {(SearchResult & ({ type: "mention" | "hashtag" | "cashtag" | "botCommand" | "url" | "email" | - "phoneNumber" | "bold" | "italic" | "underline" | "strikethrough" | "spoiler" | "blockquote" | "code" | { type: "pre", language?: string } | { type: "text_link", url: string } | { type: "text_mention", user: User } | { type: "customEmoji", customEmojiId: string }}))[]} */ - const sortedEntities = []; + const allEntities = new Collection(); for (const type of entityTypes) { - if (this[type] && Array.isArray(this[type])) { - const results = this[type].map((entity) => ({ - ...entity, - type, - })); - sortedEntities.push(...results); + const typeEntities = this[type]; + if (typeEntities instanceof Collection) { + typeEntities.forEach((entity, key) => { + allEntities.set(key, { ...entity, type }); + }); } } - sortedEntities.sort((a, b) => a.index - b.index); + const sorted = allEntities.sort((a, b) => a.index - b.index).values(); - for (const entity of sortedEntities) { + for (const entity of sorted) { yield entity; } } diff --git a/src/structures/passport/EncryptedPassportElement.js b/src/structures/passport/EncryptedPassportElement.js index 5976869..23d5e2a 100644 --- a/src/structures/passport/EncryptedPassportElement.js +++ b/src/structures/passport/EncryptedPassportElement.js @@ -2,6 +2,7 @@ const { Base } = require("../Base"); const { PassportFile } = require("./PassportFile"); const { InputFile } = require("../misc/InputFile"); +const { Collection } = require("@telegram.ts/collection"); class EncryptedPassportElement extends Base { /** @@ -50,11 +51,14 @@ class EncryptedPassportElement extends Base { if ("files" in data) { /** - * Array of encrypted files with documents provided by the user; This array is available only for types "utility_bill", "bank_statement", "rental_agreement", "passport_registration", and "temporary_registration". The files can be decrypted and verified using the accompanying EncryptedCredentials - * @type {InputFile[] | undefined} + * Collection of encrypted files with documents provided by the user; This array is available only for types "utility_bill", "bank_statement", "rental_agreement", "passport_registration", and "temporary_registration". The files can be decrypted and verified using the accompanying EncryptedCredentials + * @type {import("@telegram.ts/collection").ReadonlyCollection | undefined} */ - this.files = data.files.map( - (file) => new PassportFile(this.client, file), + this.files = new Collection( + data.files.map((file) => [ + file.file_id, + new PassportFile(this.client, file), + ]), ); } @@ -84,12 +88,15 @@ class EncryptedPassportElement extends Base { if ("translation" in data) { /** - * Array of encrypted files with translated versions of documents provided by the user; This array is available only for types "passport", "driver_license", "identity_card", "internal_passport", "utility_bill", "bank_statement", "rental_agreement", "passport_registration", and "temporary_registration". + * Collection of encrypted files with translated versions of documents provided by the user; This array is available only for types "passport", "driver_license", "identity_card", "internal_passport", "utility_bill", "bank_statement", "rental_agreement", "passport_registration", and "temporary_registration". * The files can be decrypted and verified using the accompanying EncryptedCredentials - * @type {PassportFile[] | undefined} + * @type {import("@telegram.ts/collection").ReadonlyCollection | undefined} */ - this.translation = data.translation.map( - (translated) => new PassportFile(this.client, translated), + this.translation = new Collection( + data.translation.map((translated) => [ + translated.file_id, + new PassportFile(this.client, translated), + ]), ); } diff --git a/src/structures/passport/PassportData.js b/src/structures/passport/PassportData.js index 35c0900..0660a62 100644 --- a/src/structures/passport/PassportData.js +++ b/src/structures/passport/PassportData.js @@ -1,6 +1,7 @@ // @ts-check const { Base } = require("../Base"); const { EncryptedPassportElement } = require("./EncryptedPassportElement"); +const { Collection } = require("@telegram.ts/collection"); class PassportData extends Base { /** @@ -10,9 +11,15 @@ class PassportData extends Base { constructor(client, data) { super(client); - /** Array containing information about documents and other Telegram Passport elements shared with the bot. */ - this.data = data.data.map( - (data) => new EncryptedPassportElement(client, data), + /** + * Collection containing information about documents and other Telegram Passport elements shared with the bot. + * @type {import("@telegram.ts/collection").ReadonlyCollection} + */ + this.data = new Collection( + data.data.map((data, index) => [ + index, + new EncryptedPassportElement(client, data), + ]), ); /** Encrypted credentials required to decrypt the data. */ diff --git a/typings/index.d.ts b/typings/index.d.ts index 009ebba..d7a9e9b 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1462,98 +1462,100 @@ export declare class MessageEntities extends Base { public readonly searchText: string; /** * Retrieves all mention entities from the message. - * @returns An array of objects representing mention entities. + * @returns A collection of mention entities. */ - get mention(): SearchResult[]; + get mention(): ReadonlyCollection; /** * Retrieves all hashtag entities from the message. - * @returns An array of objects representing hashtag entities. + * @returns A collection of hashtag entities. */ - get hashtag(): SearchResult[]; + get hashtag(): ReadonlyCollection; /** * Retrieves all cashtag entities from the message. - * @returns An array of objects representing cashtag entities. + * @returns A collection of cashtag entities. */ - get cashtag(): SearchResult[]; + get cashtag(): ReadonlyCollection; /** * Retrieves all bot command entities from the message. - * @returns An array of objects representing bot command entities. + * @returns A collection of bot command entities. */ - get botCommand(): SearchResult[]; + get botCommand(): ReadonlyCollection; /** * Retrieves all URL entities from the message. - * @returns An array of objects representing URL entities. + * @returns A collection of url entities. */ - get url(): SearchResult[]; + get url(): ReadonlyCollection; /** * Retrieves all email entities from the message. - * @returns An array of objects representing email entities. + * @returns A collection of email entities. */ - get email(): SearchResult[]; + get email(): ReadonlyCollection; /** * Retrieves all phone number entities from the message. - * @returns An array of objects representing phone number entities. + * @returns A collection of phone number entities. */ - get phoneNumber(): SearchResult[]; + get phoneNumber(): ReadonlyCollection; /** * Retrieves all bold entities from the message. - * @returns An array of objects representing bold entities. + * @returns A collection of bold entities. */ - get bold(): SearchResult[]; + get bold(): ReadonlyCollection; /** * Retrieves all italic entities from the message. - * @returns An array of objects representing italic entities. + * @returns A collection of italic entities. */ - get italic(): SearchResult[]; + get italic(): ReadonlyCollection; /** * Retrieves all underline entities from the message. - * @returns An array of objects representing underline entities. + * @returns A collection of underline entities. */ - get underline(): SearchResult[]; + get underline(): ReadonlyCollection; /** * Retrieves all strikethrough entities from the message. - * @returns An array of objects representing strikethrough entities. + * @returns A collection of strikethrough entities. */ - get strikethrough(): SearchResult[]; + get strikethrough(): ReadonlyCollection; /** * Retrieves all spoiler entities from the message. - * @returns An array of objects representing spoiler entities. + * @returns A collection of spoiler entities. */ - get spoiler(): SearchResult[]; + get spoiler(): ReadonlyCollection; /** * Retrieves all blockquote entities from the message. * @returns An array of objects representing blockquote entities. */ - get blockquote(): SearchResult[]; + get blockquote(): ReadonlyCollection; /** * Retrieves all code entities from the message. - * @returns An array of objects representing code entities. + * @returns A collection of code entities. */ - get code(): SearchResult[]; + get code(): ReadonlyCollection; /** * Retrieves all pre entities from the message. - * @returns An array of objects representing pre entities. + * @returns A collection of pre entities. */ - get pre(): (SearchResult & { language?: string })[]; + get pre(): ReadonlyCollection; /** * Retrieves all text link entities from the message. - * @returns An array of objects representing text link entities. + * @returns A collection of text link entities. */ - get textLink(): (SearchResult & { url: string })[]; + get textLink(): ReadonlyCollection; /** * Retrieves all text mention entities from the message. - * @returns An array of objects representing text mention entities. + * @returns A collection of text mention entities. */ - get textMention(): (SearchResult & { user: User })[]; + get textMention(): ReadonlyCollection; /** * Retrieves all custom emoji entities from the message. - * @returns An array of objects representing custom emoji entities. + * @returns A collection of custom emoji entities. */ - get customEmoji(): (SearchResult & { customEmojiId: string })[]; - /** + get customEmoji(): ReadonlyCollection< + number, + SearchResult & { customEmojiId: string } + >; /** * Searches for a specific type of entity in the message. * @param searchType - The type of entity to search for. - * @returns An array of objects representing the found entities. + * @returns A collection of found entities. */ searchEntity( searchType: @@ -1575,13 +1577,16 @@ export declare class MessageEntities extends Base { | "text_link" | "text_mention" | "custom_emoji", - ): (SearchResult & - ( - | { language?: string } - | { url: string } - | { user: User } - | { customEmojiId: string } - ))[]; + ): ReadonlyCollection< + number, + SearchResult & + ( + | { language?: string } + | { url: string } + | { user: User } + | { customEmojiId: string } + ) + >; /** * Enables iteration over the message entities. * @returns An iterator over the message entities. @@ -3886,7 +3891,7 @@ export declare class PaidMediaInfo { /** The number of Telegram Stars that must be paid to buy access to the media */ starCount: number; /** Information about the paid media */ - media: PaidMedia[]; + media: ReadonlyCollection; /** Makes the class iterable, returning each `PaidMedia` object. */ [Symbol.iterator](): IterableIterator; } @@ -5840,9 +5845,9 @@ export declare class EncryptedPassportElement extends Base { */ email?: string; /** - * Array of encrypted files with documents provided by the user; This array is available only for types "utility_bill", "bank_statement", "rental_agreement", "passport_registration", and "temporary_registration". The files can be decrypted and verified using the accompanying EncryptedCredentials + * Collection of encrypted files with documents provided by the user; This array is available only for types "utility_bill", "bank_statement", "rental_agreement", "passport_registration", and "temporary_registration". The files can be decrypted and verified using the accompanying EncryptedCredentials */ - files?: InputFile[]; + files?: ReadonlyCollection; /** * Encrypted file with the front side of the document, provided by the user; This file is available only for types "passport", "driver_license", "identity_card", and "internal_passport". It can be decrypted and verified using the accompanying EncryptedCredentials */ @@ -5856,13 +5861,13 @@ export declare class EncryptedPassportElement extends Base { */ selfie?: PassportFile; /** - * Array of encrypted files with translated versions of documents provided by the user; This array is available only for types "passport", "driver_license", "identity_card", "internal_passport", "utility_bill", "bank_statement", "rental_agreement", "passport_registration", and "temporary_registration". + * Collection of encrypted files with translated versions of documents provided by the user; This array is available only for types "passport", "driver_license", "identity_card", "internal_passport", "utility_bill", "bank_statement", "rental_agreement", "passport_registration", and "temporary_registration". * The files can be decrypted and verified using the accompanying EncryptedCredentials */ - translation?: PassportFile[]; + translation?: ReadonlyCollection; } -export declare class PassportData extends Base { +export class PassportData extends Base { /** * @param client - The client that instantiated this * @param data - Data about the describes the user's Telegram Passport data shared with the bot @@ -5871,8 +5876,8 @@ export declare class PassportData extends Base { client: TelegramClient | BaseClient, data: import("@telegram.ts/types").PassportData, ); - /** Array containing information about documents and other Telegram Passport elements shared with the bot. */ - data: EncryptedPassportElement[]; + /** Collection containing information about documents and other Telegram Passport elements shared with the bot. */ + data: ReadonlyCollection; /** Encrypted credentials required to decrypt the data. */ credentials: { data: string; @@ -6078,8 +6083,8 @@ export class Checklist extends Base { title: string; /** Special entities that appear in the checklist title */ entities?: MessageEntities; - /** List of tasks in the checklist */ - tasks: ChecklistTask[]; + /** Collection of tasks in the checklist */ + tasks: ReadonlyCollection; /** True, if users other than the creator of the list can add tasks to the list */ othersCanAddTasks?: true; /** True, if users other than the creator of the list can mark tasks as done or not done */ @@ -6087,11 +6092,27 @@ export class Checklist extends Base { /** * Get completed tasks */ - get completedTasks(): ChecklistTask[]; + get completedTasks(): ReadonlyCollection< + number, + ChecklistTask & { + completionUnixTime: number; + completionTimestamp: number; + isCompleted: true; + completedByUser: User; + } + >; /** * Get pending tasks */ - get pendingTasks(): ChecklistTask[]; + get pendingTasks(): ReadonlyCollection< + number, + ChecklistTask & { + completionUnixTime: undefined; + completionTimestamp: undefined; + isCompleted: false; + completedByUser: undefined; + } + >; /** * Get total number of tasks */ @@ -11756,7 +11777,7 @@ export declare class TransactionPartner extends Base { /** * Information about the paid media bought by the user. Can be available only for “invoice_payment” transactions. */ - paidMedia?: PaidMedia[]; + paidMedia?: ReadonlyCollection; /** * Bot-specified paid media payload. Can be available only for “invoice_payment” transactions. */ @@ -11799,7 +11820,7 @@ export declare class TransactionPartner extends Base { isUser(): this is this & { withdrawal?: undefined; user: User; - paidMedia?: PaidMedia[]; + paidMedia?: ReadonlyCollection; paidMediaPayload?: string; gift?: Gift; subscriptionPeriod?: number; @@ -13216,4 +13237,4 @@ export declare class StarTransactions { export declare const version: "4.11.0"; -export * from "./telegram/index"; \ No newline at end of file +export * from "./telegram/index"; From 457959c6ce531ca4318fb4cf0213897e8bcf2e61 Mon Sep 17 00:00:00 2001 From: Sempai-07 Date: Sun, 28 Dec 2025 20:26:49 +0200 Subject: [PATCH 04/10] Refactor(MessageEntities): strongly type languageCode --- src/structures/message/MessageEntities.js | 6 +++--- typings/index.d.ts | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/structures/message/MessageEntities.js b/src/structures/message/MessageEntities.js index c6e8910..520fe9d 100644 --- a/src/structures/message/MessageEntities.js +++ b/src/structures/message/MessageEntities.js @@ -149,7 +149,7 @@ class MessageEntities extends Base { /** * Retrieves all pre entities from the message. - * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of pre entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of pre entities. */ get pre() { return this.searchEntity("pre"); @@ -186,7 +186,7 @@ class MessageEntities extends Base { /** * Searches for a specific type of entity in the message. * @param {"mention" | "hashtag" | "cashtag" | "bot_command" | "url" | "email" | "phone_number" | "bold" | "italic" | "underline" | "strikethrough" | "spoiler" | "blockquote" | "code" | "pre" | "text_link" | "text_mention" | "custom_emoji"} searchType - The type of entity to search for. - * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of found entities. + * @returns {import("@telegram.ts/collection").ReadonlyCollection} A collection of found entities. */ searchEntity(searchType) { const results = new Collection(); @@ -215,7 +215,7 @@ class MessageEntities extends Base { /** * Enables iteration over the message entities. * @returns {Generator<(SearchResult & ({ type: "mention" | "hashtag" | "cashtag" | "botCommand" | "url" | "email" | - "phoneNumber" | "bold" | "italic" | "underline" | "strikethrough" | "spoiler" | "blockquote" | "code" | { type: "pre", language?: string } | { type: "text_link", url: string } | { type: "text_mention", user: User } | { type: "customEmoji", customEmojiId: string }}))>} An iterator over the message entities. + "phoneNumber" | "bold" | "italic" | "underline" | "strikethrough" | "spoiler" | "blockquote" | "code" | { type: "pre", language?: import("../../client/interfaces/Language").LanguageCode } | { type: "text_link", url: string } | { type: "text_mention", user: User } | { type: "customEmoji", customEmojiId: string }}))>} An iterator over the message entities. */ *[Symbol.iterator]() { /** @type {(keyof MessageEntities)[]} */ diff --git a/typings/index.d.ts b/typings/index.d.ts index d7a9e9b..66eb2f1 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1534,7 +1534,10 @@ export declare class MessageEntities extends Base { * Retrieves all pre entities from the message. * @returns A collection of pre entities. */ - get pre(): ReadonlyCollection; + get pre(): ReadonlyCollection< + number, + SearchResult & { language?: LanguageCode } + >; /** * Retrieves all text link entities from the message. * @returns A collection of text link entities. @@ -1581,7 +1584,7 @@ export declare class MessageEntities extends Base { number, SearchResult & ( - | { language?: string } + | { language?: LanguageCode } | { url: string } | { user: User } | { customEmojiId: string } @@ -1609,7 +1612,7 @@ export declare class MessageEntities extends Base { | "blockquote" | "code"; } & ( - | { type: "pre"; language?: string } + | { type: "pre"; language?: LanguageCode } | { type: "textLink"; url: string } | { type: "textMention"; user: User } | { type: "customEmoji"; customEmojiId: string } From 2905ef446d223f1ddd4c5039c9dc488a35333065 Mon Sep 17 00:00:00 2001 From: Sempai-07 Date: Sun, 28 Dec 2025 21:03:18 +0200 Subject: [PATCH 05/10] Fix(typings): fix unused @param warnings in signatures --- src/util/inline/InputMessageContentBuilder.ts | 2 -- src/util/markup/KeyboardBuilder.ts | 2 +- typings/index.d.ts | 8 +++----- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/util/inline/InputMessageContentBuilder.ts b/src/util/inline/InputMessageContentBuilder.ts index 6a213d6..2c57932 100644 --- a/src/util/inline/InputMessageContentBuilder.ts +++ b/src/util/inline/InputMessageContentBuilder.ts @@ -37,8 +37,6 @@ class InputMessageContentBuilder { * Represents the [content](https://core.telegram.org/bots/api/#inputmessagecontent) of a venue message to be sent as the result of an inline query. * @param latitude - Latitude of the venue in degrees. * @param longitude - Longitude of the venue in degrees. - * @param title - Name of the venue. - * @param address - Address of the venue. * @param options - out parameters. */ static venue( diff --git a/src/util/markup/KeyboardBuilder.ts b/src/util/markup/KeyboardBuilder.ts index 3bc13f3..bea4885 100644 --- a/src/util/markup/KeyboardBuilder.ts +++ b/src/util/markup/KeyboardBuilder.ts @@ -306,7 +306,7 @@ class KeyboardBuilder { /** * Combines the current keyboard with another one. - * @param other - The other Keyboard instance to combine with. + * @param keyboard - The other Keyboard instance to combine with. * @returns The current instance for chaining. */ combine( diff --git a/typings/index.d.ts b/typings/index.d.ts index 66eb2f1..3e0cda9 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -8924,7 +8924,7 @@ export declare class UserManager extends BaseManager { /** * @param client - The client instance. * @param iterable - Data iterable. - * @param cacheSize - The maximum size of the cache. Default is unlimited. + * @param options - Options for save cached. */ constructor( client: TelegramClient | BaseClient, @@ -12153,7 +12153,7 @@ export declare class InlineKeyboardBuilder { readonly inline_keyboard: InlineKeyboardButton[][]; /** * Creates an instance of InlineKeyboard. - * @param inlineKeyboard - A 2D array of inline keyboard buttons. + * @param inline_keyboard - A 2D array of inline keyboard buttons. */ constructor(inline_keyboard?: InlineKeyboardButton[][]); /** @@ -12560,7 +12560,7 @@ export declare class KeyboardBuilder { build(): KeyboardButton[][]; /** * Combines the current keyboard with another one. - * @param other - The other Keyboard instance to combine with. + * @param keyboard - The other Keyboard instance to combine with. * @returns The current instance for chaining. */ combine( @@ -12964,8 +12964,6 @@ export declare class InputMessageContentBuilder { * Represents the [content](https://core.telegram.org/bots/api/#inputmessagecontent) of a venue message to be sent as the result of an inline query. * @param latitude - Latitude of the venue in degrees. * @param longitude - Longitude of the venue in degrees. - * @param title - Name of the venue. - * @param address - Address of the venue. * @param options - out parameters. */ static venue( From 3a3bb6ab470191f5afbde0c0d3212de896fec3c2 Mon Sep 17 00:00:00 2001 From: Sempai-07 Date: Mon, 29 Dec 2025 13:13:11 +0200 Subject: [PATCH 06/10] Fix(MediaData): parsing inside array fields cover and thumbnail --- src/rest/MediaData.ts | 69 +++++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 19 deletions(-) diff --git a/src/rest/MediaData.ts b/src/rest/MediaData.ts index e9415d1..d18e118 100644 --- a/src/rest/MediaData.ts +++ b/src/rest/MediaData.ts @@ -216,24 +216,25 @@ class MediaData { if (await fileExists(value)) { await this.attachFormMedia(form, value, { id }); return; - } else if (id === "thumbnail" && value.startsWith("http")) { + } + + if (id === "thumbnail" && value.startsWith("http")) { const attachmentId = randomBytes(16).toString("hex"); const response = await fetch(value, { agent }); - value = Buffer.from(await response.arrayBuffer()); - - await this.attachFormMedia(form, value, { id: attachmentId }); + const buffer = Buffer.from(await response.arrayBuffer()); + await this.attachFormMedia(form, buffer, { id: attachmentId }); form.addPart({ headers: { "content-disposition": `form-data; name="${id}"` }, body: `attach://${attachmentId}`, }); return; - } else { - form.addPart({ - headers: { "content-disposition": `form-data; name="${id}"` }, - body: String(value), - }); - return; } + + form.addPart({ + headers: { "content-disposition": `form-data; name="${id}"` }, + body: String(value), + }); + return; } if (typeof value === "object" && value !== null && "source" in value) { @@ -279,27 +280,57 @@ class MediaData { if (Array.isArray(value)) { const attachments = await Promise.all( value.map(async (item) => { - const media = item.media?.source ? item.media.source : item; - if (!this.isMediaType(media.media)) { - if (!(await fileExists(media.media))) { - return media; - } + const media = item.media?.source ?? item; + + if ( + !this.isMediaType(media.media) && + !(await fileExists(media.media)) + ) { + return media; } - const attachmentId = randomBytes(16).toString("hex"); + const attachmentId = randomBytes(16).toString("hex"); await this.attachFormMedia(form, media.media, { id: attachmentId, ...(typeof media.media === "object" && - "filename" in (media.media || {}) && { + "filename" in media.media && { filename: media.media.filename, }), }); + let coverId = null; + if ("cover" in item && !item.cover?.startsWith?.("http")) { + coverId = randomBytes(16).toString("hex"); + await this.attachFormMedia(form, item.cover, { id: coverId }); + } + + let thumbnailId = null; + if ("thumbnail" in item) { + thumbnailId = randomBytes(16).toString("hex"); + + if (item.thumbnail?.startsWith?.("http")) { + const response = await fetch(item.thumbnail, { agent }); + const buffer = Buffer.from(await response.arrayBuffer()); + await this.attachFormMedia(form, buffer, { id: thumbnailId }); + } else { + await this.attachFormMedia(form, item.thumbnail, { + id: thumbnailId, + }); + } + } + + const result = { + ...(item.media.source ? item : media), + media: `attach://${attachmentId}`, + ...(coverId && { cover: `attach://${coverId}` }), + ...(thumbnailId && { thumbnail: `attach://${thumbnailId}` }), + }; + if (item.media.source) { - return { type: item.type, media: `attach://${attachmentId}` }; + result.type = item.type; } - return { ...media, media: `attach://${attachmentId}` }; + return result; }), ); From 846b90df8de01bbc2ad4b1ac2c4bc3b6f8d1f459 Mon Sep 17 00:00:00 2001 From: Sempai-07 Date: Mon, 29 Dec 2025 13:38:38 +0200 Subject: [PATCH 07/10] Refactor(Symbol.iterator): refactored to a unified style --- src/managers/BaseManager.ts | 4 +--- src/structures/boost/UserChatBoosts.js | 4 +--- src/structures/business/BusinessMessagesDeleted.js | 4 +--- src/structures/chat/VideoChatParticipantsInvited.js | 4 +--- src/structures/checklist/Checklist.js | 4 +--- src/structures/checklist/ChecklistTasksAdded.js | 4 +--- src/structures/gift/Gifts.js | 4 +--- src/structures/giveaway/GiveawayWinners.js | 4 +--- src/structures/media/paid/PaidMediaInfo.js | 4 +--- src/structures/message/MessageEntities.js | 6 +----- src/structures/misc/UsersShared.js | 4 +--- 11 files changed, 11 insertions(+), 35 deletions(-) diff --git a/src/managers/BaseManager.ts b/src/managers/BaseManager.ts index afc438a..cee14da 100644 --- a/src/managers/BaseManager.ts +++ b/src/managers/BaseManager.ts @@ -166,9 +166,7 @@ class BaseManager { * @returns An iterator object that can be used to iterate over the key-value pairs of the Collection. */ *[Symbol.iterator](): IterableIterator<[string, T]> { - for (const item of this.cache) { - yield item; - } + yield* this.cache; } } diff --git a/src/structures/boost/UserChatBoosts.js b/src/structures/boost/UserChatBoosts.js index 347110a..e64fcdd 100644 --- a/src/structures/boost/UserChatBoosts.js +++ b/src/structures/boost/UserChatBoosts.js @@ -31,9 +31,7 @@ class UserChatBoosts { * @returns {IterableIterator} */ *[Symbol.iterator]() { - for (const [_, boost] of this.boosts) { - yield boost; - } + yield* this.boosts.values(); } } diff --git a/src/structures/business/BusinessMessagesDeleted.js b/src/structures/business/BusinessMessagesDeleted.js index 8bb66c8..d582909 100644 --- a/src/structures/business/BusinessMessagesDeleted.js +++ b/src/structures/business/BusinessMessagesDeleted.js @@ -33,9 +33,7 @@ class BusinessMessagesDeleted extends Base { * @returns {IterableIterator} */ *[Symbol.iterator]() { - for (const id of this.ids) { - yield id; - } + yield* this.ids; } } diff --git a/src/structures/chat/VideoChatParticipantsInvited.js b/src/structures/chat/VideoChatParticipantsInvited.js index 64e07d3..a055086 100644 --- a/src/structures/chat/VideoChatParticipantsInvited.js +++ b/src/structures/chat/VideoChatParticipantsInvited.js @@ -24,9 +24,7 @@ class VideoChatParticipantsInvited extends Base { * @returns {IterableIterator} */ *[Symbol.iterator]() { - for (const [_, user] of this.users) { - yield user; - } + yield* this.users.values(); } } diff --git a/src/structures/checklist/Checklist.js b/src/structures/checklist/Checklist.js index 2b5ab98..52fc388 100644 --- a/src/structures/checklist/Checklist.js +++ b/src/structures/checklist/Checklist.js @@ -98,9 +98,7 @@ class Checklist extends Base { * @returns {IterableIterator} */ *[Symbol.iterator]() { - for (const task of this.tasks.values()) { - yield task; - } + yield* this.tasks.values(); } } diff --git a/src/structures/checklist/ChecklistTasksAdded.js b/src/structures/checklist/ChecklistTasksAdded.js index 897f7de..795e403 100644 --- a/src/structures/checklist/ChecklistTasksAdded.js +++ b/src/structures/checklist/ChecklistTasksAdded.js @@ -78,9 +78,7 @@ class ChecklistTasksAdded extends Base { * @returns {IterableIterator} */ *[Symbol.iterator]() { - for (const task of this.tasks) { - yield task; - } + yield* this.tasks; } } diff --git a/src/structures/gift/Gifts.js b/src/structures/gift/Gifts.js index 2c5ba16..cc4ba8a 100644 --- a/src/structures/gift/Gifts.js +++ b/src/structures/gift/Gifts.js @@ -43,9 +43,7 @@ class Gifts { * @returns {IterableIterator} */ *[Symbol.iterator]() { - for (const [_, gift] of this.gifts) { - yield gift; - } + yield* this.gifts.values(); } } diff --git a/src/structures/giveaway/GiveawayWinners.js b/src/structures/giveaway/GiveawayWinners.js index c2198ce..a290db5 100644 --- a/src/structures/giveaway/GiveawayWinners.js +++ b/src/structures/giveaway/GiveawayWinners.js @@ -154,9 +154,7 @@ class GiveawayWinners extends Base { * @returns {IterableIterator} */ *[Symbol.iterator]() { - for (const [_, winner] of this.winners) { - yield winner; - } + yield* this.winners.values(); } } diff --git a/src/structures/media/paid/PaidMediaInfo.js b/src/structures/media/paid/PaidMediaInfo.js index c57509c..c4ba87c 100644 --- a/src/structures/media/paid/PaidMediaInfo.js +++ b/src/structures/media/paid/PaidMediaInfo.js @@ -28,9 +28,7 @@ class PaidMediaInfo { * @returns {IterableIterator} */ *[Symbol.iterator]() { - for (const media of this.media.values()) { - yield media; - } + yield* this.media.values(); } } diff --git a/src/structures/message/MessageEntities.js b/src/structures/message/MessageEntities.js index 520fe9d..7b36ea2 100644 --- a/src/structures/message/MessageEntities.js +++ b/src/structures/message/MessageEntities.js @@ -251,11 +251,7 @@ class MessageEntities extends Base { } } - const sorted = allEntities.sort((a, b) => a.index - b.index).values(); - - for (const entity of sorted) { - yield entity; - } + yield* allEntities.sort((a, b) => a.index - b.index).values(); } } diff --git a/src/structures/misc/UsersShared.js b/src/structures/misc/UsersShared.js index dabe34c..f05e139 100644 --- a/src/structures/misc/UsersShared.js +++ b/src/structures/misc/UsersShared.js @@ -28,9 +28,7 @@ class UsersShared { * @returns {IterableIterator} */ *[Symbol.iterator]() { - for (const [_, user] of this.users) { - yield user; - } + yield* this.users.values(); } } From 431ea7b82993b02fc5327f2c8673064eed6feba9 Mon Sep 17 00:00:00 2001 From: Sempai-07 Date: Mon, 29 Dec 2025 18:46:48 +0200 Subject: [PATCH 08/10] Update CHANGELOG.md --- CHANGELOG.md | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 092640e..b480029 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,31 @@ # Changelog +# **4.12.0 - (2025-12-29)** + +## **Updates** + +- Bump version `@telegram.ts/formatters@2.1.0` ([v2.1.0](https://github.com/telegramsjs/formatters)) + - Major release + - Bump version `typescript@5.9.3` + - Bump version `@telegram.ts/types@1.24.0` (`MessageEntity` add `languageCode` union type) + +## **Bug Fixes** + +- **MediaData:** parsing inside array fields cover and thumbnail ([3a3bb6a](https://github.com/telegramsjs/Telegramsjs/commit/3a3bb6ab470191f5afbde0c0d3212de896fec3c2)) + +## **Refactor** + +- **Array:** use Collection instead of Array ([8c36298](https://github.com/telegramsjs/Telegramsjs/commit/8c36298080442b93cd89941a0e591f2d377f601f)) +- **MessageEntities:** add `languageCode` union type ((457959c)[https://github.com/telegramsjs/Telegramsjs/commit/457959c6ce531ca4318fb4cf0213897e8bcf2e61]) +- **Symbol.iterator:** refactored to a unified style ([846b90d](https://github.com/telegramsjs/Telegramsjs/commit/846b90df8de01bbc2ad4b1ac2c4bc3b6f8d1f459)) + +## **Typings** + +- **TransactionPartner:** fix find module `Chat` ([db7d3af](https://github.com/telegramsjs/Telegramsjs/commit/db7d3af6e01d9cc0857cc699b40b697a8a9d7ed7)) +- **Markup:** fix unused `@param` warnings in signatures ((2905ef4)[https://github.com/telegramsjs/Telegramsjs/commit/2905ef446d223f1ddd4c5039c9dc488a35333065]) + +--- + # **4.11.0 - (2025-12-15)** ## **Updates** @@ -9,13 +35,13 @@ - Bump version `typescript@5.9.3` - Major release (feature parity with [`@discordjs/collection`](https://github.com/discordjs/discord.js/tree/main/packages/collection)) -## Features +## **Features** - **TelegramClient:** resolve login timing issue with async ready handling ([39726ee](https://github.com/telegramsjs/Telegramsjs/commit/39726ee189b1575e0200763c0245179dd3ec5d62)) - **BaseManager:** allow fetch via resolved chat object ([fe95849](https://github.com/telegramsjs/Telegramsjs/commit/fe95849120b89c39d37050c1db4e747552a5bbb4)) - **BaseManager:** fetches multiple users or chats at once ([19180de](https://github.com/telegramsjs/Telegramsjs/commit/19180de54a9564417f9be5448b819bdcd69f5ce9)) -## Typings +## **Typings** - **ChatManager:** correct name parameters ([a874d79](https://github.com/telegramsjs/Telegramsjs/commit/a874d7942194c44229856a8fc4111245f0113c93)) - **BaseManager:** add UserResolvable and ChatResolvable typings ([49a57ad](https://github.com/telegramsjs/Telegramsjs/commit/49a57ad6cdb550616ef60de39e49b03b5008c69b)) From 8d6a4031b1739344e7ff4beab2050b36208c4406 Mon Sep 17 00:00:00 2001 From: Sempai-07 Date: Mon, 29 Dec 2025 18:47:18 +0200 Subject: [PATCH 09/10] Release 4.12.0 --- package.json | 4 ++-- src/client/interfaces/Message.ts | 2 +- src/structures/ChatJoinRequest.js | 2 +- typings/index.d.ts | 2 +- typings/telegram/Message.d.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 0ce754f..f2d14d9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "telegramsjs", "description": "A powerful library for interacting with the Telegram Bot API", - "version": "4.11.0", + "version": "4.12.0", "main": "./dist/src/index.js", "types": "./typings/index.d.ts", "scripts": { @@ -53,7 +53,7 @@ }, "homepage": "https://docs-telegramsjs.vercel.app/", "devDependencies": { - "@telegram.ts/types": "^1.23.5", + "@telegram.ts/types": "^1.24.0", "@types/node": "^18.19.61", "@types/node-fetch": "^2.6.11", "@types/safe-compare": "^1.1.2", diff --git a/src/client/interfaces/Message.ts b/src/client/interfaces/Message.ts index 408f2b0..e3ee25c 100644 --- a/src/client/interfaces/Message.ts +++ b/src/client/interfaces/Message.ts @@ -64,7 +64,7 @@ export declare namespace MessageEntity { export interface PreMessageEntity extends AbstractMessageEntity { type: "pre"; /** For “pre” only, the programming language of the entity text */ - language?: string; + language?: LanguageCode; } export interface TextLinkMessageEntity extends AbstractMessageEntity { type: "text_link"; diff --git a/src/structures/ChatJoinRequest.js b/src/structures/ChatJoinRequest.js index 1f2764b..6eb1b09 100644 --- a/src/structures/ChatJoinRequest.js +++ b/src/structures/ChatJoinRequest.js @@ -10,7 +10,7 @@ class ChatJoinRequest extends Base { constructor(client, data) { super(client); - /** Identifier of a private chat with the user who sent the join request. The bot can use this identifier for 5 minutes to send messages until the join request is processed, assuming no other administrator contacted the user. */ + /** Identifier of a private chat with the user who sent the join request. The bot can use this identifier for 5 minutes to send messages until the join request is processed, assuming no other administrato */ this.userChatId = String(data.user_chat_id); /** diff --git a/typings/index.d.ts b/typings/index.d.ts index 3e0cda9..3631cd8 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -13236,6 +13236,6 @@ export declare class StarTransactions { [Symbol.iterator](): IterableIterator; } -export declare const version: "4.11.0"; +export declare const version: "4.12.0"; export * from "./telegram/index"; diff --git a/typings/telegram/Message.d.ts b/typings/telegram/Message.d.ts index 408f2b0..e3ee25c 100644 --- a/typings/telegram/Message.d.ts +++ b/typings/telegram/Message.d.ts @@ -64,7 +64,7 @@ export declare namespace MessageEntity { export interface PreMessageEntity extends AbstractMessageEntity { type: "pre"; /** For “pre” only, the programming language of the entity text */ - language?: string; + language?: LanguageCode; } export interface TextLinkMessageEntity extends AbstractMessageEntity { type: "text_link"; From 68300dd034d7dfe87f8eae55184eb307e673fa86 Mon Sep 17 00:00:00 2001 From: Sempai-07 Date: Mon, 29 Dec 2025 18:50:13 +0200 Subject: [PATCH 10/10] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b480029..eee92fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ ## **Typings** - **TransactionPartner:** fix find module `Chat` ([db7d3af](https://github.com/telegramsjs/Telegramsjs/commit/db7d3af6e01d9cc0857cc699b40b697a8a9d7ed7)) -- **Markup:** fix unused `@param` warnings in signatures ((2905ef4)[https://github.com/telegramsjs/Telegramsjs/commit/2905ef446d223f1ddd4c5039c9dc488a35333065]) +- **Markup:** fix unused `@param` warnings in signatures ([2905ef4](https://github.com/telegramsjs/Telegramsjs/commit/2905ef446d223f1ddd4c5039c9dc488a35333065)) ---