messages.deleteMessages

Deletes messages by their identifiers.

Example

const {Api, TelegramClient} = require('telegram');
const {StringSession} = require('telegram/sessions');

const session = new StringSession('');
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
    const result = await client.invoke(new Api.messages.deleteMessages({
        revoke: true,
        id: [7969713],
        }));
    console.log(result); // prints the result
})();

TL schema

messages.affectedMessages#84d19185 pts:int pts_count:int = messages.AffectedMessages;
---functions---
messages.deleteMessages#e58e95d2 flags:# revoke:flags.0?true id:Vector<int> = messages.AffectedMessages;

Parameters

Name

Type

Description

revoke

Whether to delete messages for all participants of the chat

Result

The method returns the list of successfully deleted messages in Vectorarrow-up-right[int](https://core.telegram.org/type/int)arrow-up-right.

Possible errors

Code

Type

Description

403

MESSAGE_DELETE_FORBIDDEN

You can't delete one of the messages you tried to delete, most likely because it is a service message.

Can bots use this methd ?

yes

Last updated