Skip to content

Commit

Permalink
Add support for SimpleMenu to use custom select options (#6480)
Browse files Browse the repository at this point in the history
Co-authored-by: Jakub Kuczys <[email protected]>
  • Loading branch information
TrustyJAID and Jackenmen authored Dec 24, 2024
1 parent 9419f26 commit f4ffc6b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions redbot/core/utils/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ class SimpleMenu(discord.ui.View):
under the select menu in this instance.
Defaults to False.
Attributes
----------
select_menu: `discord.ui.Select`
A select menu with a list of pages. The usage of this attribute is discouraged
as it may store different instances throughout the menu's lifetime.
.. deprecated-removed:: 3.5.14 60
Any behaviour enabled by the usage of this attribute should no longer be depended on.
If you need this for something and cannot replace it with the other functionality,
create an issue on Red's issue tracker.
Examples
--------
You can provide a list of strings::
Expand Down Expand Up @@ -269,6 +280,11 @@ async def start(
Send the message ephemerally. This only works
if the context is from a slash command interaction.
"""
if self.use_select_menu and self.source.is_paginating():
self.remove_item(self.select_menu)
# we added a default one in init so we want to remove it and add any changes here
self.select_menu = self._get_select_menu()
self.add_item(self.select_menu)
self._fallback_author_to_ctx = True
if user is not None:
self.author = user
Expand All @@ -285,6 +301,11 @@ async def start_dm(self, user: discord.User):
user: `discord.User`
The user that will be direct messaged by the bot.
"""
if self.use_select_menu and self.source.is_paginating():
self.remove_item(self.select_menu)
# we added a default one in init so we want to remove it and add any changes here
self.select_menu = self._get_select_menu()
self.add_item(self.select_menu)
self.author = user
kwargs = await self.get_page(self.current_page)
self.message = await user.send(**kwargs)
Expand Down

0 comments on commit f4ffc6b

Please sign in to comment.