- TelegramBot
- TelegramApiError
- EventError
- TelegramTokenError
- BitFieldError
- IntentsError
- ParameterError
- ErrorTable
- ErrorExtension
- constructor
- getMe
- deleteWebhook
- deleteWebhook
- getWebhookInfo
- sendMessage
- sendPhoto
- sendAudio
- sendDocument
- sendVideo
- sendAnimation
- sendVoice
- sendVideoNote
- sendMediaGroup
- sendLocation
- sendVenue
- forwardMessage
- copyMessage
- sendContact
- sendPoll
- sendDice
- sendChatAction
- getUserProfilePhotos
- getFile
- downloadFile
- banChatMember
- unbanChatMember
- restrictChatMember
- promoteChatMember
- setChatAdministratorCustomTitle
- banChatSenderChat
- unbanChatSenderChat
- setChatPermissions
- portChatInviteLink
- createChatInviteLink
- editChatInviteLink
- revokeChatInviteLink
- approveChatJoinRequest
- declineChatJoinRequest
- setChatPhoto
- deleteChatPhoto
- setChatTitle
- setChatDescription
- pinChatMessage
- unpinChatMessage
- unpinAllChatMessages
- leaveChat
- getChat
- getChatAdministrators
- getChatMemberCount
- getChatMember
- setChatStickerSet
- deleteChatStickerSet
- getForumTopicIconStickers
- createForumTopic
- editForumTopic
- closeForumTopic
- reopenForumTopic
- deleteForumTopic
- unpinAllForumTopicMessages
- editGeneralForumTopic
- closeGeneralForumTopic
- reopenGeneralForumTopic
- hideGeneralForumTopic
- unhideGeneralForumTopic
- answerCallbackQuery
- setMyCommands
- deleteMyCommands
- getMyCommands
- setMyName
- getMyName
- setMyDescription
- getMyDescription
- setMyShortDescription
- getMyShortDescription
- setChatMenuButton
- getChatMenuButton
- setMyDefaultAdministratorRights
- getMyDefaultAdministratorRights
- editMessageText
- editMessageCaption
- editMessageMedia
- editMessageLiveLocation
- stopMessageLiveLocation
- editMessageReplyMarkup
- stopPoll
- sendSticker
- getStickerSet
- getCustomEmojiStickers
- uploadStickerFile
- createNewStickerSet
- addStickerToSet
- setStickerPositionInSet
- deleteStickerFromSet
- setStickerEmoji
- setStickerKeywords
- setStickerKeywords
- setStickerMaskPosition
- setStickerMaskPosition
- setStickerSetTitle
- setStickerSetThumbnail
- setCustomEmojiStickerSetThumbnail
- deleteStickerSet
- answerInlineQuery
- answerWebAppQuery
- sendInvoice
- createInvoiceLink
- answerShippingQuery
- answerPreCheckoutQuery
- setPassportDataErrors
- sendGame
- deleteMessage
- createChat
- get
- set
- SimpleStorage
- SessionTypes
- Request
- Markup
- constructor
- toJSON
- setInline
- setResize
- setOneTime
- setSelective
- addKeyboard
- MessageCollector
- Events
- ChatActionType
- EntityType
- ChatPermission
- GroupPermission
- GroupStatus
- DocumentTypes
- IntentsBitField
- toArray
- has
- decodeIntents
- IntentBits
- TelegramIntentBits
- checkMessageLinks
- extractUserMentions
- extractHashtags
- checkLocation
- checkUserMentions
- checkHashtags
- checkPhoneNumber
- extractUserIdFromLink
- checkGroupOrChannel
- checkEmoji
- checkSticker
- extractUsernameFromLink
- checkBot
- checkChannel
- checkLink
- checkGroup
- checkUsername
- extractUsername
Extends BaseClient
A class representing a Telegram Bot client.
The Telegram Bot API token.
Type: string
The base URL for the Telegram Bot API.
Type: string
Registers a listener for the specified event.
on(eventName, listener) { return this.on(eventName, listener); }
Removes the specified listener for the given event.
off(eventName, listener) { return this.off(eventName, listener); }
Registers a one-time listener for the specified event. The listener is automatically removed after it's invoked.
once(eventName, listener) { return this.once(eventName, listener); }
The function that starts the whole process
Extends Error
Custom error class for errors returned by the Telegram Bot API
error
string The error message returned by the Telegram Bot API
Extends Error
Custom error class for errors related to event handling
error
string The error message
Extends Error
Custom error class for errors related to Telegram tokens
error
string The error message
Extends Error
Custom error class for errors related to bit fields
error
string The error message
Extends Error
Custom error class for errors related to intents
error
string The error message
Extends Error
Custom error class for errors related to function parameters
error
string The error message
Extends Error
Custom error class for a collection of errors
error
string The error message
Extends Error
Custom error class for a collection of errors
error
string The error message
Creat method Telegram Api
token
string The Telegram Bot API token.intents
(string | array | number)? The client intents.parseMode
string? The parse mode for message formatting.chatId
(string | number)? The default chat ID for sending messages.queryString
string? The default query string for API requests.offSetType
(string | object)? The type of offset to use for updates.
Get information about the bot itself.
- Throws TelegramApiError Throws an error if the response is empty or if there is an error returned by the Telegram API.
Returns Promise<object> Returns a Promise that resolves with an object containing information about the bot.
Delete the webhook.
-
options
object Options to configure the webhook deletion.options.dropPendingUpdates
boolean Pass true to drop pending updates while deleting the webhook.
- Throws TelegramApiError Throws an error if the webhook deletion fails.
Returns Promise<object> Returns the response object containing the result of the deletion request.
Delete the currently set webhook.
- Throws TelegramApiError Throws an error if the Telegram API returns a response indicating failure.
Returns Promise<boolean> Returns a Promise that resolves with a boolean indicating whether the operation was successful.
Get current webhook status.
- Throws TelegramApiError If an error occurs while fetching the webhook status.
Returns Promise<object> An object representing the current webhook status.
Send a message to a chat.
-
options
object object containing options for the messageoptions.chatId
(number | string) Unique identifier for the target chat or username of the target channel (optional, defaultthis.chatId
)options.text
string Text of the message to be sent.options.replyMarkup
(object | string)? Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard, or to force a reply from the user.options.allowReply
boolean? Passtrue
if the message should be sent even if the specified replied-to message is not foundoptions.notification
boolean? Sends the message silently. Users will receive a notification with no sound.options.content
boolean? Passtrue
if the message should be encrypted.options.threadId
number? Unique identifier for the target message thread.options.replyToMessageId
number? If the message is a reply, the ID of the original message.options.parseMode
string Send'Markdown'
or'HTML'
if you want Telegram apps to show bold, italic, fixed-width text, or inline URLs in your bot's message. (optional, defaultthis.parseMode
)
- Throws TelegramApiError Throws an error if there is a problem with the Telegram API request.
Returns Promise<object> Returns the sent message.
Sends a photo to the chat.
-
options
object The options object.options.chatId
number =this.chatId - The ID of the chat where the photo will be sent.options.threadId
number? The ID of the thread message.options.photo
any The photo to be sent. Can be a string URL or Buffer.options.caption
string The photo caption.options.parseMode
string? The parse mode of the caption. Can be "MarkdownV2" or "HTML".options.captionEntities
Array<object> The special entities of the caption.options.hasSpoiler
boolean? If the photo should be marked as a spoiler.options.notification
boolean? If notifications should be disabled for the message.options.content
boolean? If the message should be protected by the "new forwarded messages privacy mode".options.replyToMessageId
number? The ID of the message being replied to.options.allowReply
boolean? If the message can be sent without a reply to another message.options.replyMarkup
object? The reply markup object.
- Throws TelegramApiError If an error occurs while sending the photo.
Returns Promise<object> The sent photo object.
Sends an audio message to the chat.
-
options
object The options to configure the audio message.options.chatId
string The chat ID of the recipient. (optional, defaultthis.chatId
)options.threadId
string? The message thread ID.options.audio
any The audio file to send.options.caption
string? The caption of the audio message.options.parseMode
string The parsing mode of the caption (optional, defaultthis.parseMode
)options.captionEntities
Array? The special entities in the caption.options.duration
number? The duration of the audio message.options.performer
string? The performer of the audio file.options.title
string? The title of the audio file.options.thumbnail
any? The thumbnail of the audio message.options.notification
boolean If true, sends the message silently. (optional, defaulttrue
)options.content
boolean If true, protects the audio file from unauthorized access. (optional, defaultfalse
)options.replyToMessageId
number? The ID of the message to reply to.options.allowReply
boolean If true, allows the message to be sent without replying to a message. (optional, defaultfalse
)options.replyMarkup
(object | string)? The reply markup of the message.
- Throws TelegramApiError If there is an error sending the message.
Returns Promise<object> The sent audio message object.
Sends a document to the chat.
-
options
object Options for sending the document.options.chatId
number? Unique identifier for the target chat or username of the target channel.options.threadId
number? Identifier of the message thread.options.document
any File path or Stream for the document to send.options.thumbnail
any? File path or Stream for the document's thumbnail.options.caption
string? Caption for the document.options.parseMode
string? The mode for parsing entities in the document caption. One of "Markdown" or "HTML".options.captionEntities
Array? List of special entities to highlight in the document caption.options.disableContentTypeDetection
boolean? Disables automatic content type detection for uploaded files.options.notification
boolean? Sends the message silently if true.options.content
boolean? If the document should be protected by a password.options.replyToMessageId
number? Identifier of the message being replied to.options.allowReply
boolean? Pass true to enable sending the message without a reply.options.replyMarkup
(object | string)? InlineKeyboardMarkup or ReplyKeyboardMarkup for the sent message.
- Throws TelegramApiError When the request to the Telegram API fails.
Returns Promise<object> The sent message object.
Sends a video message to a chat.
-
options
object Options for the video message.options.chatId
(string | number) Unique identifier for the target chat or username of the target channel.options.video
any Video to send. Can be a string path or a stream.options.duration
number? Duration of the video in seconds.options.width
number? Width of the video.options.height
number? Height of the video.options.thumbnail
string? Thumbnail of the video. Can be a string path or a stream.options.caption
string? Caption for the video.options.parseMode
string? Mode for parsing entities in the video caption.options.captionEntities
Array? List of special entities that appear in the video caption.options.hasSpoiler
boolean? Pass true, if a spoiler for the media message is needed.options.supportsStreaming
boolean? Pass true, if the uploaded video is suitable for streaming.options.notification
boolean? Sends the message silently. Users will receive a notification with no sound.options.content
boolean? Pass true, if the video should be encrypted.options.replyToMessageId
number? The ID of the message to reply to.options.allowReply
boolean? Pass true, if the message should be sent even if the specified replied-to message is not found.options.replyMarkup
(object | string)? Additional interface options for the message.
- Throws TelegramApiError Throws an error if the API response returns an error code.
Returns Promise<object> Returns a Promise that resolves to the sent video message object on success.
Sends an animation message to a specified chat or channel.
-
options
object The options for sending the animation message.options.chatId
string? The chat or channel id to send the animation message to.options.animation
string The animation to be sent.options.duration
number? The duration of the animation.options.width
number? The width of the animation.options.height
number? The height of the animation.options.thumbnail
string? The thumbnail of the animation.options.caption
string? The caption of the animation.options.parseMode
string? The parse mode of the animation.options.captionEntities
Array? The caption entities of the animation.options.hasSpoiler
boolean? Whether the animation has a spoiler.options.notification
boolean? Whether the notification for the message should be disabled.options.content
boolean? Whether the message content should be protected.options.replyToMessageId
number? The message id to reply to.options.allowReply
boolean? Whether the message can be sent without a reply.options.replyMarkup
(object | string)? The reply markup for the message.options.threadId
string? The id of the message thread to send the animation to.
- Throws TelegramApiError If there was an error while sending the animation message.
Returns Promise<object> The response object from the Telegram API.
Sends a voice message to the specified chat.
-
options
object Options for sending the voice message.options.voice
string The voice file to send.options.chatId
(string | number)? The chat ID to send the voice message to. Defaults to the chat ID of the current context if not provided.options.caption
string? Caption for the voice message, 0-1024 characters.options.parseMode
string? The parse mode of the message caption. Defaults to the parse mode of the current context if not provided.options.captionEntities
Array? Additional entities to specify for message caption.options.duration
number? Duration of the voice message in seconds.options.notification
boolean? Sends the message silently. Users will receive a notification with no sound.options.content
boolean? Pass true if the uploaded voice message is a file protected with a password.options.replyToMessageId
number? The message ID to reply to.options.allowReply
boolean? Pass true if sending the message without reply is allowed.options.replyMarkup
(object | string)? InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply. Additional interface options for the message.options.threadId
string? Unique identifier for the target chat thread.
- Throws TelegramApiError If an error occurs while sending the voice message.
Returns Promise<object> On success, the sent Message is returned.
Sends a video note message to a chat.
-
options
object The options object.options.chatId
(string | number) The chat ID to send the message to.options.videoNote
string The video note file to send. Pass a file ID or a URL to the video note file.options.duration
number? Duration of the video note in seconds.options.length
number? File size of the video note.options.thumbnail
object? Optional thumbnail (image file to use as the thumbnail) for the video note.options.notification
boolean? Sends the message silently if true, otherwise with sound (default).options.content
boolean? True, if the video note should be protected by a password.options.threadId
number? Message thread ID.options.replyToMessageId
number? ID of the original message when sending a reply.options.allowReply
boolean? Pass true, if the message should be sent even without a reply message.options.replyMarkup
(object | string)? Additional interface options (JSON-serialized object).
- Throws TelegramApiError Throws an error if the response contains an error_code property.
Returns Promise<object> Returns a Promise that resolves to the sent message object.
Sends a media group to the specified chat.
-
options
object An object containing the options for the media group.options.chatId
number =this.chatId - The ID of the chat to send the media group to.options.notification
boolean Pass true to disable notification for the message. (optional, defaultfalse
)options.content
boolean Pass true to protect the content of the media group from being forwarded. (optional, defaultfalse
)options.threadId
number? Send message as a reply to a message thread.options.replyToMessageId
number? The ID of the message being replied to.options.allowReply
boolean Pass true to allow sending the media group without replying to a message. (optional, defaultfalse
)options.media
Array<object> An array of media objects to be sent in the media group.options.media
string [].type - Type of the media (photo, video, etc.).options.media
(string | any) [].media - The media to send (as a string).
-
string
string [].caption] - Caption of the media (0-1024 characters). -
string
string [].parseMode] - The parse mode of the caption (Markdown, HTML). -
number
number [].width] - The width of the media (for videos and photos). -
number
number [].height] - The height of the media (for videos and photos). -
number
number [].duration] - Duration of the video/audio (in seconds). -
boolean
boolean [].supportsStreaming] - Pass true if the uploaded video supports streaming.
- Throws TelegramApiError Throws an error if the response contains an error code.
Returns Promise<object> Returns a Promise that resolves to the sent media group object on success.
Sends a location message to a chat.
-
options
object An object containing the options for sending the location message.options.latitude
number The latitude of the location.options.longitude
number The longitude of the location.options.accuracy
number? The horizontal accuracy of the location.options.livePeriod
number? The duration in seconds for which the location will be updated.options.heading
number? The direction in which the user is moving, in degrees. Must be between 1 and 360.options.proximityRadius
number? The radius of the proximity alert for the location, in meters.options.notification
boolean Sends the message silently. Users will receive a notification with no sound. (optional, defaulttrue
)options.content
boolean Passes the message content through the Telegram content provider. (optional, defaultfalse
)options.threadId
number? The ID of the message thread.options.replyToMessageId
number? The ID of the message to which this message is a reply.options.allowReply
boolean Pass true if the message should be sent even if the specified reply_to_message_id is not found. (optional, defaulttrue
)options.replyMarkup
(object | string)? A JSON-serialized object for an inline keyboard or custom reply keyboard.
- Throws TelegramApiError If the Telegram API returns an error.
Returns Promise<object> The sent location message object.
Sends a venue message to the chat.
-
options
object The options to send the message.options.chatId
string? The chat id where to send the message.options.threadId
number? Unique identifier for the target chat thread.options.latitude
number Latitude of the venue.options.longitude
number Longitude of the venue.options.title
string Name of the venue.options.address
string Address of the venue.options.foursquareId
string? Foursquare identifier of the venue.options.foursquareType
string? Foursquare type of the venue, if known.options.googlePlaceId
string? Google Places identifier of the venue.options.googlePlaceType
string? Google Places type of the venue, if known.options.notification
boolean? Sends the message silently.options.content
boolean? For messages forwarded from channels, sets the channel as protected.options.replyToMessageId
number? Id of the message to reply to.options.allowReply
boolean? Pass True, if the message should be sent even if the specified replied-to message is not found.options.replyMarkup
(object | string)? Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
- Throws TelegramApiError When there's an error sending the message.
Returns Promise<object> On success, the sent Message is returned.
Forward a message to a chat.
-
options
object The options to use for forwarding the message.options.chatId
number =this.chatId - The chat ID of the recipient chat. Required ifthis.chatId
is not set.options.fromChatId
number The chat ID of the chat where the message to forward is located.options.messageId
number The message ID of the message to forward.options.threadId
number The ID of the message thread. Optional.options.notification
boolean Passtrue
to disable notification for the message. Optional.options.content
boolean Passtrue
to protect forwarded message from being copied. Optional.
- Throws TelegramApiError If an error occurs while forwarding the message.
Returns Promise<object> The forwarded message object.
Copy a message from one chat to another.
-
options
object The options for copying the message.options.fromChatId
string The chat ID of the chat where the original message is located.options.messageId
string The message ID of the message to copy.options.threadId
string? The message thread ID.options.chatId
string The chat ID of the chat where the message will be copied to. If not provided, uses the chat ID set in the constructor. (optional, defaultthis.chatId
)options.caption
string? The caption of the message to be copied.options.parseMode
string The parsing mode of the message caption. If not provided, uses the parse mode set in the constructor. (optional, defaultthis.parseMode
)options.captionEntities
Array<object>? The entities in the message caption.options.notification
boolean? Sends the message silently. Users will receive a notification with no sound.options.content
boolean? Pass true to protect the content of the message from being forwarded without permission.options.replyToMessageId
string? The message ID being replied to.options.allowSendingWithoutReply
boolean? Pass true to allow sending the message without a reply.options.replyMarkup
(object | string)? The inline keyboard markup for the message.
- Throws TelegramApiError Throws an error if the Telegram API returns an error.
Returns Promise<object> Returns the copied message object.
Sends a contact to the chat.
-
options
object Options for sending the contact.options.chatId
number =this.chatId - ID of the chat where the contact should be sent.options.phoneNumber
string Phone number of the contact.options.firstName
string First name of the contact.options.lastName
string? Last name of the contact.options.vcard
string? Additional vCard data about the contact.options.notification
boolean Sends the message silently if true. (optional, defaulttrue
)options.content
boolean Protects the contact's content if true. (optional, defaulttrue
)options.threadId
number? Thread ID for the message.options.replyToMessageId
number? ID of the message being replied to.options.allowReply
boolean Allows sending the message without a reply if true. (optional, defaulttrue
)options.replyMarkup
(object | string)? Additional options for reply markup.
- Throws TelegramApiError Throws an error if the API request fails.
Returns Promise<object> Result of the sent contact message.
Sends a poll to the chat with the given options.
-
options
object An object containing the poll options.options.chatId
number? The ID of the chat to send the poll to.options.question
string The question of the poll.options.options
Array<string> An array of strings representing the answer options for the poll.options.isAnonymous
boolean Whether the poll is anonymous or not.options.type
string The type of the poll. Can be "quiz" or "regular".options.allowsMultipleAnswers
boolean Whether the poll allows multiple answers or not.options.correctOptionId
number The correct answer option ID for the quiz type poll.options.explanation
string The explanation for the correct answer option in the quiz type poll.options.explanationParseMode
string The parse mode for the explanation message.options.explanationEntities
Array<object> An array of message entities in the explanation message.options.openPeriod
number The amount of time in seconds the poll will be open for.options.closeDate
number The date when the poll will be automatically closed.options.isClosed
boolean Whether the poll is closed or not.options.notification
boolean Whether to disable notifications for the message or not.options.content
boolean Whether to protect the poll content from being copied or not.options.threadId
number The message thread ID.options.replyToMessageId
number The ID of the message being replied to.options.allowReply
boolean Whether to allow sending the poll without replying to a message or not.options.replyMarkup
object The reply markup for the message.
- Throws TelegramApiError If an error occurs while sending the poll.
Returns Promise<object> The response from the Telegram API.
Sends a dice animation to the chat.
-
options
object The options for the dice animation.options.chatId
number? The ID of the chat where to send the message.options.emoji
string The emoji to use for the dice animation.options.notification
boolean Sends the message silently. Users will receive a notification with no sound. (optional, defaultfalse
)options.content
boolean Pass True, if the message contains a game. (optional, defaultfalse
)options.threadId
number? Unique identifier for the target chat or username of the target channel (in the format @channelusername) of the thread to send a reply to.options.replyToMessageId
number? The ID of the message to reply to.options.allowReply
boolean Pass True, if the message should be sent even if the specified replied-to message is not found. (optional, defaultfalse
)options.replyMarkup
(object | string)? Additional interface options for sending the message.
- Throws TelegramApiError Throws an error when there is an error in the request.
Returns Promise<object> Returns a Promise that resolves to the sent message object on success.
Sends a chat action to indicate the bot is performing an action (typing, uploading a photo etc.) to the user.
-
options
object The options object for sending the chat action.options.chatId
string The chat ID to send the chat action to. Ifthis.chatId
is set, it will be used by default. (optional, defaultthis.chatId
)options.action
string The type of action to send to the user (typing, upload_photo, record_video, upload_video, record_audio, upload_audio, upload_document, find_location, record_video_note, upload_video_note).options.threadId
string Unique identifier for the target chat message thread.
- Throws TelegramApiError Throws an error if the Telegram API returns an error code.
Returns Promise<object> The response object from the Telegram API containing information about the sent chat action.
Returns user profile photos.
-
options
object The options object.
- Throws TelegramApiError Throws an error if the Telegram API returns an error.
Returns Promise<object> On success, an object containing the user profile photos is returned.
Get information about a file on the Telegram server
fileId
string ID of the file to fetch information for
- Throws TelegramApiError If the Telegram API returns an error
Returns Promise<object> An object containing information about the file
Downloads a file from the Telegram servers.
filePath
string The path of the file to download.
- Throws Error If the HTTP response status code is not 200.
Returns Promise<any> A Promise that resolves with the downloaded file as a Buffer, or rejects with an error.
Ban a chat member in the Telegram chat.
-
options
object The options for banning a chat member.options.chatId
string The ID of the chat where the user is to be banned. (optional, defaultthis.chatId
)options.userId
number The ID of the user to be banned.options.untilDate
number Date when the user will be unbanned, unix time.options.revokeMessages
boolean Pass True to delete all messages from the chat for the user that is being removed.
- Throws TelegramApiError If an error occurs while executing the request.
Returns Promise<object> On success, returns True.
Unban a previously banned chat member in a Telegram chat.
-
options
object Options for unbanning a chat member.options.userId
(string | number) Unique identifier of the chat member to unban.options.chatId
(string | number)? Unique identifier of the target chat. If not specified, defaults to the chat associated with the bot instance.options.onlyIfBanned
boolean Iftrue
, only unban the chat member if they are currently banned. Otherwise, unban the chat member regardless of their current ban status. (optional, defaultfalse
)
- Throws TelegramApiError If the request to the Telegram API fails or returns an error.
Returns Promise<object> Promise which resolves to the result of the Telegram API request.
Restricts a chat member's permissions.
-
options
object The options to restrict the chat member.options.userId
number The ID of the chat member to restrict.options.permissions
object The new permissions to restrict the chat member to.options.useIndependentChatPermissions
boolean? Pass true to use the chat member's own permissions instead of the default permissions.options.untilDate
number? The date when the restrictions will be lifted.
- Throws TelegramApiError Throws an error if the API response contains an error.
Returns Promise<object> The updated ChatMember object.
Promotes a user in a chat with additional privileges.
-
options
object The options object.options.userId
number The ID of the user to promote.options.chatId
number The ID of the chat where the user will be promoted. Defaults to the chat ID set in the instance. (optional, defaultthis.chatId
)options.isAnonymous
boolean? Pass true to promote the user anonymously.options.canManageChat
boolean? Pass true to allow the user to manage the chat.options.canPostMessages
boolean? Pass true to allow the user to post messages in the chat.options.canEditMessages
boolean? Pass true to allow the user to edit messages of other users.options.canDeleteMessages
boolean? Pass true to allow the user to delete messages of other users.options.canManageVideoChats
boolean? Pass true to allow the user to manage voice chats.options.canRestrictMembers
boolean? Pass true to allow the user to restrict members in the chat.options.canPromoteMembers
boolean? Pass true to allow the user to promote other members in the chat.options.canChangeInfo
boolean? Pass true to allow the user to change the chat's title, photo, and other settings.options.canInviteUsers
boolean? Pass true to allow the user to invite new users to the chat.options.canPinMessages
boolean? Pass true to allow the user to pin messages in the chat.options.canManageTopics
boolean? Pass true to allow the user to manage chat topics.
- Throws TelegramApiError Throws an error with the Telegram API description if the response contains an error.
Returns Promise<object> Returns a Promise that resolves to the promoted user object on success.
Sets a custom title for a chat administrator.
-
options
object The options object.
- Throws TelegramApiError If an error occurs while setting the custom title.
Returns Promise<boolean> A promise that resolves with true
if the custom title was set successfully.
Ban a user from sending messages in a chat.
-
options
object The options to use for banning the user.
- Throws TelegramApiError If an error occurs while banning the user.
Returns Promise<object> The result of the request.
Unban a previously kicked chat member from the chat and remove any previous ban on their username.
-
options
object Options for unbanning a chat member.
- Throws TelegramApiError When an error occurs while unbanning the chat member.
Returns Promise<object> On success, the returned object will contain the ok
field set to true
.
Sets chat permissions for a given chat.
-
options
object The options for setting chat permissions.options.chatId
string The ID of the chat to set permissions for. If not provided, defaults to the chat ID saved in the instance. (optional, defaultthis.chatId
)options.permissions
object The chat permissions to set. This should be an object containing key-value pairs where the keys are the names of the permissions and the values are booleans indicating whether the permission should be allowed or not.options.independentPermissions
boolean Whether to use independent chat permissions or not. (optional, defaultfalse
)
- Throws TelegramApiError Throws an error if the Telegram API returns an error.
Returns Promise<object> Returns a promise which resolves to the result of the API request.
Exports the invite link to a chat. If chatId
is not defined on the instance, it should be provided in options
.
chatId
string Unique identifier for the target chat.
- Throws TelegramApiError If an error occurs while exporting the chat invite link.
Returns Promise<string> The invite link for the chat.
Creates a new chat invite link with the specified options.
-
options
object The options for the chat invite link.options.chatId
string? The ID of the chat where the invite link will be created. If not provided, the ID of the current chat will be used.options.name
string? The name of the chat that will be shown in the invite link preview. If not provided, the chat name will be used.options.expireDate
Date? The date and time when the invite link will expire.options.memberLimit
number? The maximum number of members that can join the chat using the invite link. If not provided, there will be no limit.options.createsJoinRequest
boolean? Determines whether the invite link creates a join request instead of adding the user directly to the chat. Defaults to false.
- Throws TelegramApiError If the API response contains an error.
Returns Promise<object> The created chat invite link object.
Edits the specified chat invite link. Returns the edited invite link as a ChatInviteLink object.
-
options
object Options for editing the chat invite link.options.chatId
number? Unique identifier of the target chat.options.inviteLink
string The invite link to edit.options.name
string? New name for the invite link, 1-64 characters.options.expireDate
number? Point in time (Unix timestamp) when the link will expire, in 30-2592000 seconds.options.memberLimit
number? Maximum number of chat members that can join the chat through the link.options.createsJoinRequest
boolean? True, if the link is a primary link for inviting users to a chat.
- Throws TelegramApiError If the response contains an error.
Returns Promise<any> The edited chat invite link as a ChatInviteLink object.
Revoke a chat invite link.
-
options
object The options to use for the API call.
- Throws TelegramApiError If the API call fails, an error with the description of the problem.
Returns Promise<object> The API response object.
Approve a join request to a chat.
-
options
object The options to approve the chat join request.
- Throws TelegramApiError If the response contains an error code.
Returns Promise<object> The result of the approveChatJoinRequest method.
Declines a chat join request from a user.
-
options
object Options object.
- Throws TelegramApiError Throws an error if the Telegram API responds with an error.
Returns Promise<object> Returns a Promise that resolves to the API response on success.
Sets a new profile photo for the chat. The photo can be a local file path or a URL.
-
options
object Options for setting the chat photo.
- Throws TelegramApiError If the request to the Telegram API fails or if the response contains an error code.
Returns Promise<object> On success, the method returns True.
Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
chatId
number =this.chatId - Unique identifier for the target chat or username of the target channel (in the format@channelusername
).options
string Optional parameters.
- Throws TelegramApiError If an error is encountered while processing the request.
Returns Promise<boolean> On success, returns True.
Set a new chat title for a given chat ID.
-
options
object The options to set a new chat title.
- Throws TelegramApiError If the request to set a new chat title fails, this error is thrown.
Returns Promise<object> On success, the updated chat object is returned.
Sets the description of a chat.
-
options
object The options object.
- Throws TelegramApiError Throws an error if the request to the Telegram API fails or if the response contains an error.
Returns Promise<object> Returns a promise that resolves to the response from the Telegram API.
Pins a message in a chat.
-
options
object The options to pin the message.
- Throws TelegramApiError If an error occurs while attempting to pin the message.
Returns Promise<object> On success, the method returns True.
Unpins a message in a chat.
-
options
object The options for unpinning a message in a chat.
- Throws TelegramApiError Throws an error if the API returns an error response.
Returns Promise<object> Returns a Promise that resolves to the result of the API call.
Unpins all chat messages in the specified chat.
chatId
number =this.chatId - Unique identifier for the target chat or username of the target channel (in the format @channelusername).
- Throws TelegramApiError When the API call fails.
Returns Promise<object> On success, the sent Message is returned.
Leave a chat.
chatId
number =this.chatId - The chat ID of the chat to leave.
- Throws TelegramApiError When the response contains an error.
Returns Promise<object> On success, the method returns True.
Returns information about a chat.
chatId
string The ID of the chat to get information about.
- Throws TelegramApiError Throws an error if the response contains an error code.
Returns Promise<object> Returns an object containing information about the chat.
Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
chatId
(number | string) Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- Throws TelegramApiError If the request to the Telegram API fails or if the API returns an error
Returns Promise<Array<any>> On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots.
Retrieves the current number of members in a chat.
chatId
number =this.chatId - The identifier of the chat. If not provided, the chatId property of the TelegramBot instance will be used.
- Throws TelegramApiError If there is an error while calling the Telegram API.
Returns Promise<number> The number of members in the chat.
Returns information about a member of a chat.
-
options
object An object containing chatId and userId.
- Throws TelegramApiError If the request to the Telegram API fails or if there is an error code in the response.
Returns Promise<object> On success, an object containing information about the member.
Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
-
options
object An object containing options to pass.
- Throws TelegramApiError When the response contains an error.
Returns Promise<boolean> Returns True on success.
Deletes a chat's sticker set.
chatId
number =this.chatId - Unique identifier for the target chat or username of the target channel.
- Throws TelegramApiError If an error occurs while deleting the chat's sticker set.
Returns Promise<object> On success, the deleted chat's sticker set is returned.
Get a list of stickers corresponding to a forum topic icon
- Throws TelegramApiError Throws an error if the Telegram API returns an error response
Returns Promise<Array<object>> An array of sticker objects for the corresponding forum topic icon
Creates a forum topic with the specified options.
-
options
object The options to use when creating the forum topic.options.chatId
number? The chat ID to use for the forum topic. If not provided,this.chatId
is used instead.options.name
string The name of the forum topic.options.iconColor
string The icon color of the forum topic.options.iconCustomEmojiId
string The ID of the custom emoji to use as the icon of the forum topic.
- Throws TelegramApiError If there was an error creating the forum topic.
Returns Promise<object> The response from the Telegram API.
Edits a forum topic.
-
options
object The options for editing the forum topic.options.chatId
number =this.chatId - The ID of the chat where the forum topic is located.options.messageThreadId
number The ID of the forum topic to edit.options.name
string The new name for the forum topic.options.iconCustomEmojiId
string The ID of the custom emoji to use as the new icon for the forum topic.
- Throws TelegramApiError If the API response contains an error code.
Returns Promise<object> The edited forum topic object.
Closes a forum topic in the specified chat.
-
options
object The options to be passed to the function.
- Throws TelegramApiError If the Telegram API returns an error.
Returns Promise<object> Returns a Promise that resolves to the result of the API call.
Reopens a previously closed discussion thread in a group or a channel.
-
options
object Options for reopening a discussion thread.
- Throws TelegramApiError Throws error when the API call returns an error.
Delete a forum topic with the given message thread ID from the specified chat or from the default chat ID of the TelegramBot instance.
-
options
object An object containing the options for deleting a forum topic.
- Throws TelegramApiError If there is an error with the Telegram API request.
Returns Promise<object> A Promise which resolves to an object representing the deleted forum topic.
Unpins all messages in a specific message thread in a Telegram chat.
-
options
object The options for unpinning messages.
- Throws TelegramApiError Throws an error if the Telegram API returns an error.
Returns Promise<object> Returns a Promise that resolves to the API response object.
Edit a general forum topic.
-
options
object The options to edit the forum topic.
- Throws TelegramApiError Throws an error if the API call fails.
Returns Promise<object> Returns a Promise that resolves to the edited forum topic object on success.
Closes a general forum topic in a Telegram chat.
chatId
number =this.chatId - The ID of the chat where the forum topic is located.
- Throws TelegramApiError If an error occurs while closing the forum topic.
Returns Promise<object> The result of the API call to the Telegram server.
Reopens a general forum topic on the chat with the specified chat ID.
chatId
string The chat ID of the chat where the topic is located. Optional if chat ID is set in the TelegramBot constructor.
- Throws TelegramApiError Throws an error if the response from the Telegram API contains an error code.
Returns Promise<object> Returns a Promise that resolves to the result of the Telegram API response.
Hides the general forum topic for the specified chat.
- Throws TelegramApiError Throws an error if the response contains an error code.
Returns Promise<boolean> Returns true if the general forum topic was successfully hidden.
Unhides a previously hidden general forum topic in a Telegram chat.
- Throws TelegramApiError Throws an error if the Telegram API responds with an error.
Returns Promise<boolean> Returns true
if the topic was successfully unhidden.
Sends an answer to a callback query sent from an inline keyboard or an inline button.
-
options
object The options object.options.callbackQueryId
string The unique identifier of the callback query to be answered.options.text
string? Text of the notification to be sent, 0-200 characters.options.showAlert
boolean? If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.options.url
string? URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @Botfather, specify the URL that opens your game. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.options.cacheTime
number? The maximum amount of time in seconds that the result of the callback query may be cached client-side. Defaults to 0.
- Throws TelegramApiError Throws an error if the response contains an error_code.
Returns Promise<boolean> Returns true on success.
Sets the list of commands supported by your bot.
-
options
object Options object.
- Throws TelegramApiError Throws a TelegramApiError if the API response contains an error code.
Returns Promise<object> Returns a Promise that resolves to the API response on success, or throws a TelegramApiError on failure.
Use this method to delete the list of the bot's commands for the given scope and user language. Returns True on success.
-
options
object Optional parameters for deleting bot commands.options.scope
string A string, which represent the scope of users. Pass "all_private_chats" to delete commands in all private chats and groups, or "all_public_chats" to delete commands in all chats.options.languageCode
string A string, which represent the user language for which the commands are relevant.
- Throws TelegramApiError If an error is encountered while deleting bot commands.
Returns Promise<boolean> On success, returns True.
Get the list of commands set by the bot for its users.
-
options
object Additional options for the request.
- Throws TelegramApiError Throws an error if there is a problem with the request.
Returns Promise<Array<object>> Returns an array of BotCommand on success.
Asynchronously sets the name and language code for a Telegram bot.
-
options
object An object containing the name and language code to set.
- Throws TelegramApiError Throws an error if there is an error in the API response.
Returns Promise<string> The result of the API request.
Asynchronously retrieves the name of the user associated with the current API authentication token.
languageCode
string An optional parameter to specify the language code in which to retrieve the name.
- Throws TelegramApiError If there is an error with the Telegram API.
Returns Promise<string> The name of the user associated with the current API authentication token.
Set the description of the bot. This is a new field that is not yet widely available.
-
options
object An object containing the following properties:
Returns Promise<object> Returns a Promise that resolves to the updated User object representing the bot. Throws a TelegramApiError if the bot description could not be set.
Get the bot's description, as set by the user.
languageCode
string? IETF language tag of the user's language. Defaults toen
.
- Throws TelegramApiError If the API returns an error.
Returns Promise<string> A promise that resolves to a string representing the bot's description.
Sets the bot's short description for the profile.
-
options
object Options for setting the short description.
- Throws TelegramApiError If the request was unsuccessful, a TelegramApiError will be thrown with the description of the error.
Returns Promise<object> On success, the method returns the bot's updated profile.
Retrieves the bot's short description in the specified language or in English if the language code is not specified.
languageCode
string Optional language code to get the short description in a specific language.
- Throws TelegramApiError When the Telegram API returns an error.
Returns Promise<object> object with the bot's short description.
Sets the menu button for a specific chat.
-
options
object Options for setting the menu button.options.chatId
number =this.chatId - The ID of the chat where the menu button will be set. IfchatId
is not provided, the instance'schatId
property will be used.options.menuButton
object The menu button object to be set. This object should conform to the Telegram Bot API'sInlineKeyboardButton
type.
- Throws TelegramApiError If there is an error in the Telegram API response.
Returns Promise<object> The result object from the Telegram API response.
Gets the menu button of the chat with the given chat ID or the current chat ID if available.
- Throws TelegramApiError Throws an error if the API response contains an error_code.
Returns Promise<object> Returns the menu button of the chat.
Set default administrator rights for the bot in a chat.
-
options
object The options object.
- Throws TelegramApiError Throws an error if the response contains an error_code.
Returns Promise<object> Returns a Promise that resolves to the updated rights for the bot.
Returns the default admin rights of the bot in a given channel or all channels.
forChannels
boolean Passtrue
to return the default admin rights for all channels the bot is an administrator in.
- Throws TelegramApiError Throws an error if the response contains an error_code.
Returns Promise<object> Returns a Promise that resolves to an object with the default admin rights of the bot in the specified channel(s).
Edits the text of a message sent by the bot or via inline mode.
-
options
object Options for editing the message text.options.chatId
string? Unique identifier for the target chat or username of the target channel.options.messageId
number Identifier of the message to edit.options.inlineMessageId
string Identifier of the inline message to edit.options.text
string New text of the message.options.parseMode
string? Format of the new message text.options.entities
Array<object>? List of special entities that appear in message text.options.disableWebPagePreview
boolean? Disables link previews for links in the message.options.replyMarkup
(object | string)? Additional interface options for the message.
- Throws TelegramApiError If the request was unsuccessful.
Returns Promise<object> Response object with edited message.
Edits the caption of a message.
-
options
object The options for editing the caption.options.messageId
number The message ID of the message to edit.options.inlineMessageId
string? Required if the message is an inline message. The inline message ID.options.caption
string? The new caption of the message.options.parseMode
string? The parsing mode of the new caption.options.captionEntities
Array? List of special entities that appear in the caption, which can be specified instead of parse_mode.options.replyMarkup
(object | string)? The reply markup of the message.
- Throws TelegramApiError If there is an error editing the message caption.
Returns Promise<object> The edited message object.
Edits the media of an existing message sent by the bot or via inline mode.
-
options
object The options for editing the message media.
- Throws TelegramApiError If there is an error editing the message.
Returns Promise<object> The edited message object.
Edits the live location of a message sent via the bot (for inline bots) or via the bot in a chat.
-
options
object The options to edit the live location message.options.chatId
string? Required ifinlineMessageId
is not specified. Unique identifier for the target chat.options.messageId
number? Required ifinlineMessageId
is not specified. Identifier of the message to edit.options.inlineMessageId
string? Required ifchatId
andmessageId
are not specified. Identifier of the inline message to edit.options.latitude
number Latitude of new location.options.longitude
number Longitude of new location.options.horizontalAccuracy
number? The radius of uncertainty for the location, measured in meters; 0-1500.options.heading
number? Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.options.proximityAlertRadius
number? Maximum distance for proximity alerts about approaching another chat member, in meters.options.replyMarkup
(object | string)? Additional interface options. An object of theInlineKeyboardMarkup
type.
- Throws TelegramApiError When an error occurs while editing the message.
Returns Promise<object> On success, returns the edited message as a Message
object.
Stop updating a live location message sent by the bot or via inline mode.
-
options
object Options for stopping live location.options.chatId
(string | null) Unique identifier for the target chat or username of the target channel. (optional, defaultthis.chatId
)options.messageId
number Identifier of the sent message.options.inlineMessageId
(string | null) Identifier of the inline message.options.replyMarkup
(object | null) A reply markup object.
- Throws TelegramApiError Throws an error if the Telegram API returns an error.
Returns Promise<object> Returns a Promise that resolves to the stopped live location message object.
Edits the reply markup of a message sent by the bot or via inline mode.
-
options
object The options object.options.chatId
string? Required ifinlineMessageId
is not specified. The unique identifier of the target chat.options.messageId
number? Required ifinlineMessageId
is not specified. Identifier of the message to edit.options.inlineMessageId
string? Required ifchatId
andmessageId
are not specified. Identifier of the inline message.options.replyMarkup
object A new reply markup for the message.
- Throws TelegramApiError If an error occurs while editing the message, an error object will be thrown.
Returns Promise<object> On success, the edited Message is returned.
Stops a poll in a chat.
-
options
object The options to use for stopping the poll.
- Throws TelegramApiError If an error occurs while stopping the poll.
Returns Promise<object> On success, the stopped poll is returned.
Sends a sticker message.
-
options
object The options for sending the sticker message.options.chatId
(string | number)? The ID of the chat where the message will be sent. Required ifthis.chatId
is not set.options.sticker
string The sticker file ID or URL.options.emoji
string? The emoji corresponding to the sticker.options.notification
boolean? Sends the message silently, without a notification. False by default.options.content
boolean? Pass true to send the sticker as a protected content message. False by default.options.replyToMessageId
(string | number)? The ID of the message to reply to.options.allowReply
boolean? Pass true to allow sending the message without a reply message. False by default.options.replyMarkup
(object | string)? Additional interface options for the message.options.threadId
(string | number)? The ID of the thread where the message will be sent.
- Throws TelegramApiError Throws an error if the request to the Telegram API fails.
Returns Promise<object> Returns a Promise that resolves to the sent message object on success.
Get a sticker set by its name.
name
string Name of the sticker set.
- Throws TelegramApiError Throws an error if the Telegram API returns an error.
Returns Promise<object> A Promise that returns an object representing the sticker set on success.
Returns a list of sticker sets containing custom emojis
- Throws TelegramApiError Throws an error if the API response contains an error code
Returns Promise<object> Returns an object representing the list of sticker sets containing custom emojis
Uploads a PNG image to create a new sticker file. The file must be less than 512 KB in size.
-
options
object An object containing the following parameters:
- Throws TelegramApiError If there is an error during the API request.
Returns Promise<object> The uploaded sticker file's information.
Creates a new sticker set with the specified options.
-
options
object The options object containing the following properties:options.userId
number The ID of the user who will create the sticker set.options.name
string The unique name of the sticker set, 1-64 characters.options.title
string The title of the sticker set, 1-64 characters.options.stickers
Array<object> An array of sticker objects containing the following properties:* {string} emoji - Emoji corresponding to the sticker.- {string} file - File path or URL of the sticker image.
options.stickerFormat
string The format of the stickers. Supported formats: "png", "webp", "tgs".options.stickerType
string The type of the stickers. Supported types: "static" for static stickers, "animated" for animated stickers.options.needsRepainting
boolean Whether the sticker set needs to be repainted. Defaults to false.
- Throws TelegramApiError If there is an error creating the sticker set.
Returns Promise<object> The created sticker set object.
Add a new sticker to a set created by the bot.
-
options
object The options to add a sticker to a set.-
options.userId
number The user id of the sticker set owner. -
options.name
string The name of the sticker set. -
options.sticker
object The sticker to add to the set.-
options.sticker.fileId
string The file id of the sticker. -
options.sticker.emoji
string The emoji associated with the sticker. -
options.sticker.maskPosition
object? The position where the mask should be placed on faces.options.sticker.maskPosition.point
string The part of the face where the mask should be placed.options.sticker.maskPosition.xShift
number The horizontal shift in pixels.options.sticker.maskPosition.yShift
number The vertical shift in pixels.options.sticker.maskPosition.scale
number The scale of the mask.
-
-
- Throws TelegramApiError If an error occurs while adding the sticker.
Returns Promise<object> On success, the added Sticker object is returned.
Set the position of a sticker in its set. Returns True on success.
-
options
object Options for setting the sticker position.
- Throws TelegramApiError If an error occurs while setting the sticker position.
Returns Promise<boolean> A Promise that resolves to true
on success.
Use this method to delete a sticker from a set created by the bot. Returns True on success.
sticker
string File identifier of the sticker to be deleted
- Throws TelegramApiError If there is an error returned by the Telegram API
Returns Promise<boolean> On success, True is returned
Set the emoji associated with a sticker.
options
- Throws TelegramApiError If there is an error returned from the Telegram API.
Returns Promise<object> On success, the updated sticker object is returned.
Set the keywords associated with a sticker.
-
options
object Options for setting sticker keywords.
- Throws TelegramApiError If an error occurs while setting sticker keywords.
Returns Promise<object> Result of the API call.
Sets the keywords for a sticker.
-
options
object The options object.
- Throws TelegramApiError If an error occurs while setting the sticker keywords.
Returns Promise<object> On success, the updated Sticker object is returned.
Sets the position of a sticker in the mask position for subsequent operation mask() calls.
-
options
object The options to set the sticker mask position.
- Throws TelegramApiError If an error occurs while setting the sticker mask position.
Returns Promise<object> On success, the edited sticker is returned.
Set the position of a sticker in a mask.
-
options
object The options for setting the sticker mask position
- Throws TelegramApiError If an error occurs while setting the sticker mask position.
Returns Promise<object> On success, the returned Promise will resolve with the updated Sticker object.
Sets the title of a sticker set.
-
options
object Options for setting the sticker set title.
- Throws TelegramApiError If the API call returns an error.
Returns Promise<object> On success, the updated sticker set is returned.
Set the thumbnail of a sticker set.
-
options
object Options object.
- Throws TelegramApiError If an error occurs while executing the method, an error with a description is thrown.
Returns Promise<object> On success, the updated sticker set is returned.
Set the thumbnail of a sticker set created with a custom emoji.
-
options
object The options to set the custom emoji sticker set thumbnail.
- Throws TelegramApiError When the Telegram API returns an error.
Returns Promise<object> The response from the Telegram API containing the result.
Use this method to delete a sticker set. Use the bot's username and the name of the sticker set.
name
string object containing the following required parameters
- Throws TelegramApiError When the request to the Telegram API fails or when the response contains an error.
Returns Promise<object> On success, returns True.
Answer an inline query.
-
options
object The options for answering the inline query.options.inlineQueryId
string Identifier of the inline query.options.results
Array<object> An array of results for the inline query.options.cacheTime
number The maximum amount of time in seconds that the result of the inline query may be cached. (optional, default300
)options.isPersonal
boolean Passtrue
, if the results of the inline query should be kept on the server side. (optional, defaultfalse
)options.nextOffset
string The offset that a client should send in the next query with the same text to receive more results. (optional, default''
)options.switchPmText
string? If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter.options.switchPmParameter
string? The parameter for the start message sent to the bot when user presses the switch button.
- Throws TelegramApiError If the Telegram API returns an error.
Returns Promise<object> A Promise that resolves to the result of the request.
Use this method to answer a callback query sent from a web app.
-
options
object An object containing the parameters for the method.options.queryId
string Unique identifier for the query to be answered.options.inlineQueryResult
any An array of results for the inline query.
- Throws TelegramApiError On error, an error object with an error code and description.
Returns Promise<object> On success, the method returns the updated message object.
Sends an invoice to the specified chat.
-
options
object Options for sending the invoice.options.chatId
number =this.chatId - Unique identifier for the target chat.options.messageThreadId
number Identifier of the message thread.options.title
string Product name for the invoice.options.description
string Product description for the invoice.options.payload
string Bot-defined invoice payload, 1-128 bytes.options.providerToken
string Payments provider token.options.currency
string Three-letter ISO 4217 currency code.options.prices
Array Array of price portions.options.maxTipAmount
number Maximum accepted amount for tips.options.suggestedTipAmounts
Array Suggested tip amounts.options.startParameter
string Bot-defined identifier for the invoice.options.providerData
string JSON-encoded data about the invoice, which will be shared with the payment provider.options.photoUrl
string URL of the product photo for the invoice.options.photoSize
number Size of the product photo for the invoice.options.photoWidth
number Width of the product photo for the invoice.options.photoHeight
number Height of the product photo for the invoice.options.needName
boolean Pass true if the customer's full name should be collected.options.needPhoneNumber
boolean Pass true if the customer's phone number should be collected.options.needEmail
boolean Pass true if the customer's email address should be collected.options.needShippingAddress
boolean Pass true if the customer's shipping address should be collected.options.sendPhoneNumberToProvider
boolean Pass true if the customer's phone number should be sent to the payment provider.options.sendEmailToProvider
boolean Pass true if the customer's email address should be sent to the payment provider.options.isFlexible
boolean Pass true if the final price depends on the shipping method.options.disableNotification
boolean Pass true if a notification for the invoice message should not be sent.options.protectContent
boolean Pass true if the invoice message content should be encrypted.options.replyToMessageId
number Identifier of the message to reply to.options.allowSendingWithoutReply
boolean Pass true if the message can be sent without a reply.options.replyMarkup
object Inline keyboard markup object.
- Throws TelegramApiError If there was an error sending the invoice.
Returns Promise<object> Result object containing information about the sent invoice.
Creates a payment invoice link for a Telegram bot user.
-
options
object The options for creating the payment link.options.title
string The title of the product or service being purchased.options.description
string The description of the product or service being purchased.options.payload
string A developer-defined payload, which will be included in the payment notification.options.providerToken
string The authentication token provided by the payment provider.options.currency
string The currency of the payment, in ISO 4217 format.options.prices
Array<object> An array of price components for the product or service being purchased.options.maxTipAmount
number The maximum tip amount allowed for the payment.options.suggestedTipAmounts
Array<number> An array of suggested tip amounts for the payment.options.providerData
string Additional data to pass to the payment provider, in JSON format.options.photoUrl
string The URL of a photo for the product or service being purchased.options.photoSize
number The size of the photo in bytes.options.photoWidth
number The width of the photo in pixels.options.photoHeight
number The height of the photo in pixels.options.needName
boolean Whether the user's name is needed for the payment.options.needPhoneNumber
boolean Whether the user's phone number is needed for the payment.options.needEmail
boolean Whether the user's email address is needed for the payment.options.needShippingAddress
boolean Whether the user's shipping address is needed for the payment.options.sendPhoneNumberToProvider
boolean Whether to send the user's phone number to the payment provider.options.sendEmailToProvider
boolean Whether to send the user's email address to the payment provider.options.isFlexible
boolean Whether the final payment amount can be changed by the user.
- Throws TelegramApiError If there was an error creating the invoice link.
Returns Promise<object> The response object, which contains the URL of the payment invoice link.
Sends a shipping query answer to the user.
-
options
object The options object.options.queryId
string The ID of the shipping query.options.isDeliveryPossible
boolean Specify true if delivery to the specified address is possible.options.shippingOptions
Array? List of available shipping options.options.errorMessage
string? Error message to display to the user if delivery to the specified address is not possible.
- Throws TelegramApiError Throws an error if the response contains an error code.
Returns Promise<object> Returns a Promise that resolves to the result object upon successful execution of the method.
Use this method to respond to such pre-checkout queries. On success, True is returned.
-
options
object An object containing the response parameters.options.preCheckoutQueryId
string Unique identifier for the query to be answered.options.ok
boolean Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Specify False if there are any problems.options.errorMessage
string? Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout.
- Throws TelegramApiError On Telegram API error.
Returns Promise<boolean> On success, True is returned.
Set errors in user Passport and revoke the verification of the data.
-
options
object The options to pass.-
options.userId
number Required. Unique identifier of the target user. -
options.errors
Array<object> Required. An array describing the errors.options.errors.source
string Required. The section of the user's Telegram Passport which has the error, one of "utility_bill", "bank_statement", "rental_agreement", "passport_registration", "temporary_registration".options.errors.type
string Required. Type of element of the Telegram Passport which has the error, one of "personal_details", "passport", "driver_license", "identity_card", "internal_passport", "address", "utility_bill", "bank_statement", "rental_agreement", "passport_registration", "temporary_registration".options.errors.message
string Required. Error message.
-
- Throws TelegramApiError If the response from the API contains an error code.
Returns Promise<object> On success, returns an object with the success status.
Sends a game to the chat.
-
options
object Options for sending the game.options.chatId
number =this.chatId - ID of the chat where the game should be sent.options.gameShortName
string Short name of the game to be sent.options.disableNotification
boolean Pass true to disable notification for the message. (optional, defaultfalse
)options.protectContent
boolean Pass true to protect the content of the message from screenshots. (optional, defaultfalse
)options.messageThreadId
number? Identifier of the message thread.options.replyToMessageId
number? Identifier of the message to reply to.options.allowSendingWithoutReply
boolean Pass true to allow sending the message without a reply. (optional, defaultfalse
)options.replyMarkup
(object | string)? Additional interface options for the message.
- Throws TelegramApiError If an error occurs while sending the game.
Returns Promise<object> A Promise that resolves to the sent game object on success.
Delete a message on Telegram.
-
options
object Options object.
- Throws TelegramApiError Throws an error if the API response contains an error_code.
Returns object Returns a Promise which will resolve to a message object if the message was deleted successfully.
Creates a new chat with the specified options.
-
options
object The options for creating the chat.
- Throws TelegramApiError Throws an error if the Telegram API returns an error.
Returns Promise<object> Returns a Promise that resolves to an object representing the created chat.
Retrieves the database object from the specified directory, table, and extension.
dir
string The directory where the storage is located.table
string The name of the table.extname
string The extension of the storage file.
Returns any The retrieved database object.
Sets the database object in the specified directory, table, and extension.
dir
string The directory where the storage is located.table
string The name of the table.db
any The database object to set.extname
string The extension of the storage file.
Class representing a simple storage.
options
Object The options for configuring the simple storage. (optional, default{}
)
Retrieves the value associated with the given key from the specified table.
table
string The name of the table.key
any The key to retrieve the value for.
- Throws ErrorTable Throws an error if the table name is invalid.
Returns any The value associated with the key.
Sets the value for the given key in the specified table.
table
string The name of the table.key
any The key to set the value for.value
any The value to set.
- Throws ErrorTable Throws an error if the table name is invalid.
Deletes the value associated with the given key from the specified table.
table
string The name of the table.key
any The key to delete.
- Throws ErrorTable Throws an error if the table name is invalid.
Checks if the specified table has a value associated with the given key.
table
string The name of the table.key
any The key to check.
- Throws ErrorTable Throws an error if the table name is invalid.
Returns boolean true
if the table has the key, false
otherwise.
Filters the values in the specified table based on the provided callback function.
- Throws ErrorTable Throws an error if the table name is invalid.
Returns object An object containing the filtered key-value pairs.
Retrieves all the key-value pairs from the specified table.
table
string The name of the table.
- Throws ErrorTable Throws an error if the table name is invalid.
Returns object An object containing all the key-value pairs.
Types of sessions.
Type: string
Simple session type.
Auto session type.
Time session type.
Extends EventEmitter
Represents a request object for making requests to the Telegram Bot API.
token
string? The API token for the bot.intents
(string | array | number)? The types of updates the bot is interested in.queryString
string? The type of query string to use for requests.offSetType
(string | boolean | object)? The type of offset to use for updates.parseMode
Gets the updates from the Telegram Bot API.
- Throws TelegramTokenError When the token is invalid.
- Throws TelegramApiError When an error occurs with the Telegram Bot API.
Returns Promise<Array<object>> An array of updates.
Makes a request to the Telegram Bot API.
Returns Promise<object> The response from the API call.
Gets the uptime of the bot.
Returns number The uptime in milliseconds.
Gets the ping latency of the bot.
Returns Promise<number> The ping latency in milliseconds.
Gets the last update ID received.
Returns (number | null) The last update ID, or null if not available.
Gets the last object received.
Returns object The last received object.
Set the token for the bot.
token
string The token to set.
Returns boolean Returns true if the token was set successfully.
Set the intents for the bot.
Returns boolean Returns true if the intents were set successfully.
Set the parse mode for the bot.
parseMode
string The parse mode to set.
Returns boolean Returns true if the parse mode was set successfully.
Set the chat ID for the bot.
Returns (string | number) Returns the chat ID that was set.
Set the query string for the bot.
queryString
string The query string to set.
Returns boolean Returns true if the query string was set successfully.
Set the offset type for the bot.
offSetType
string The offset type to set.
Returns string Returns the offset type that was set.
Class representing a markup in the Telegram Bot API.
options
Object Button settings. (optional, default{}
)
Sets the markup action type.
type
string Button action type.
Returns Markup Returns an instance of the Markup object for method chaining.
Sets the markup action.
action
string Button action to be passed to the event handler.
Returns Markup Returns an instance of the Markup object for method chaining.
Sets the text on the markup.
text
string Text on the markup.
Returns Markup Returns an instance of the Markup object for method chaining.
Sets the URL for the web app.
Returns Markup Returns the current object instance for chaining.
Sets the force_reply
option for the reply keyboard.
forceReply
boolean Indicates whether to enable the force reply feature.
Returns Markup Returns the modified instance of the object.
Returns the markup object in the format expected by Telegram Bot API.
Returns object Returns the markup object in the format expected by Telegram Bot API.
Returns the text representation of the markup object in the format expected by Telegram Bot API.
Returns string Returns the text representation of the markup object in the format expected by Telegram Bot API.
Set the remove_keyboard
option to remove the keyboard after the user presses a markup.
remove
boolean Whether the keyboard should be removed after the user presses a markup. (optional, defaultfalse
)
Returns string Returns a JSON string with the remove_keyboard
option set to true
.
Creates a new Button object from a markup object in the format expected by Telegram Bot API.
markupObj
object Button object in the format expected by Telegram Bot API.
Returns Markup Returns an instance of the Markup object.
Returns the inline keyboard object in the format expected by Telegram Bot API.
markups
Array A 2-dimensional array of Markup objects representing the markups on the keyboard.
Returns object Returns the inline keyboard object in the format expected by Telegram Bot API.
Generates a JSON string representing a reply markup object with an inline keyboard.
arrayMarkup
Array An array containing elements of the markup.arrayLength
number The desired length of the markup array. Defaults to 10. (optional, default10
)
Returns string Returns a JSON string representing the reply markup object.
Creates a new Keyboard object.
-
markups
Array A 2-dimensional array of Button objects representing the markups on the keyboard. -
options
Object Additional options for the keyboard. (optional, default{}
)options.inline
boolean Whether the keyboard is an inline keyboard. (optional, defaultfalse
)options.resize
boolean Whether the keyboard should be resized to fit the user's screen. (optional, defaultfalse
)options.oneTime
boolean Whether the keyboard should disappear after the user presses a markup. (optional, defaultfalse
)options.selective
boolean Whether the keyboard should be shown only to specific users. (optional, defaultfalse
)
Returns the keyboard object in the format expected by Telegram Bot API.
Returns object Returns the keyboard object in the format expected by Telegram Bot API.
Sets the inline option of the keyboard.
inline
boolean Whether the keyboard should be displayed inline with the message.
Returns Keyboard Returns the updated Keyboard object.
Sets the resize
option for the keyboard.
resize
boolean Whether the keyboard should be resized to fit the user's screen.
Returns Keyboard Returns the current Keyboard
object for chaining.
Sets whether the keyboard should disappear after the user presses a markup.
oneTime
boolean Whether the keyboard should disappear after the user presses a markup.
Returns Keyboard Returns the Keyboard object.
Set the selective
option for the keyboard.
selective
boolean Whether the keyboard should be shown only to specific users.
Returns Keyboard Returns the Keyboard
object with the selective
option set.
Adds markups to the keyboard markups array.
markupRows
...any One or more markup rows to add to the keyboard.defaults
boolean Specifies whether to use default values for the markups. (optional, defaultfalse
)
Returns Keyboard Returns the updated Keyboard
object.
Extends EventEmitter
Represents a message collector.
options
Object The options for the collector.
Handles a new message received by the collector.
message
Object The message object.
Returns the collected messages.
Returns Array The collected messages.
Returns the count of collected messages.
Returns number The count of collected messages.
Clears the collected messages.
Returns boolean true
if the collected messages are cleared successfully, false
otherwise.
Sets a new filter function for the collector.
filter
Function The new filter function.
Returns boolean true
if the filter function is set successfully, false
otherwise.
Sets a new duration for the collector to run.
time
number The new duration in milliseconds.
Returns boolean true
if the duration is set successfully, false
otherwise.
Sets a new maximum number of messages to collect.
max
number The new maximum number of messages.
Returns boolean true
if the maximum number is set successfully, false
otherwise.
Returns whether the collector is currently running.
Returns boolean true
if the collector is running, false
otherwise.
Stops the message collector.
Events object with predefined event types.
Type: Object
Message
string Represents the 'message' event.EditedMessage
string Represents the 'edited_message' event.ChannelPost
string Represents the 'channel_post' event.EditedChannelPost
string Represents the 'edited_channel_post' event.InlineQuery
string Represents the 'inline_query' event.ChosenInlineResult
string Represents the 'chosen_inline_result' event.CallbackQuery
string Represents the 'callback_query' event.ShippingQuery
string Represents the 'shipping_query' event.PreCheckoutQuery
string Represents the 'pre_checkout_query' event.Poll
string Represents the 'poll' event.PollAnswer
string Represents the 'poll_answer' event.ChatMember
string Represents the 'chat_member' event.MyChatMember
string Represents the 'my_chat_member' event.ChatJoinRequest
string Represents the 'chat_join_request' event.ReplyMessage
string Represents the 'reply_message' event.
An object representing the available chat action types.
Type: object
Typing
string Represents a typing action.UploadPhoto
string Represents an action for uploading a photo.RecordVideo
string Represents an action for recording a video.UploadVideo
string Represents an action for uploading a video.RecordVoice
string Represents an action for recording a voice message.UploadVoice
string Represents an action for uploading a voice message.UploadDocument
string Represents an action for uploading a document.ChooseSticker
string Represents an action for choosing a sticker.FindLocation
string Represents an action for finding a location.RecordVideoNote
string Represents an action for recording a video note.UploadVideoNote
string Represents an action for uploading a video note.
Object representing types of Telegram message entities.
Type: string
Mention
string A@username
mention.Hashtag
string A#hashtag
mention.Cashtag
string A$cashtag
mention.BotCommand
string A bot command mention.URL
string A URL link.Email
string An email link.PhoneNumber
string A phone number link.Bold
string Bold text.Italic
string Italic text.Underline
string Underlined text.Strikethrough
string Strikethrough text.Spoiler
string Spoiler text.Code
string Monospace code text.Pre
string Preformatted code block.TextLink
string A clickable text URL link.TextMention
string A mention of a user by their username.CustomEmoji
string A custom emoji.
An object containing chat permissions.
Type: Object
CanSendOtherMessages
string Specifies if users can send other kinds of messages.CanAddWebPagePreviews
string Specifies if users can add web page previews to their messages.CanSendMessages
string Specifies if users can send text messages.CanSendAudios
string Specifies if users can send audio messages.CanSendDocuments
string Specifies if users can send document messages.CanSendPhotos
string Specifies if users can send photo messages.CanSendVideos
string Specifies if users can send video messages.CanSendVideoNotes
string Specifies if users can send video note messages.CanSendVoiceNotes
string Specifies if users can send voice note messages.CanSendPolls
string Specifies if users can send polls.
An object containing group permissions.
Type: Object
CanManageChat
string Specifies if users can manage the group.CanChangeInfo
string Specifies if users can change group information.CanDeleteMessages
string Specifies if users can delete messages.CanInviteUsers
string Specifies if users can invite other users to the group.CanRestrictMembers
string Specifies if users can restrict group members.CanPinMessages
string Specifies if users can pin messages.CanManageTopics
string Specifies if users can manage group topics.CanPromoteMembers
string Specifies if users can promote members.CanManageVideoChats
string Specifies if users can manage video groups.CanManageVoiceChats
string Specifies if users can manage voice groups.
Enum representing the status of a group member.
Type: string
The user is an administrator of the group.
The user has left the group.
The user is a regular member of the group.
The user is the creator of the group.
Constants for document types.
Type: string
PersonalDetails
string Personal details.Passport
string Passport.DriverLicense
string Driver's license.IdentityCard
string Identity card.InternalPassport
string Internal passport.Address
string Address.UtilityBill
string Utility bill.BankStatement
string Bank statement.RentalAgreement
string Rental agreement.PassportRegistration
string Passport registration.TemporaryRegistration
string Temporary registration.PhoneNumber
string Phone number.Email
string Email.
Adds one or more bits to the bit field.
ints
...number The bits to add to the bit field.
- Throws BitFieldError If a specified bit is not a number.
Returns IntentsBitField The updated IntentsBitField instance.
Removes one or more Telegram intents from the bitfield.
ints
...number The bits that represent the Telegram intents to be removed.
- Throws BitFieldError If an invalid argument is passed.
Returns IntentsBitField The IntentsBitField instance.
Returns the bitfield as a number.
Returns number The bitfield.
Returns an array of intent strings based on the current bit value
Returns Array<string> Array of intent strings
Checks if the bit field has a specific bit set
bit
number Bit to check
Returns boolean True if the bit is set, false otherwise
Decodes a bit field instance and returns an array of intent strings
intentsBitField
IntentsBitField Bit field instance to decode
Returns Array<string> Array of intent strings
Type: Object
Message
number Represents a bit flag for Telegram messages.EditedMessage
number Represents a bit flag for edited Telegram messages.ChannelPost
number Represents a bit flag for posts in Telegram channels.EditedChannelPost
number Represents a bit flag for edited posts in Telegram channels.InlineQuery
number Represents a bit flag for inline queries from users.ChosenInlineResult
number Represents a bit flag for chosen inline query results.CallbackQuery
number Represents a bit flag for callback queries from users.ShippingQuery
number Represents a bit flag for shipping queries from users.PreCheckoutQuery
number Represents a bit flag for pre-checkout queries from users.Poll
number Represents a bit flag for polls from users.PollAnswer
number Represents a bit flag for answers to polls from users.MyChatMember
number Represents a bit flag for a user's chat membership status in their own chat.ChatMember
number Represents a bit flag for a user's chat membership status in a chat they are a member of.ChatJoinRequest
number Represents a bit flag for a user's request to join a chat.
Type: Object
Message
string Represents a Telegram message.EditedMessage
string Represents an edited Telegram message.ChannelPost
string Represents a post in a Telegram channel.EditedChannelPost
string Represents an edited post in a Telegram channel.InlineQuery
string Represents an inline query from a user.ChosenInlineResult
string Represents a chosen inline query result.CallbackQuery
string Represents a callback query from a user.ShippingQuery
string Represents a shipping query from a user.PreCheckoutQuery
string Represents a pre-checkout query from a user.Poll
string Represents a poll from a user.PollAnswer
string Represents an answer to a poll from a user.MyChatMember
string Represents a user's chat membership status in their own chat.ChatMember
string Represents a user's chat membership status in a chat they are a member of.ChatJoinRequest
string Represents a user's request to join a chat.
Checks if a message contains any links.
message
string The message to check.
Returns boolean Returns true if the message contains links, otherwise false.
Extracts user mentions from a message.
message
string The message to extract mentions from.
Returns Array<string> An array of user mentions found in the message.
Extracts hashtags from a message.
message
string The message to extract hashtags from.
Returns Array<string> An array of hashtags found in the message.
Checks if a location object is valid.
-
location
object The location object to check.
Returns boolean Returns true if the location object is valid, otherwise false.
Checks if a message contains any user mentions.
message
string The message to check.
Returns boolean Returns true if the message contains user mentions, otherwise false.
Checks if a message contains any hashtags.
message
string The message to check.
Returns boolean Returns true if the message contains hashtags, otherwise false.
Checks if a phone number is valid.
phoneNumber
string The phone number to check.
Returns boolean Returns true if the phone number is valid, otherwise false.
Extracts the user ID from a Telegram link.
link
string The Telegram link to extract the user ID from.
Returns (string | null) The extracted user ID, or null if not found.
Checks if a message contains a Telegram group or channel link.
message
string The message to check.
Returns boolean Returns true if the message contains a group or channel link, otherwise false.
Checks if a message contains only emoji characters.
message
string The message to check.
Returns boolean Returns true if the message contains only emoji characters, otherwise false.
Checks if a message contains only a Telegram sticker.
message
string The message to check.
Returns boolean Returns true if the message contains only a Telegram sticker, otherwise false.
Extracts the username from a Telegram link.
link
string The Telegram link to extract the username from.
Returns (string | null) The extracted username, or null if not found.
Checks if a message contains a Telegram bot username.
message
string The message to check.
Returns boolean Returns true if the message contains a Telegram bot username, otherwise false.
Checks if a message contains a Telegram channel link (excluding usernames).
message
string The message to check.
Returns boolean Returns true if the message contains a Telegram channel link, otherwise false.
Checks if a message contains a Telegram link.
message
string The message to check.
Returns boolean Returns true if the message contains a Telegram link, otherwise false.
Checks if a message contains a Telegram group link.
message
string The message to check.
Returns boolean Returns true if the message contains a Telegram group link, otherwise false.
Checks if a username is valid.
username
string The username to check.
Returns boolean Returns true if the username is valid, otherwise false.
Extracts the username from a Telegram link.
link
string The Telegram link to extract the username from.
Returns (string | null) The extracted username, or null if not found.