Skip to main content

channels.editAdmin

Modify the admin rights of a user in a supergroup/channel.

func (c *Client) ChannelsEditAdmin(ctx context.Context, request *ChannelsEditAdminRequest) (UpdatesClass, error)

Calling this method

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

res, err := api.ChannelsEditAdmin(ctx, &tg.ChannelsEditAdminRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // UpdatesClass
return nil
})

Parameters

NameTypeRequiredDescription
ChannelInputChannelClassyesThe supergroup/channel.
UserIDInputUserClassyesThe ID of the user whose admin rights should be modified
AdminRightsChatAdminRightsyesThe admin rights
RankstringIndicates the role (rank) of the admin in the group: just an arbitrary string. If the flag is not set, the rank is left unchanged.

Returns

UpdatesClass

Possible errors

CodeTypeDescription
400ADMINS_TOO_MUCHThere are too many admins.
400ADMIN_RANK_EMOJI_NOT_ALLOWEDAn admin rank cannot contain emojis.
400ADMIN_RANK_INVALIDThe specified admin rank is invalid.
400BOTS_TOO_MUCHThere are too many bots in this chat/channel.
400BOT_CHANNELS_NABots can't edit admin privileges.
400BOT_GROUPS_BLOCKEDThis bot can't be added to groups.
400CHANNEL_INVALIDThe provided channel is invalid.
400CHANNEL_MONOFORUM_UNSUPPORTEDMonoforums do not support this feature.
400CHANNEL_PRIVATEYou haven't joined this channel/supergroup.
403CHAT_ADMIN_INVITE_REQUIREDYou do not have the rights to do this.
403CHAT_ADMIN_REQUIREDYou must be an admin in this chat to do this.
403CHAT_WRITE_FORBIDDENYou can't write in this chat.
406FRESH_CHANGE_ADMINS_FORBIDDENYou were just elected admin, you can't add or modify other admins yet.
400INPUT_USER_DEACTIVATEDThe specified user was deleted.
400MSG_ID_INVALIDInvalid message ID provided.
400PEER_ID_INVALIDThe provided peer id is invalid.
403RIGHT_FORBIDDENYour admin rights do not allow you to do this.
400USERS_TOO_MUCHThe maximum number of users has been exceeded (to create a chat, for example).
400USER_BLOCKEDUser blocked.
403USER_CHANNELS_TOO_MUCHOne of the users you tried to add is already in too many channels/supergroups.
400USER_CREATORFor channels.editAdmin: you've tried to edit the admin rights of the owner, but you're not the owner; for channels.leaveChannel: you can't leave this channel, because you're its creator.
400USER_ID_INVALIDThe provided user ID is invalid.
400USER_KICKEDThis user was kicked from this supergroup/channel.
403USER_NOT_MUTUAL_CONTACTThe provided user is not a mutual contact.
403USER_PRIVACY_RESTRICTEDThe user's privacy settings do not allow you to do this.
403USER_RESTRICTEDYou're spamreported, you can't create channels or chats.

References