Skip to content

Conversation

@sebkuip
Copy link
Member

@sebkuip sebkuip commented Nov 30, 2025

The newly added threadmenu lacks the code for submenu. The config options exist but was never implemented. This fix implements this similar to how advanced-menu used to do this.

Issue #3403 is fixed by this

Copilot AI review requested due to automatic review settings November 30, 2025 20:38
@sebkuip sebkuip linked an issue Nov 30, 2025 that may be closed by this pull request
Copilot finished reviewing on behalf of sebkuip November 30, 2025 20:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements submenu functionality for the thread creation menu system, addressing issue #3403. The implementation allows users to navigate through nested menus when creating threads, with the ability to return to the main menu from submenus. The changes modify how menu options are tracked, shifting from storing a single option dict to maintaining a navigation path as a list.

Key Changes

  • Refactored _ThreadCreationMenuSelect and _ThreadCreationMenuView to support hierarchical menu navigation with submenu data and path tracking
  • Added "main menu" return option for submenus with navigation logic that rebuilds views based on menu level
  • Changed _selected_thread_creation_menu_option from storing an option dictionary to storing a list representing the navigation path
Comments suppressed due to low confidence (1)

core/thread.py:3196

  • The variable chosen_label is used on lines 3186, 3190, and 3196 but is never defined in this callback method. The removed lines (shown in the diff as deleted lines 3171-3173) previously defined this variable, but they were mistakenly removed. This will cause a NameError at runtime when a user selects an option in the precreate menu.

Add these lines after line 3170 (after the unsnooze exception handler):

chosen_label = self.values[0]
key = chosen_label.lower().replace(" ", "_")
selected = options.get(key)
self.outer_thread._selected_thread_creation_menu_option = selected
                async def callback(self, interaction: discord.Interaction):
                    await interaction.response.defer(ephemeral=False)
                    # If thread somehow got snoozed before selection in precreate flow (rare), restore first.
                    try:
                        if self.outer_thread.snoozed:
                            await self.outer_thread.restore_from_snooze()
                    except Exception:
                        logger.warning(
                            "Failed unsnoozing thread prior to precreate menu selection; continuing.",
                            exc_info=True,
                        )
                    # Remove the view
                    try:
                        msg = getattr(interaction, "message", None)
                        if msg is None and self.view and hasattr(self.view, "message"):
                            msg = self.view.message
                        if msg is not None:
                            # Replace entire embed so only the selection line remains
                            try:
                                base_color = (msg.embeds[0].color if msg.embeds else None) or getattr(
                                    self.outer_thread.bot, "mod_color", None
                                )
                            except Exception:
                                base_color = getattr(self.outer_thread.bot, "mod_color", None)
                            selection_embed = (
                                discord.Embed(
                                    description=f"You selected: {chosen_label}",
                                    color=base_color,
                                )
                                if base_color is not None
                                else discord.Embed(description=f"You selected: {chosen_label}")
                            )
                            await msg.edit(content=None, embed=selection_embed, view=None)
                        else:
                            try:
                                await interaction.edit_original_response(
                                    content=f"You selected: {chosen_label}", view=None

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@sebkuip sebkuip requested a review from Copilot November 30, 2025 20:44
@martinbndr martinbndr requested review from a team and removed request for Copilot November 30, 2025 20:46
@martinbndr
Copy link
Contributor

Can you run black formatting so the checks does not fail?

Copilot finished reviewing on behalf of sebkuip November 30, 2025 20:48
Copilot AI review requested due to automatic review settings November 30, 2025 20:51
@sebkuip
Copy link
Member Author

sebkuip commented Nov 30, 2025

Can you run black formatting so the checks does not fail?

Done so now. Thanks

Copilot finished reviewing on behalf of sebkuip November 30, 2025 20:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

martinbndr
martinbndr previously approved these changes Dec 1, 2025
Signed-off-by: lorenzo132 <50767078+lorenzo132@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 1, 2025 14:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Refactor thread creation menu handling to improve path management and submenu navigation.

Signed-off-by: lorenzo132 <50767078+lorenzo132@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 1, 2025 14:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@StephenDaDev
Copy link
Member

The checks are failing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: threadmenu is lacking submenu support

4 participants