From ce49fc38a05c193144a02c43cffa880f30ed7c70 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Fri, 6 May 2022 22:00:20 +0200 Subject: [PATCH] Fix promote_chat_member when adding bots as admins --- pyrogram/methods/chats/promote_chat_member.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pyrogram/methods/chats/promote_chat_member.py b/pyrogram/methods/chats/promote_chat_member.py index f8a2779b..46ffe446 100644 --- a/pyrogram/methods/chats/promote_chat_member.py +++ b/pyrogram/methods/chats/promote_chat_member.py @@ -19,7 +19,7 @@ from typing import Union import pyrogram -from pyrogram import raw, types +from pyrogram import raw, types, errors class PromoteChatMember: @@ -61,12 +61,15 @@ class PromoteChatMember: if privileges is None: privileges = types.ChatPrivileges() - raw_chat_member = (await self.invoke( - raw.functions.channels.GetParticipant( - channel=chat_id, - participant=user_id - ) - )).participant + try: + raw_chat_member = (await self.invoke( + raw.functions.channels.GetParticipant( + channel=chat_id, + participant=user_id + ) + )).participant + except errors.RPCError: + raw_chat_member = None rank = None if isinstance(raw_chat_member, raw.types.ChannelParticipantAdmin):