From 399746726c37bedfe42fe8ac9b572b19d9e0f791 Mon Sep 17 00:00:00 2001 From: Gabriel2392 Date: Sun, 7 May 2023 15:06:35 +0000 Subject: [PATCH] userinfo: Don't fail when there is no username --- AstrakoBot/modules/userinfo.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/AstrakoBot/modules/userinfo.py b/AstrakoBot/modules/userinfo.py index 536c1aa219..4b30c1acef 100644 --- a/AstrakoBot/modules/userinfo.py +++ b/AstrakoBot/modules/userinfo.py @@ -58,12 +58,17 @@ def get_id(update: Update, context: CallbackContext): ) else: - - user = bot.get_chat(user_id) - msg.reply_text( - f"{html.escape(user.first_name)}'s id is {user.id}.", - parse_mode=ParseMode.HTML, - ) + try: + user = bot.get_chat(user_id) + msg.reply_text( + f"{html.escape(user.first_name)}'s id is {user.id}.", + parse_mode=ParseMode.HTML, + ) + except: + msg.reply_text( + f"Their id is {user_id}.", + parse_mode=ParseMode.HTML, + ) else: