@@ -2706,7 +2706,6 @@ async def callback(self, interaction: discord.Interaction):
27062706 # Resolve option key
27072707 key = chosen_label .lower ().replace (" " , "_" )
27082708 if key == "main_menu" :
2709- # From a submenu, go back to main menu. This is achieved by rebuilding the view.
27102709 option_data = self .bot .config .get ("thread_creation_menu_options" ) or {}
27112710 new_view = _ThreadCreationMenuView (
27122711 self .bot ,
@@ -2717,23 +2716,34 @@ async def callback(self, interaction: discord.Interaction):
27172716 is_home = True ,
27182717 )
27192718 return await self .menu_msg .edit (view = new_view )
2720- self .path .append (chosen_label )
27212719 selected : dict = self .option_data .get (key , {})
2720+ next_path = [* self .path , chosen_label ]
27222721 if selected .get ("type" , "command" ) == "submenu" :
2723- # Build new view for submenu
27242722 submenu_data = self .bot .config .get ("thread_creation_menu_submenus" ) or {}
2725- option_data = submenu_data .get (key , {})
2723+ submenu_key = selected .get ("callback" , key )
2724+ option_data = submenu_data .get (submenu_key , {})
2725+ if not option_data :
2726+ home_options = self .bot .config .get ("thread_creation_menu_options" ) or {}
2727+ new_view = _ThreadCreationMenuView (
2728+ self .bot ,
2729+ self .outer_thread ,
2730+ home_options ,
2731+ self .menu_msg ,
2732+ path = [],
2733+ is_home = True ,
2734+ )
2735+ return await self .menu_msg .edit (view = new_view )
27262736 new_view = _ThreadCreationMenuView (
27272737 self .bot ,
27282738 self .outer_thread ,
27292739 option_data ,
27302740 self .menu_msg ,
2731- path = self . path ,
2741+ path = next_path ,
27322742 is_home = False ,
27332743 )
27342744 return await self .menu_msg .edit (view = new_view )
27352745
2736- self .outer_thread ._selected_thread_creation_menu_option = self . path
2746+ self .outer_thread ._selected_thread_creation_menu_option = next_path
27372747 # Reflect the selection in the original DM by editing the embed/body
27382748 try :
27392749 msg = getattr (interaction , "message" , None )
@@ -3195,10 +3205,10 @@ async def callback(self, interaction: discord.Interaction):
31953205 "Failed unsnoozing thread prior to precreate menu selection; continuing." ,
31963206 exc_info = True ,
31973207 )
3198- # Define selection variables
31993208 chosen_label = self .values [0 ]
32003209 key = chosen_label .lower ().replace (" " , "_" )
32013210 selected = options .get (key )
3211+ self .outer_thread ._selected_thread_creation_menu_option = selected
32023212 # Remove the view
32033213 try :
32043214 msg = getattr (interaction , "message" , None )
0 commit comments