Skip to content
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

Add support for SimpleMenu to use custom select options #6480

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions redbot/core/utils/views.py
Original file line number Diff line number Diff line change
@@ -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::
@@ -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
@@ -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)