GramJS

channels.GetAdminLog

Get the admin log of a channel/supergroup

Example

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

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result = await client.invoke(
    new Api.channels.GetAdminLog({
      channel: "username",
      q: "some string here",
      maxId: 0,
      minId: 0,
      limit: 100,
      eventsFilter: new Api.ChannelAdminLogEventsFilter({
        join: true,
        leave: true,
        invite: true,
        ban: true,
        unban: true,
        kick: true,
        unkick: true,
        promote: true,
        demote: true,
        info: true,
        settings: true,
        pinned: true,
        groupCall: true,
        invites: true,
      }),
    })
  );
  console.log(result); // prints the result
})();
import { Api, TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result: Api.channels.AdminLogResults = await client.invoke(
    new Api.channels.GetAdminLog({
      channel: "username",
      q: "some string here",
      maxId: 0,
      minId: 0,
      limit: 100,
      eventsFilter: new Api.ChannelAdminLogEventsFilter({
        join: true,
        leave: true,
        invite: true,
        ban: true,
        unban: true,
        kick: true,
        unkick: true,
        promote: true,
        demote: true,
        info: true,
        settings: true,
        pinned: true,
        groupCall: true,
        invites: true,
      }),
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
flags#Flags, see TL conditional fields
channelInputChannelChannel
qstringSearch query, can be empty
eventsFilterflags.0?ChannelAdminLogEventsFilterEvent filter
adminsflags.1?Vector<InputUser>Only show events from these admins
maxIdlongMaximum ID of message to return (see pagination)
minIdlongMinimum ID of message to return (see pagination)
limitintMaximum number of results to return, see pagination

Result

channels.AdminLogResults

Possible errors

CodeTypeDescription
400CHANNEL_INVALIDThe provided channel is invalid
400CHANNEL_PRIVATEYou haven't joined this channel/supergroup
400CHAT_ADMIN_REQUIREDYou must be an admin in this chat to do this
403CHAT_WRITE_FORBIDDENYou can't write in this chat
400MSG_ID_INVALIDInvalid message ID provided

Can bots use this method?

No

Pagination in the API

How to fetch results from large lists of objects.

Channels

How to handle channels, supergroups, groups, and what's the difference between them.