-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Added threadmenu functionality to threadmenu. Fixes #3403 #3404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
_ThreadCreationMenuSelectand_ThreadCreationMenuViewto 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_optionfrom 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_labelis 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 aNameErrorat 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.
|
Can you run black formatting so the checks does not fail? |
Done so now. Thanks |
There was a problem hiding this 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.
Signed-off-by: lorenzo132 <50767078+lorenzo132@users.noreply.github.com>
There was a problem hiding this 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>
There was a problem hiding this 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.
|
The checks are failing |
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