Actions¶
Delete, pin, react, forward, copy, and send chat actions on the current message or chat. Side effects without sending a new message.
Delete¶
delete(messageId?) — alias: del, remove¶
Delete a message in the current chat. Defaults to the current message.
await msg.delete() // delete the message that triggered the command
await msg.delete(msg.message_id) // same — explicit id
await msg.del(otherMessageId) // delete a different message in this chat
Reactions¶
react(emoji, isBig?) — alias: reaction¶
Add an emoji reaction to the current message:
| Param | Default | Description |
|---|---|---|
emoji | required | Single emoji string |
isBig | false | Show large reaction animation |
removeReaction(options?) — alias: unreact¶
Remove the bot's reaction from the current message:
Pin and unpin¶
pin(disableNotification?)¶
Pin the current message in the chat:
Requires bot admin rights with can_pin_messages in groups.
unpin(messageId?)¶
Unpin a message. Defaults to the current message:
Forward and copy¶
forward(toChatId, options?) — alias: fwd¶
Forward the current message to another chat:
copy(toChatId, options?) — alias: cp¶
Copy (send without forward header) to another chat:
| Param | Description |
|---|---|
toChatId | Destination chat ID or @username |
options | Extra forwardMessage / copyMessage params |
Chat actions¶
sendChatAction(action, options?) — alias: action, typing¶
Show a status indicator in the chat:
| Action | Shows |
|---|---|
typing | Typing… |
upload_photo | Sending photo… |
record_video | Recording video… |
upload_video | Sending video… |
record_voice | Recording voice… |
upload_voice | Sending voice… |
upload_document | Sending file… |
choose_sticker | Choosing sticker… |
find_location | Finding location… |
record_video_note | Recording video note… |
upload_video_note | Sending video note… |
Chat actions expire after ~5 seconds. Send again for longer operations.
Business messages¶
read(options?) — alias: markRead, markAsRead¶
Mark the current business message as read. Only works when msg.isBusiness() is true.
Throws read is only available for business messages on normal messages.
Method reference¶
| Method | Alias | Telegram API |
|---|---|---|
delete(id?) | del, remove | deleteMessage |
react(emoji, big?) | reaction | setMessageReaction |
removeReaction(opts?) | unreact | deleteMessageReaction |
pin(silent?) | — | pinChatMessage |
unpin(id?) | — | unpinChatMessage |
forward(chatId, opts?) | fwd | forwardMessage |
copy(chatId, opts?) | cp | copyMessage |
sendChatAction(action, opts?) | typing, action | sendChatAction |
read(opts?) | markRead | readBusinessMessage |
Try it — copy-paste examples¶
Self-destructing command response¶
let notice = await msg.reply("Processing...")
// ... do work ...
await notice.delete()
await msg.reply("Done!")
Forward user message to admin¶
let adminId = process.env.ADMIN_CHAT_ID
await msg.forward(adminId)
await msg.reply("Reported to admin.")
React to confirm¶
Typing indicator during slow work¶
await msg.sendChatAction("typing")
let result = await HTTP.get("https://api.example.com/data")
await msg.reply("Result: " + result.data.value)
Notes¶
delete()can remove the triggering message or any message in the same chat (with permission)- Reactions require Telegram Premium in some private chat contexts
forwardshows "Forwarded from" header;copydoes not- Rate limit: 10 msg method calls per second
- For actions on messages sent via
Api, use method chaining on the returned object