diff --git a/packages/client/src/methods/auth/accept-tos.ts b/packages/client/src/methods/auth/accept-tos.ts index 5426f4b1..8c32e1b4 100644 --- a/packages/client/src/methods/auth/accept-tos.ts +++ b/packages/client/src/methods/auth/accept-tos.ts @@ -21,7 +21,7 @@ export async function acceptTos( if (!res) throw new MtCuteTypeAssertionError( - 'acceptTos (@ help.acceptTermsOfService)', + 'help.acceptTermsOfService', 'true', 'false' ) diff --git a/packages/client/src/methods/chats/create-channel.ts b/packages/client/src/methods/chats/create-channel.ts index ce96a303..9b75c1b1 100644 --- a/packages/client/src/methods/chats/create-channel.ts +++ b/packages/client/src/methods/chats/create-channel.ts @@ -23,7 +23,7 @@ export async function createChannel( if (!(res._ === 'updates' || res._ === 'updatesCombined')) { throw new MtCuteTypeAssertionError( - 'createChannel (@ channels.createChannel)', + 'channels.createChannel', 'updates | updatesCombined', res._ ) diff --git a/packages/client/src/methods/chats/create-group.ts b/packages/client/src/methods/chats/create-group.ts index 2bafc532..3e69423c 100644 --- a/packages/client/src/methods/chats/create-group.ts +++ b/packages/client/src/methods/chats/create-group.ts @@ -36,7 +36,7 @@ export async function createGroup( if (!(res._ === 'updates' || res._ === 'updatesCombined')) { throw new MtCuteTypeAssertionError( - 'createChannel (@ channels.createChannel)', + 'messages.createChat', 'updates | updatesCombined', res._ ) diff --git a/packages/client/src/methods/chats/create-supergroup.ts b/packages/client/src/methods/chats/create-supergroup.ts index dbcc1b3a..f166eab6 100644 --- a/packages/client/src/methods/chats/create-supergroup.ts +++ b/packages/client/src/methods/chats/create-supergroup.ts @@ -22,7 +22,7 @@ export async function createSupergroup( if (!(res._ === 'updates' || res._ === 'updatesCombined')) { throw new MtCuteTypeAssertionError( - 'createChannel (@ channels.createChannel)', + 'channels.createChannel', 'updates | updatesCombined', res._ ) diff --git a/packages/client/src/methods/chats/join-chat.ts b/packages/client/src/methods/chats/join-chat.ts index 20b36667..20332edc 100644 --- a/packages/client/src/methods/chats/join-chat.ts +++ b/packages/client/src/methods/chats/join-chat.ts @@ -31,7 +31,7 @@ export async function joinChat( }) if (!(res._ === 'updates' || res._ === 'updatesCombined')) { throw new MtCuteTypeAssertionError( - 'joinChat, (@ messages.importChatInvite)', + 'messages.importChatInvite', 'updates | updatesCombined', res._ ) @@ -52,7 +52,7 @@ export async function joinChat( }) if (!(res._ === 'updates' || res._ === 'updatesCombined')) { throw new MtCuteTypeAssertionError( - 'joinChat, (@ channels.joinChannel)', + 'channels.joinChannel', 'updates | updatesCombined', res._ ) diff --git a/packages/client/src/methods/chats/set-chat-default-permissions.ts b/packages/client/src/methods/chats/set-chat-default-permissions.ts index e1db115e..842e2a82 100644 --- a/packages/client/src/methods/chats/set-chat-default-permissions.ts +++ b/packages/client/src/methods/chats/set-chat-default-permissions.ts @@ -53,7 +53,7 @@ export async function setChatDefaultPermissions( if (!(res._ === 'updates' || res._ === 'updatesCombined')) { throw new MtCuteTypeAssertionError( - 'joinChat, (@ channels.joinChannel)', + 'messages.editChatDefaultBannedRights', 'updates | updatesCombined', res._ ) diff --git a/packages/client/src/methods/dialogs/get-dialogs.ts b/packages/client/src/methods/dialogs/get-dialogs.ts index b2e2f6c6..a1aef1f0 100644 --- a/packages/client/src/methods/dialogs/get-dialogs.ts +++ b/packages/client/src/methods/dialogs/get-dialogs.ts @@ -178,7 +178,7 @@ export async function* getDialogs( ): Dialog[] => { if (res._ === 'messages.dialogsNotModified') throw new MtCuteTypeAssertionError( - 'getDialogs', + 'messages.getPeerDialogs', '!messages.dialogsNotModified', 'messages.dialogsNotModified' ) diff --git a/packages/client/src/methods/messages/close-poll.ts b/packages/client/src/methods/messages/close-poll.ts index a866bda5..89dfa1cd 100644 --- a/packages/client/src/methods/messages/close-poll.ts +++ b/packages/client/src/methods/messages/close-poll.ts @@ -41,7 +41,7 @@ export async function closePoll( if (!(res._ === 'updates' || res._ === 'updatesCombined')) throw new MtCuteTypeAssertionError( - '_findMessageInUpdate', + 'messages.editMessage', 'updates | updatesCombined', res._ ) @@ -49,10 +49,10 @@ export async function closePoll( this._handleUpdate(res, true) const upd = res.updates[0] - assertTypeIs('closePoll (@ messages.editMessage)', upd, 'updateMessagePoll') + assertTypeIs('messages.editMessage (@ .updates[0])', upd, 'updateMessagePoll') if (!upd.poll) { throw new MtCuteTypeAssertionError( - 'closePoll (@ messages.editMessage)', + 'messages.editMessage (@ .updates[0].poll)', 'poll', 'undefined' ) diff --git a/packages/client/src/methods/messages/find-in-update.ts b/packages/client/src/methods/messages/find-in-update.ts index 6225a9b7..18f3b941 100644 --- a/packages/client/src/methods/messages/find-in-update.ts +++ b/packages/client/src/methods/messages/find-in-update.ts @@ -42,7 +42,7 @@ export function _findMessageInUpdate( } throw new MtCuteTypeAssertionError( - '_findMessageInUpdate (@ -> updates[*])', + '_findInUpdate (@ .updates[*])', 'updateNewMessage | updateNewChannelMessage | updateNewScheduledMessage', 'none' ) diff --git a/packages/client/src/methods/messages/forward-messages.ts b/packages/client/src/methods/messages/forward-messages.ts index 7ed7b1c6..3031329d 100644 --- a/packages/client/src/methods/messages/forward-messages.ts +++ b/packages/client/src/methods/messages/forward-messages.ts @@ -232,7 +232,7 @@ export async function forwardMessages( if (!(res._ === 'updates' || res._ === 'updatesCombined')) throw new MtCuteTypeAssertionError( - 'forwardMessages', + 'messages.forwardMessages', 'updates | updatesCombined', res._ ) diff --git a/packages/client/src/methods/messages/get-history.ts b/packages/client/src/methods/messages/get-history.ts index ae8d84db..0c45c881 100644 --- a/packages/client/src/methods/messages/get-history.ts +++ b/packages/client/src/methods/messages/get-history.ts @@ -75,7 +75,7 @@ export async function getHistory( if (res._ === 'messages.messagesNotModified') throw new MtCuteTypeAssertionError( - 'getHistory', + 'messages.getHistory', '!messages.messagesNotModified', res._ ) diff --git a/packages/client/src/methods/messages/search-global.ts b/packages/client/src/methods/messages/search-global.ts index f43e0199..fafc4a51 100644 --- a/packages/client/src/methods/messages/search-global.ts +++ b/packages/client/src/methods/messages/search-global.ts @@ -72,7 +72,7 @@ export async function* searchGlobal( if (res._ === 'messages.messagesNotModified') throw new MtCuteTypeAssertionError( - 'searchMessages', + 'messages.searchGlobal', '!messages.messagesNotModified', res._ ) diff --git a/packages/client/src/methods/messages/search-messages.ts b/packages/client/src/methods/messages/search-messages.ts index ff20fa71..e0fad373 100644 --- a/packages/client/src/methods/messages/search-messages.ts +++ b/packages/client/src/methods/messages/search-messages.ts @@ -97,7 +97,7 @@ export async function* searchMessages( if (res._ === 'messages.messagesNotModified') throw new MtCuteTypeAssertionError( - 'searchMessages', + 'messages.search', '!messages.messagesNotModified', res._ ) diff --git a/packages/client/src/methods/messages/send-vote.ts b/packages/client/src/methods/messages/send-vote.ts index 3331812e..f87d9e7f 100644 --- a/packages/client/src/methods/messages/send-vote.ts +++ b/packages/client/src/methods/messages/send-vote.ts @@ -1,7 +1,15 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtCuteArgumentError, MtCuteTypeAssertionError, Poll } from '../../types' +import { + InputPeerLike, + MtCuteArgumentError, + MtCuteTypeAssertionError, + Poll, +} from '../../types' import { MaybeArray } from '@mtcute/core' -import { createUsersChatsIndex, normalizeToInputPeer } from '../../utils/peer-utils' +import { + createUsersChatsIndex, + normalizeToInputPeer, +} from '../../utils/peer-utils' import { assertTypeIs } from '../../utils/type-assertion' /** @@ -31,7 +39,9 @@ export async function sendVote( if (options.some((it) => typeof it === 'number')) { const msg = await this.getMessages(peer, message) if (!(msg.media instanceof Poll)) - throw new MtCuteArgumentError('This message does not contain a poll') + throw new MtCuteArgumentError( + 'This message does not contain a poll' + ) poll = msg.media options = options.map((opt) => { @@ -46,12 +56,12 @@ export async function sendVote( _: 'messages.sendVote', peer, msgId: message, - options: options as Buffer[] + options: options as Buffer[], }) if (!(res._ === 'updates' || res._ === 'updatesCombined')) throw new MtCuteTypeAssertionError( - '_findMessageInUpdate', + 'messages.sendVote', 'updates | updatesCombined', res._ ) @@ -59,9 +69,13 @@ export async function sendVote( this._handleUpdate(res, true) const upd = res.updates[0] - assertTypeIs('sendVote (@ messages.sendVote)', upd, 'updateMessagePoll') + assertTypeIs('messages.sendVote (@ .updates[0])', upd, 'updateMessagePoll') if (!upd.poll) { - throw new MtCuteTypeAssertionError('sendVote (@ messages.sendVote)', 'poll', 'undefined') + throw new MtCuteTypeAssertionError( + 'messages.sendVote (@ .updates[0].poll)', + 'poll', + 'undefined' + ) } const { users } = createUsersChatsIndex(res) diff --git a/packages/client/src/types/media/thumbnail.ts b/packages/client/src/types/media/thumbnail.ts index 0a5cf4fe..5598ec80 100644 --- a/packages/client/src/types/media/thumbnail.ts +++ b/packages/client/src/types/media/thumbnail.ts @@ -64,7 +64,7 @@ export class Thumbnail extends FileLocation { ) { if (sz._ === 'photoSizeEmpty' || sz._ === 'photoCachedSize') throw new MtCuteTypeAssertionError( - 'Thumbnail#constructor (sz)', + 'sz', 'not (photoSizeEmpty | photoCachedSize)', sz._ ) diff --git a/packages/client/src/types/messages/message.ts b/packages/client/src/types/messages/message.ts index 2ef37c53..3e81d1c6 100644 --- a/packages/client/src/types/messages/message.ts +++ b/packages/client/src/types/messages/message.ts @@ -216,7 +216,7 @@ export class Message { this._sender = new User(this.client, this._users[from.userId]) } else throw new MtCuteTypeAssertionError( - 'Message#sender (@ raw.fromId)', + 'raw.fromId', 'peerUser | peerChannel', from._ ) @@ -287,7 +287,7 @@ export class Message { break default: throw new MtCuteTypeAssertionError( - 'Message#forward (@ raw.fwdFrom.fromId)', + 'raw.fwdFrom.fromId', 'peerUser | peerChannel', fwd.fromId._ ) diff --git a/packages/client/src/types/misc/sticker-set.ts b/packages/client/src/types/misc/sticker-set.ts index 7f890b40..04f15715 100644 --- a/packages/client/src/types/misc/sticker-set.ts +++ b/packages/client/src/types/misc/sticker-set.ts @@ -147,7 +147,7 @@ export class StickerSet { ) if (!(sticker instanceof Sticker)) { throw new MtCuteTypeAssertionError( - 'StickerSet#stickers (full.documents)', + 'full.documents', 'Sticker', sticker.mimeType ) diff --git a/packages/client/src/types/peers/chat.ts b/packages/client/src/types/peers/chat.ts index 1ca796e3..9c05c3a1 100644 --- a/packages/client/src/types/peers/chat.ts +++ b/packages/client/src/types/peers/chat.ts @@ -66,7 +66,7 @@ export class Chat { ) ) throw new MtCuteTypeAssertionError( - 'Chat#constructor (@ peer)', + 'peer', 'user | chat | channel', peer._ )