GramJS

channels.GetAdminedPublicChannels

Get channels/supergroups/geogroups we're admin in. Usually called when the user exceeds the limit for owned public channels/supergroups/geogroups, and the user is given the choice to remove one of his channels/supergroups/geogroups.

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.GetAdminedPublicChannels({
      byLocation: true,
      checkLimit: 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.messages.Chats = await client.invoke(
    new Api.channels.GetAdminedPublicChannels({
      byLocation: true,
      checkLimit: true,
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
flags#Flags, see TL conditional fields
byLocationflags.0?trueGet geogroups
checkLimitflags.1?trueIf set and the user has reached the limit of owned public channels/supergroups/geogroups, instead of returning the channel list one of the specified errors will be returned.Useful to check if a new public channel can indeed be created, even before asking the user to enter a channel username to use in channels.checkUsername/channels.updateUsername.

Result

messages.Chats

Possible errors

CodeTypeDescription
400CHANNELS_ADMIN_LOCATED_TOO_MUCHThe user has reached the limit of public geogroups.
400CHANNELS_ADMIN_PUBLIC_TOO_MUCHYou're admin of too many public channels, make some channels private to change the username of this channel.

Can bots use this method?

No

Channels, supergroups, gigagroups and basic groups

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

channels.checkUsername

Check if a username is free and can be assigned to a channel/supergroup

channels.updateUsername

Change the username of a supergroup/channel

config

Current configuration