Skip to content

Commit

Permalink
userinfo: Don't fail when there is no username
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel2392 authored and itsLuuke committed May 7, 2023
1 parent 8a99d89 commit 3997467
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions AstrakoBot/modules/userinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>{user.id}</code>.",
parse_mode=ParseMode.HTML,
)
try:
user = bot.get_chat(user_id)
msg.reply_text(
f"{html.escape(user.first_name)}'s id is <code>{user.id}</code>.",
parse_mode=ParseMode.HTML,
)
except:
msg.reply_text(
f"Their id is <code>{user_id}</code>.",
parse_mode=ParseMode.HTML,
)

else:

Expand Down

0 comments on commit 3997467

Please sign in to comment.