Get Messages

Get Messages

File: src/Methods/Messages/GetMessages.ts
Schema: channels.GetMessages & messages.GetMessages

Get one or more messages from a chat by using message identifiers.

Usage

client.api.getMessages(chatId, messageIds, replyToMessageIds, replies);
namerequiredtypedescription
chatIdtruebigint or stringUnique identifier or username of the target chat.
messageIdstruearray of numberMessage identifier to get the content of the message. You can pass with undefined if you want to use replyToMessageIds parameter.
replyToMessageIdstruearray of numberMessage identifier to get the content of the previous message which is replied by current messages. You can pass with undefined if you want to use messageIds parameter.
repliestruenumberThe number of subsequent replies to get for each message. Pass 0 for no reply at all or -1 for unlimited replies. Defaults to 1.

You cannot use the messageIds parameter at the same time as replyToMessageIds, if the messageIds parameter is available then we will prioritize using the messageIds parameter over replyToMessageIds.

Possible Error

CodeMessageDescription
400CHANNEL_INVALIDThe provided channel is invalid.
400CHANNEL_PRIVATEYou haven't joined this channel/supergroup.
400MESSAGE_IDS_EMPTYNo message ids were provided.
400MSG_ID_INVALIDInvalid message ID provided.
400USER_BANNED_IN_CHANNELYou're banned from sending messages in supergroups/channels.
406CHANNEL_PRIVATEYou haven't joined this channel/supergroup.

Bots can use