telegramx.js

Message

class

extends Base<T.Message>

A message in a chat.

Declaration

declare class Message extends Base<T.Message> 

Properties

authorproperty#
get author(): User | undefined;

The sender, for messages sent by a user.

captionproperty#
get caption(): string | undefined;

The caption, for media messages.

chatproperty#
get chat(): Chat;

The chat the message belongs to.

createdAtproperty#
get createdAt(): Date;

Date the message was sent, as a Date.

idproperty#
get id(): number;

Unique message identifier inside its chat.

get replyToMessage(): Message | undefined;

The message this message replies to, if any.

textproperty#
get text(): string | undefined;

The message text, if this is a text message.

Methods

copymethod#
copy(chatId: number | string, options?: Without<CopyMessageParams, 'from_chat_id' | 'message_id'>): Promise<T.MessageId>;
ParameterType
chatIdnumber | string
options?Without<CopyMessageParams, 'from_chat_id' | 'message_id'>
Returns Promise<T.MessageId>

Copy this message to another chat (sent as a new message, not a forward).

deletemethod#
delete(): Promise<boolean>;
Returns Promise<boolean>

Delete this message.

editmethod#
edit(text: string, options?: Without<EditMessageTextParams, 'text' | 'message_id'>): Promise<Message | boolean>;
ParameterType
textstring
options?Without<EditMessageTextParams, 'text' | 'message_id'>
Returns Promise<Message | boolean>

Edit the text of this message (must be a message the bot sent).

forwardmethod#
forward(chatId: number | string, options?: Without<ForwardMessageParams, 'from_chat_id' | 'message_id'>): Promise<Message>;
ParameterType
chatIdnumber | string
options?Without<ForwardMessageParams, 'from_chat_id' | 'message_id'>
Returns Promise<Message>

Forward this message to another chat.

pinmethod#
pin(): Promise<boolean>;
Returns Promise<boolean>

Pin this message in its chat.

reactmethod#
react(reaction: string | T.ReactionType[]): Promise<boolean>;
ParameterType
reactionstring | T.ReactionType[]
Returns Promise<boolean>

Set the bot's reaction to this message (pass a single emoji, or an array of reactions).

replymethod#
reply(text: string, options?: Without<SendMessageParams, 'text'>): Promise<Message>;
ParameterType
textstring
options?Without<SendMessageParams, 'text'>
Returns Promise<Message>

Reply to this message in the same chat.

unpinmethod#
unpin(): Promise<boolean>;
Returns Promise<boolean>

Unpin this message.