getMyDefaultAdministratorRights
Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
Parameters
for_channelsBooleanOptionalPass True to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned.
Returns
On success, the ChatAdministratorRights object is returned.
GramIO Usage
ts
// Get default admin rights for groups and supergroups
const groupRights = await bot.api.getMyDefaultAdministratorRights({});
console.log(`Can delete messages: ${groupRights.can_delete_messages}`);
console.log(`Can restrict members: ${groupRights.can_restrict_members}`);
console.log(`Can manage video chats: ${groupRights.can_manage_video_chats}`);ts
// Get default admin rights for channels
const channelRights = await bot.api.getMyDefaultAdministratorRights({
for_channels: true,
});
console.log(`Can post messages: ${channelRights.can_post_messages}`);
console.log(`Can edit messages: ${channelRights.can_edit_messages}`);
console.log(`Can delete messages: ${channelRights.can_delete_messages}`);ts
// Read and compare rights for both contexts
const [groupRights, channelRights] = await Promise.all([
bot.api.getMyDefaultAdministratorRights({}),
bot.api.getMyDefaultAdministratorRights({ for_channels: true }),
]);
console.log("Group rights: ", groupRights);
console.log("Channel rights:", channelRights);ts
// Verify required rights are configured before starting
const rights = await bot.api.getMyDefaultAdministratorRights({});
if (!rights.can_delete_messages) {
console.warn(
"Warning: bot does not have can_delete_messages by default. " +
"Call setMyDefaultAdministratorRights to update."
);
}Errors
| Code | Error | Cause |
|---|---|---|
| 429 | Too Many Requests: retry after N | Rate limit hit — check retry_after, use the auto-retry plugin |
Tips & Gotchas
for_channelsselects the context. Passtrueto read channel rights; omit it (or passfalse) to read group/supergroup rights. The two are configured independently viasetMyDefaultAdministratorRights.- Default rights apply when the bot is promoted without explicit rights. If an admin promotes the bot without specifying individual permissions, Telegram uses these defaults. Setting good defaults avoids needing to re-configure every group manually.
- Channel-only fields are only meaningful when
for_channels: true. Fields likecan_post_messagesandcan_edit_messagesare channel-specific and will be absent orfalsein the group rights response. - These are defaults, not actual rights in any specific chat. To check what rights the bot has in a particular chat, use
getChatMemberon the bot's ownuser_idin that chat. - Rights changes require re-promotion. Changing defaults with
setMyDefaultAdministratorRightsdoes not retroactively update the bot's permissions in existing chats — existing admin promotions are unaffected.
See Also
- ChatAdministratorRights — return type with all permission fields
- setMyDefaultAdministratorRights — update the bot's default admin rights
- getMe — get the bot's identity and capability flags
- getChatMember — check actual rights in a specific chat
- getChatAdministrators — list all admins in a chat