From 4ac606b468fd5f585e9c8c11d98493947d1b76f2 Mon Sep 17 00:00:00 2001 From: Tobotimus Date: Mon, 15 Jan 2018 15:11:24 +1100 Subject: [PATCH] [V3 Launcher] Fix asking for cli flags after invalid instance selection (#1200) --- redbot/launcher.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/redbot/launcher.py b/redbot/launcher.py index 7401c73e0..f1f6281fc 100644 --- a/redbot/launcher.py +++ b/redbot/launcher.py @@ -202,24 +202,24 @@ def instance_menu(): return None counter = 0 print("Red instance menu\n") - + name_num_map = {} for name in list(instances.keys()): print("{}. {}\n".format(counter+1, name)) name_num_map[str(counter+1)] = name counter += 1 - selection = user_choice() - try: - selection = int(selection) - except ValueError: - print("Invalid input! Try again.") - return None - else: - if selection not in list(range(1, counter+1)): - print("Invalid selection! Please try again") - return None + + while True: + selection = user_choice() + try: + selection = int(selection) + except ValueError: + print("Invalid input! Please enter a number corresponding to an instance.") else: - return name_num_map[str(selection)] + if selection not in list(range(1, counter+1)): + print("Invalid selection! Please try again") + else: + return name_num_map[str(selection)] def clear_screen():