Skip to main content

messages.deleteMessages

Deletes messages by their identifiers.

func (c *Client) MessagesDeleteMessages(ctx context.Context, request *MessagesDeleteMessagesRequest) (*MessagesAffectedMessages, error)

Calling this method

client.Run(ctx, func(ctx context.Context) error {
api := client.API()

res, err := api.MessagesDeleteMessages(ctx, &tg.MessagesDeleteMessagesRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // *MessagesAffectedMessages
return nil
})

Parameters

NameTypeRequiredDescription
RevokeboolWhether to delete messages for all participants of the chat
ID[]intyesMessage ID list

Returns

*MessagesAffectedMessages

Possible errors

CodeTypeDescription
403BOT_ACCESS_FORBIDDENThe specified method can be used over a business connection for some operations, but the specified query attempted an operation that is not allowed over a business connection.
400BUSINESS_CONNECTION_INVALIDThe connection_id passed to the wrapping invokeWithBusinessConnection call is invalid.
403MESSAGE_DELETE_FORBIDDENYou can't delete one of the messages you tried to delete, most likely because it is a service message.
400MESSAGE_ID_INVALIDThe provided message id is invalid.
400SELF_DELETE_RESTRICTEDBusiness bots can't delete messages just for the user, revoke must be set.

References