EditAdminRequest

Both users and bots can use this request. See code examples.

---functions---
channels.editAdmin#d33c8902 channel:InputChannel user_id:InputUser admin_rights:ChatAdminRights rank:string = Updates

Returns

Updates

This type can be an instance of either:

UpdateShortUpdateShortChatMessage
UpdateShortMessageUpdateShortSentMessage
UpdatesUpdatesCombined
UpdatesTooLong

Parameters

channelInputChannelAnything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.).
user_idInputUserAnything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.).
admin_rightsChatAdminRights
rankstring

Known RPC errors

This request can cause 13 known errors:

AdminsTooMuchErrorToo many admins.
AdminRankEmojiNotAllowedErrorEmoji are not allowed in admin titles or ranks.
AdminRankInvalidErrorThe given admin title or rank was invalid (possibly larger than 16 characters).
BotChannelsNaErrorBots can't edit admin privileges.
ChannelInvalidErrorInvalid channel object. Make sure to pass the right types, for instance making sure that the request is designed for channels or otherwise look for a different one more suited.
ChatAdminInviteRequiredErrorYou do not have the rights to do this.
ChatAdminRequiredErrorChat admin privileges are required to do that in the specified chat (for example, to send a message in a channel which is not yours), or invalid permissions used for the channel or group.
FreshChangeAdminsForbiddenErrorRecently logged-in users cannot add or change admins.
RightForbiddenErrorEither your admin rights do not allow you to do this or you passed the wrong rights combination (some rights only apply to channels and vice versa).
UserCreatorErrorYou can't leave this channel, because you're its creator.
UserIdInvalidErrorInvalid object ID for a user. Make sure to pass the right types, for instance making sure that the request is designed for users or otherwise look for a different one more suited.
UserNotMutualContactErrorThe provided user is not a mutual contact.
UserPrivacyRestrictedErrorThe user's privacy settings do not allow you to do this.

You can import these from telethon.errors.

Example

Please refer to the documentation of client.edit_admin() to learn about the parameters and see several code examples on how to use it.

The method above is the recommended way to do it. If you need more control over the parameters or want to learn how it is implemented, open the details by clicking on the "Details" text.

from telethon.sync import TelegramClient
from telethon import functions, types

with TelegramClient(name, api_id, api_hash) as client:
    result = client(functions.channels.EditAdminRequest(
        channel='username',
        user_id='username',
        admin_rights=types.ChatAdminRights(
            change_info=True,
            post_messages=True,
            edit_messages=True,
            delete_messages=True,
            ban_users=True,
            invite_users=True,
            pin_messages=True,
            add_admins=True,
            anonymous=True,
            manage_call=True,
            other=True,
            manage_topics=True,
            post_stories=True,
            edit_stories=True,
            delete_stories=True
        ),
        rank='some string here'
    ))
    print(result.stringify())