From a30f9ff7e63bbd3c72d3a7d527a8bbc7345e70d3 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Sun, 17 Mar 2024 23:13:43 +0100 Subject: [PATCH 1/7] Update install guides with new OS support matrix (#6309) --- .../_includes/install-python310-pyenv.rst | 27 --------- docs/install_guides/arch.rst | 12 ++-- docs/install_guides/fedora.rst | 2 +- docs/install_guides/index.rst | 2 +- docs/install_guides/opensuse-leap-15.rst | 8 +-- docs/install_guides/raspberry-pi-os-10.rst | 55 ------------------- docs/install_guides/raspberry-pi-os-11.rst | 22 ++++---- docs/install_guides/raspberry-pi-os-12.rst | 38 +++++++++++++ docs/version_guarantees.rst | 12 ++-- 9 files changed, 67 insertions(+), 111 deletions(-) delete mode 100644 docs/install_guides/_includes/install-python310-pyenv.rst delete mode 100644 docs/install_guides/raspberry-pi-os-10.rst create mode 100644 docs/install_guides/raspberry-pi-os-12.rst diff --git a/docs/install_guides/_includes/install-python310-pyenv.rst b/docs/install_guides/_includes/install-python310-pyenv.rst deleted file mode 100644 index c4160682155..00000000000 --- a/docs/install_guides/_includes/install-python310-pyenv.rst +++ /dev/null @@ -1,27 +0,0 @@ ----------------------------- -Installing Python with pyenv ----------------------------- - -On distributions where Python 3.10 needs to be compiled from source, we recommend the use of pyenv. -This simplifies the compilation process and has the added bonus of simplifying setting up Red in a -virtual environment. - -.. include:: _includes/_install-pyenv-and-setup-path.rst - -.. prompt:: bash - - CONFIGURE_OPTS=--enable-optimizations pyenv install 3.10.13 -v - -This may take a long time to complete, depending on your hardware. For some machines (such as -Raspberry Pis and micro-tier VPSes), it may take over an hour; in this case, you may wish to remove -the ``CONFIGURE_OPTS=--enable-optimizations`` part from the front of the command, which will -drastically reduce the install time. However, be aware that this will make Python run about 10% -slower. - -After that is finished, run: - -.. prompt:: bash - - pyenv global 3.10.13 - -Pyenv is now installed and your system should be configured to run Python 3.10. diff --git a/docs/install_guides/arch.rst b/docs/install_guides/arch.rst index 64c7f0c368c..6c2c4b5aec0 100644 --- a/docs/install_guides/arch.rst +++ b/docs/install_guides/arch.rst @@ -18,20 +18,20 @@ Install the pre-requirements with pacman: sudo pacman -Syu git jre17-openjdk-headless base-devel nano -On Arch Linux, Python 3.9 can be installed from the Arch User Repository (AUR) from the ``python39`` package. +On Arch Linux, Python 3.10 can be installed from the Arch User Repository (AUR) from the ``python310`` package. -The manual build process is the Arch-supported install method for AUR packages. You can install ``python39`` package with the following commands: +The manual build process is the Arch-supported install method for AUR packages. You can install ``python310`` package with the following commands: .. prompt:: bash - git clone https://aur.archlinux.org/python39.git /tmp/python39 - cd /tmp/python39 + git clone https://aur.archlinux.org/python310.git /tmp/python310 + cd /tmp/python310 makepkg -sicL cd - - rm -rf /tmp/python39 + rm -rf /tmp/python310 .. Include common instructions: -.. include:: _includes/create-env-with-venv3.9.rst +.. include:: _includes/create-env-with-venv3.10.rst .. include:: _includes/install-and-setup-red-unix.rst diff --git a/docs/install_guides/fedora.rst b/docs/install_guides/fedora.rst index 485cf5fda6c..447873ec043 100644 --- a/docs/install_guides/fedora.rst +++ b/docs/install_guides/fedora.rst @@ -12,7 +12,7 @@ Installing Red on Fedora Linux Installing the pre-requirements ------------------------------- -Fedora Linux 37 and above has all required packages available in official repositories. Install +Fedora Linux 38 and above has all required packages available in official repositories. Install them with dnf: .. prompt:: bash diff --git a/docs/install_guides/index.rst b/docs/install_guides/index.rst index 9188cce26a0..b71ec347d52 100644 --- a/docs/install_guides/index.rst +++ b/docs/install_guides/index.rst @@ -26,8 +26,8 @@ we recommend **Ubuntu 22.04 LTS**. opensuse-tumbleweed oracle-linux-8 oracle-linux-9 - raspberry-pi-os-10 raspberry-pi-os-11 + raspberry-pi-os-12 rhel-8 rhel-9 rocky-linux-8 diff --git a/docs/install_guides/opensuse-leap-15.rst b/docs/install_guides/opensuse-leap-15.rst index 6a93be13289..0113ed99752 100644 --- a/docs/install_guides/opensuse-leap-15.rst +++ b/docs/install_guides/opensuse-leap-15.rst @@ -1,7 +1,7 @@ .. _install-opensuse-leap-15: ===================================== -Installing Red on openSUSE Leap 15.4+ +Installing Red on openSUSE Leap 15.5+ ===================================== .. include:: _includes/supported-arch-x64+aarch64.rst @@ -12,16 +12,16 @@ Installing Red on openSUSE Leap 15.4+ Installing the pre-requirements ------------------------------- -openSUSE Leap 15.4+ has all required dependencies available in official repositories. Install them +openSUSE Leap 15.5+ has all required dependencies available in official repositories. Install them with zypper: .. prompt:: bash - sudo zypper -n install python310 python310-devel git-core java-17-openjdk-headless nano + sudo zypper -n install python311 python311-devel git-core java-17-openjdk-headless nano sudo zypper -n install -t pattern devel_basis .. Include common instructions: -.. include:: _includes/create-env-with-venv3.10.rst +.. include:: _includes/create-env-with-venv3.11.rst .. include:: _includes/install-and-setup-red-unix.rst diff --git a/docs/install_guides/raspberry-pi-os-10.rst b/docs/install_guides/raspberry-pi-os-10.rst deleted file mode 100644 index af7468cfc3f..00000000000 --- a/docs/install_guides/raspberry-pi-os-10.rst +++ /dev/null @@ -1,55 +0,0 @@ -.. _install-raspberry-pi-os-10: - -==================================================== -Installing Red on Raspberry Pi OS (Legacy) 10 Buster -==================================================== - -.. include:: _includes/supported-arch-armv7l.rst - -.. note:: - - While we do provide support and install instructions for running Red - on Raspberry Pi OS (Legacy) 10 Buster, we highly recommend installing/upgrading to - the new version - Raspberry Pi OS 11 Bullseye. - - If you're not sure what version you are using, - you can check your version of Raspberry Pi OS by running: - - .. prompt:: bash - - lsb_release -a - - If you're running Bullseye already, read `install-raspberry-pi-os-11` document instead. - - If you're using Buster, please consider upgrading to Bullseye if possible. - You can read - `the post about Bullseye release from Raspberry Pi Foundation `__ - to learn how you can install/upgrade to the new version. - -.. include:: _includes/linux-preamble.rst - -------------------------------- -Installing the pre-requirements -------------------------------- - -We recommend installing pyenv as a method of installing non-native versions of Python on -Raspberry Pi OS. This guide will tell you how. First, run the following commands: - -.. cmake is necessary to be able to successfully build rapidfuzz. - -.. prompt:: bash - - sudo apt update - sudo apt -y install cmake make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev libgdbm-dev uuid-dev python3-openssl git openjdk-17-jre-headless nano - CXX=/usr/bin/g++ - -.. Include common instructions: - -.. We should only build and install even versions of Python on Raspberry Pi OS as odd -.. versions are part of piwheels and can cause installs of pip packages that won't work. - -.. include:: _includes/install-python310-pyenv.rst - -.. include:: _includes/create-env-with-pyenv-virtualenv.rst - -.. include:: _includes/install-and-setup-red-unix.rst diff --git a/docs/install_guides/raspberry-pi-os-11.rst b/docs/install_guides/raspberry-pi-os-11.rst index 1cd81f0f0b8..72a38cb4c5b 100644 --- a/docs/install_guides/raspberry-pi-os-11.rst +++ b/docs/install_guides/raspberry-pi-os-11.rst @@ -1,25 +1,27 @@ .. _install-raspberry-pi-os-11: -============================================= -Installing Red on Raspberry Pi OS 11 Bullseye -============================================= +====================================================== +Installing Red on Raspberry Pi OS (Legacy) 11 Bullseye +====================================================== .. include:: _includes/supported-arch-aarch64+armv7l.rst .. note:: - This guide can only be used with Raspberry Pi OS 11 Bullseye, - it will not work with any older (e.g. Raspberry Pi OS 10 Buster) - or newer (e.g. Raspberry Pi OS 12 Bookworm) releases. - You can check your version of Raspberry Pi OS by running: + While we do provide support and install instructions for running Red + on Raspberry Pi OS (Legacy) 11 Bullseye, we highly recommend installing/upgrading to + the new version - Raspberry Pi OS 12 Bookworm. + + If you're not sure what version you are using, + you can check your version of Raspberry Pi OS by running: .. prompt:: bash lsb_release -a - If you're not running Bullseye, you should read - `the post about Bullseye release from Raspberry Pi Foundation `__ - to learn how you can install/upgrade to the new version. + If you're running Bookworm already, read `install-raspberry-pi-os-12` document instead. + + If you're using Bullseye, please consider performing a clean install of Bookworm if possible. .. include:: _includes/linux-preamble.rst diff --git a/docs/install_guides/raspberry-pi-os-12.rst b/docs/install_guides/raspberry-pi-os-12.rst new file mode 100644 index 00000000000..8d63e6da9b8 --- /dev/null +++ b/docs/install_guides/raspberry-pi-os-12.rst @@ -0,0 +1,38 @@ +.. _install-raspberry-pi-os-12: + +============================================= +Installing Red on Raspberry Pi OS 12 Bookworm +============================================= + +.. include:: _includes/supported-arch-aarch64+armv7l.rst + +.. note:: + + This guide can only be used with Raspberry Pi OS 12 Bookworm, + it will not work with any older (e.g. Raspberry Pi OS 11 Bullseye) + or newer (e.g. Raspberry Pi OS 13 Trixie) releases. + You can check your version of Raspberry Pi OS by running: + + .. prompt:: bash + + lsb_release -a + +.. include:: _includes/linux-preamble.rst + +------------------------------- +Installing the pre-requirements +------------------------------- + +Raspberry Pi OS "Bookworm" has all required packages available in official repositories. Install them +with apt: + +.. prompt:: bash + + sudo apt update + sudo apt -y install python3 python3-dev python3-venv git openjdk-17-jre-headless build-essential nano + +.. Include common instructions: + +.. include:: _includes/create-env-with-venv3.11.rst + +.. include:: _includes/install-and-setup-red-unix.rst diff --git a/docs/version_guarantees.rst b/docs/version_guarantees.rst index 637c7430bd5..4cc444ef6c9 100644 --- a/docs/version_guarantees.rst +++ b/docs/version_guarantees.rst @@ -52,9 +52,9 @@ Operating system version Supported architectures Ideally supported u ================================ ======================= ============================================================ Windows 10 x86-64 `End/Retirement Date `__ Windows 11 x86-64 `Retirement Date `__ -macOS 11 (Big Sur) x86-64, aarch64 ~2023-10 macOS 12 (Monterey) x86-64, aarch64 ~2024-10 macOS 13 (Ventura) x86-64, aarch64 ~2025-10 +macOS 14 (Sonoma) x86-64, aarch64 ~2026-10 Alma Linux 8 x86-64, aarch64 2029-05-31 (`How long will CloudLinux support AlmaLinux? `__) Alma Linux 9 x86-64, aarch64 2032-05-31 Arch Linux x86-64 forever (support is only provided for an up-to-date system) @@ -63,15 +63,14 @@ CentOS Stream 8 x86-64, aarch64 2024-05-31 (`end of CentOS Stream 9 x86-64, aarch64 2027-05-31 (`expected EOL `__) Debian 11 Bullseye x86-64, aarch64, armv7l ~2024-07 (`End of life `__) Debian 12 Bookworm x86-64, aarch64, armv7l ~2026-09 (`End of life `__) -Fedora Linux 37 x86-64, aarch64 2023-11-14 (`End of Life `__) Fedora Linux 38 x86-64, aarch64 2024-05-14 (`End of Life `__) -openSUSE Leap 15.4 x86-64, aarch64 2023-11-30 (`end of maintenance life cycle `__) +Fedora Linux 39 x86-64, aarch64 2024-11-12 (`End of Life `__) openSUSE Leap 15.5 x86-64, aarch64 2024-12-31 (`end of maintenance life cycle `__) openSUSE Tumbleweed x86-64, aarch64 forever (support is only provided for an up-to-date system) Oracle Linux 8 x86-64, aarch64 2029-07-31 (`End of Premier Support `__) Oracle Linux 9 x86-64, aarch64 2032-06-31 (`End of Premier Support `__) -Raspberry Pi OS (Legacy) 10 armv7l ~2023-12 (approximate date of release of Raspberry Pi OS 12) -Raspberry Pi OS 11 aarch64, armv7l ~2023-12 (approximate date of release of Raspberry Pi OS 12) +Raspberry Pi OS (Legacy) 11 armv7l ~2025-10 (approximate date of release of Raspberry Pi OS 13) +Raspberry Pi OS 12 aarch64, armv7l ~2025-10 (approximate date of release of Raspberry Pi OS 13) RHEL 8 (latest) x86-64, aarch64 2029-05-31 (`End of Maintenance Support `__) RHEL 8.6 x86-64, aarch64 2024-05-31 (`End of Extended Update Support `__) RHEL 8.8 x86-64, aarch64 2025-05-31 (`End of Extended Update Support `__) @@ -82,8 +81,7 @@ Rocky Linux 8 x86-64, aarch64 2029-05-31 (`end-of Rocky Linux 9 x86-64, aarch64 2032-05-31 (`end-of-life `__) Ubuntu 20.04 LTS x86-64, aarch64 2025-04-30 (`End of Standard Support `__) Ubuntu 22.04 LTS x86-64, aarch64 2027-04-30 (`End of Standard Support `__) -Ubuntu 22.10 x86-64, aarch64 2023-07-31 (`End of Standard Support `__) -Ubuntu 23.04 x86-64, aarch64 2024-01-31 (`End of Standard Support `__) +Ubuntu 23.10 x86-64, aarch64 2024-07-31 (`End of Standard Support `__) ================================ ======================= ============================================================ .. _developer-guarantees: From 293d8065eca6ab94bb94c3dc98f535b0f9980a5b Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Sun, 17 Mar 2024 23:53:06 +0100 Subject: [PATCH 2/7] Remove traceback suppression from buttonized menu() (#6310) --- redbot/core/utils/menus.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/redbot/core/utils/menus.py b/redbot/core/utils/menus.py index d3d057285a1..ee63a70045e 100644 --- a/redbot/core/utils/menus.py +++ b/redbot/core/utils/menus.py @@ -49,10 +49,7 @@ async def callback(self, interaction: discord.Interaction): if self.emoji.is_unicode_emoji() else (ctx.bot.get_emoji(self.emoji.id) or self.emoji) ) - try: - await self.func(ctx, pages, controls, message, page, timeout, emoji) - except Exception: - pass + await self.func(ctx, pages, controls, message, page, timeout, emoji) async def menu( From 0c83fcd4955791260e9cf784e0f490d66613d11a Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Mon, 18 Mar 2024 01:15:17 +0100 Subject: [PATCH 3/7] Add explicit mention of word 'provisional' for version guarantee exclusions (#6311) --- CHANGES.rst | 10 +++++----- docs/framework_commands.rst | 2 +- docs/framework_rpc.rst | 3 ++- docs/version_guarantees.rst | 12 +++++++++--- redbot/core/_rpc.py | 6 ++++-- redbot/core/bot.py | 4 ++-- redbot/core/commands/commands.py | 2 +- redbot/core/commands/converter.py | 5 +++-- redbot/core/commands/help.py | 4 ++-- 9 files changed, 29 insertions(+), 19 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 16bfcbb0a05..6b39d423d80 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -443,7 +443,7 @@ Changes - **Core - Bot Class** - The ``channel`` parameter of `Red.embed_requested()` now accepts any messageable guild channel (:issue:`5576`) - **Core - Bot Class** - The bot's color is now set earlier in the launch process (:issue:`5627`) - **Core - Bot Class** - `Red.remove_cog()` returns a `commands.Cog` instance now (:issue:`5600`) -- **Core - Commands Package** - The provisional ``Literal`` converter has been replaced with discord.py's own `typing.Literal` implementation (:issue:`5600`) +- **Core - Commands Package** - The `provisional ` ``Literal`` converter has been replaced with discord.py's own `typing.Literal` implementation (:issue:`5600`) - **Core - Commands Package** - Added a ``join_character`` parameter to `Red.send_interactive()` and `Context.send_interactive()` to allow choosing the character messages are joined with (:issue:`5901`, :issue:`5902`) - **Core - Modlog** - `modlog.set_modlog_channel()` can now accept `discord.VoiceChannel` and `discord.StageChannel` (:issue:`5709`) - **Core - Utils Package** - `menu()` now defaults to `DEFAULT_CONTROLS` if the ``controls`` argument is not passed (:issue:`5678`) @@ -2077,13 +2077,13 @@ Additions - Cog disabling is automatically applied for commands and only needs to be done manually for things like event listeners; see `recommendations-for-cog-creators` for more information - |cool| **Core** - Added data request API (:issue:`4045`, :issue:`4169`) - - New special methods added to `redbot.core.commands.Cog`: `red_get_data_for_user()` (documented provisionally), `red_delete_data_for_user()` + - New special methods added to `redbot.core.commands.Cog`: `red_get_data_for_user()` (documented `provisionally `), `red_delete_data_for_user()` - New special module level variable added: ``__red_end_user_data_statement__`` - These methods and variables should be added by all cogs according to their documentation; see `recommendations-for-cog-creators` for more information - New ``info.json`` key added: ``end_user_data_statement``; see `Info.json format documentation ` for more information - **Core - Bot Class** - Added `bot.message_eligible_as_command() ` utility method which can be used to determine if a message may be responded to as a command (:issue:`4077`) -- |cool| **Core - Commands Package** - Added a provisional API for replacing the help formatter. See `documentation ` for more details (:issue:`4011`) -- **Core - Commands Package** - `commands.NoParseOptional ` is no longer provisional and is now fully supported part of API (:issue:`4142`) +- |cool| **Core - Commands Package** - Added a `provisional API ` for replacing the help formatter. See `documentation ` for more details (:issue:`4011`) +- **Core - Commands Package** - `commands.NoParseOptional ` is no longer `provisional ` and is now fully supported part of API (:issue:`4142`) Changes ******* @@ -2435,7 +2435,7 @@ Documentation changes Changes ******* -- Added information about provisional status of RPC (:issue:`3862`) +- Added information about `provisional ` status of RPC (:issue:`3862`) - Revised install instructions (:issue:`3847`) - Improved navigation in `document about updating Red ` (:issue:`3856`, :issue:`3849`) diff --git a/docs/framework_commands.rst b/docs/framework_commands.rst index 38a57470706..59da090600e 100644 --- a/docs/framework_commands.rst +++ b/docs/framework_commands.rst @@ -66,7 +66,7 @@ Help Functionality .. warning:: - The content in this section is provisional and may change + The content in this section is `provisional ` and may change without prior notice or warning. Updates to this will be communicated on `this issue `_ diff --git a/docs/framework_rpc.rst b/docs/framework_rpc.rst index 45757b128d6..41a821d4152 100644 --- a/docs/framework_rpc.rst +++ b/docs/framework_rpc.rst @@ -6,7 +6,8 @@ RPC .. important:: - RPC support is included in Red on a provisional basis. Backwards incompatible changes (up to and including removal of the RPC) may occur if deemed necessary. + RPC support is included in Red on a `provisional ` basis. + Backwards incompatible changes (up to and including removal of the RPC) may occur if deemed necessary. V3 comes default with an internal RPC server that may be used to remotely control the bot in various ways. Cogs must register functions to be exposed to RPC clients. diff --git a/docs/version_guarantees.rst b/docs/version_guarantees.rst index 4cc444ef6c9..c5978094a45 100644 --- a/docs/version_guarantees.rst +++ b/docs/version_guarantees.rst @@ -112,12 +112,18 @@ This allows us to add certain optional features non-breakingly without a name co Any RPC method exposed by Red may break without notice. -Any exclusion from these guarantees should be noted in the documentation of -the affected attribute, function, class, or method. - If you would like something in here to be guaranteed, open an issue making a case for it to be moved. +.. _developer-guarantees-exclusions: + +Exclusions +---------- + +Any exclusion from these guarantees should be noted in the documentation of +the affected attribute, function, class, or method. The term "provisional" +may be used in documentation to note such exclusions. + .. _breaking-change-notices: ======================= diff --git a/redbot/core/_rpc.py b/redbot/core/_rpc.py index 5cd2e1660e8..28515687a1d 100644 --- a/redbot/core/_rpc.py +++ b/redbot/core/_rpc.py @@ -156,7 +156,8 @@ def register_rpc_handler(self, method): The return value of handler methods must also be JSON serializable. .. important:: - RPC support is included in Red on a provisional basis. Backwards incompatible changes (up to and including removal of the RPC) may occur if deemed necessary. + RPC support is included in Red on a `provisional ` basis. + Backwards incompatible changes (up to and including removal of the RPC) may occur if deemed necessary. Parameters ---------- @@ -180,7 +181,8 @@ def unregister_rpc_handler(self, method): method is not previously registered. .. important:: - RPC support is included in Red on a provisional basis. Backwards incompatible changes (up to and including removal of the RPC) may occur if deemed necessary. + RPC support is included in Red on a `provisional ` basis. + Backwards incompatible changes (up to and including removal of the RPC) may occur if deemed necessary. Parameters ---------- diff --git a/redbot/core/bot.py b/redbot/core/bot.py index bb77723b3c7..f3a9135d6e5 100644 --- a/redbot/core/bot.py +++ b/redbot/core/bot.py @@ -255,7 +255,7 @@ def set_help_formatter(self, formatter: commands.help.HelpFormatterABC): Set's Red's help formatter. .. warning:: - This method is provisional. + This method is `provisional `. The formatter must implement all methods in @@ -296,7 +296,7 @@ def reset_help_formatter(self): Resets Red's help formatter. .. warning:: - This method is provisional. + This method is `provisional `. This exists for use in ``cog_unload`` for cogs which replace the formatter diff --git a/redbot/core/commands/commands.py b/redbot/core/commands/commands.py index 85ff1dc0a58..22ffc34ccdf 100644 --- a/redbot/core/commands/commands.py +++ b/redbot/core/commands/commands.py @@ -840,7 +840,7 @@ async def red_get_data_for_user(self, *, user_id: int) -> MutableMapping[str, io .. note:: - This method is documented provisionally + This method is documented `provisionally ` and may have minor changes made to it. It is not expected to undergo major changes, but nothing utilizes this method yet and the inclusion of this method diff --git a/redbot/core/commands/converter.py b/redbot/core/commands/converter.py index 8af18dcaea0..9ef82cdffad 100644 --- a/redbot/core/commands/converter.py +++ b/redbot/core/commands/converter.py @@ -3,7 +3,8 @@ ================== This module contains useful functions and classes for command argument conversion. -Some of the converters within are included provisionally and are marked as such. +Some of the converters within are included `provisionally ` +and are marked as such. """ import functools import math @@ -492,7 +493,7 @@ def __class_getitem__(cls, key): #: multiple types, but such usage is not supported and will fail at runtime #: #: .. warning:: - #: This converter class is still provisional. + #: This converter class is still `provisional `. UserInputOptional = Optional if TYPE_CHECKING: diff --git a/redbot/core/commands/help.py b/redbot/core/commands/help.py index 66920780d59..111d6d302dc 100644 --- a/redbot/core/commands/help.py +++ b/redbot/core/commands/help.py @@ -82,7 +82,7 @@ class HelpSettings: .. warning:: - This class is provisional. + This class is `provisional `. """ @@ -190,7 +190,7 @@ class HelpFormatterABC(abc.ABC): .. warning:: - This class is documented but provisional with expected changes. + This class is documented but `provisional ` with expected changes. In the future, this class will receive changes to support invoking the help command without context. From f5011a90e174d483cec72096ceb837701d83b5bc Mon Sep 17 00:00:00 2001 From: Michael Oliveira <34169552+Flame442@users.noreply.github.com> Date: Sun, 17 Mar 2024 20:17:12 -0400 Subject: [PATCH 4/7] Fix editrole color (#6270) --- redbot/cogs/admin/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/admin/admin.py b/redbot/cogs/admin/admin.py index 22439bb8c08..1dfa57a22f9 100644 --- a/redbot/cogs/admin/admin.py +++ b/redbot/cogs/admin/admin.py @@ -273,7 +273,7 @@ async def editrole_colour( """ author = ctx.author reason = _("{author} ({author.id}) changed the colour of role '{role.name}'").format( - author=author, role=role.name + author=author, role=role ) if not self.pass_user_hierarchy_check(ctx, role): From 4c7a691ec9fc5f4d28170cf0f102a36eb5107ba4 Mon Sep 17 00:00:00 2001 From: Michael Oliveira <34169552+Flame442@users.noreply.github.com> Date: Sun, 17 Mar 2024 20:29:17 -0400 Subject: [PATCH 5/7] Add note to refresh client after syncing slash commands (#6298) --- docs/guide_slash_and_interactions.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/guide_slash_and_interactions.rst b/docs/guide_slash_and_interactions.rst index 3422094773f..d69a489e1d9 100644 --- a/docs/guide_slash_and_interactions.rst +++ b/docs/guide_slash_and_interactions.rst @@ -39,6 +39,11 @@ Go ahead and load your cog. Once it is loaded, we will have to enable and sync o We can do this by using the :ref:`[p]slash` command to manage our slash commands. Once you have registered your slash commands, you can test them out by typing ``/hello`` in your server. +.. tip:: + + You may need to restart your Discord client with ``Ctrl + R`` (or your device's equivalent) to force + your client to see the new command after syncing. + ---------------------------- Slash Commands and Arguments ---------------------------- From 8c2976504a0e355dd244721d37cd531a8b1b5921 Mon Sep 17 00:00:00 2001 From: Auguste Charpentier Date: Mon, 18 Mar 2024 01:35:53 +0100 Subject: [PATCH 6/7] Add user param to menu() (#4913) Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> Co-authored-by: Jakub Kuczys --- redbot/core/commands/help.py | 10 +-- redbot/core/utils/menus.py | 139 ++++++++++++++++++++++++++++++----- redbot/core/utils/views.py | 37 +++++++++- 3 files changed, 158 insertions(+), 28 deletions(-) diff --git a/redbot/core/commands/help.py b/redbot/core/commands/help.py index 111d6d302dc..a86b16bb5ab 100644 --- a/redbot/core/commands/help.py +++ b/redbot/core/commands/help.py @@ -878,14 +878,10 @@ async def send_pages( m = await (destination.send(embed=pages[0]) if embed else destination.send(pages[0])) c = menus.DEFAULT_CONTROLS if len(pages) > 1 else {"\N{CROSS MARK}": menus.close_menu} # Allow other things to happen during menu timeout/interaction. - if use_DMs: - menu_ctx = await ctx.bot.get_context(m) - # Monkeypatch so help listens for reactions from the original author, not the bot - menu_ctx.author = ctx.author - else: - menu_ctx = ctx asyncio.create_task( - menus.menu(menu_ctx, pages, c, message=m, timeout=help_settings.react_timeout) + menus.menu( + ctx, pages, c, user=ctx.author, message=m, timeout=help_settings.react_timeout + ) ) # menu needs reactions added manually since we fed it a message menus.start_adding_reactions(m, c.keys()) diff --git a/redbot/core/utils/menus.py b/redbot/core/utils/menus.py index ee63a70045e..d3a52dde78e 100644 --- a/redbot/core/utils/menus.py +++ b/redbot/core/utils/menus.py @@ -49,48 +49,126 @@ async def callback(self, interaction: discord.Interaction): if self.emoji.is_unicode_emoji() else (ctx.bot.get_emoji(self.emoji.id) or self.emoji) ) - await self.func(ctx, pages, controls, message, page, timeout, emoji) + user = self.view.author if not self.view._fallback_author_to_ctx else None + if user is not None: + await self.func(ctx, pages, controls, message, page, timeout, emoji, user=user) + else: + await self.func(ctx, pages, controls, message, page, timeout, emoji) async def menu( ctx: commands.Context, pages: _PageList, controls: Optional[Mapping[str, _ControlCallable]] = None, - message: discord.Message = None, + message: Optional[discord.Message] = None, page: int = 0, timeout: float = 30.0, + *, + user: Optional[discord.User] = None, ) -> _T: """ An emoji-based menu - .. note:: All pages should be of the same type + All functions for handling what a particular emoji does + should be coroutines (i.e. :code:`async def`). Additionally, + they must take all of the parameters of this function, in + addition to a string representing the emoji reacted with. + This parameter should be the 7th one, and none of the + parameters in the handling functions are optional. + + .. warning:: + + The ``user`` parameter is considered `provisional `. + If no issues arise, we plan on including it under developer guarantees + in the first release made after 2024-05-18. + + .. warning:: + + If you're using the ``user`` param, you need to pass it + as a keyword-only argument, and set :obj:`None` as the + default in your function. + + Examples + -------- + + Simple menu using default controls:: + + from redbot.core.utils.menus import menu + + pages = ["Hello", "Hi", "Bonjour", "Salut"] + await menu(ctx, pages) + + Menu with a custom control performing an action (deleting an item from pages list):: + + from redbot.core.utils import menus + + items = ["Apple", "Banana", "Cucumber", "Dragonfruit"] + + def generate_pages(): + return [f"{fruit} is an awesome fruit!" for fruit in items] + + async def delete_item_action(ctx, pages, controls, message, page, timeout, emoji): + fruit = items.pop(page) # lookup and remove corresponding fruit name + await ctx.send(f"I guess you don't like {fruit}, huh? Deleting...") + pages = generate_pages() + if not pages: + return await menus.close_menu(ctx, pages, controls, message, page, timeout) + page = min(page, len(pages) - 1) + return await menus.menu(ctx, pages, controls, message, page, timeout) + + pages = generate_pages() + controls = {**menus.DEFAULT_CONTROLS, "\\N{NO ENTRY SIGN}": delete_item_action} + await menus.menu(ctx, pages, controls) - .. note:: All functions for handling what a particular emoji does - should be coroutines (i.e. :code:`async def`). Additionally, - they must take all of the parameters of this function, in - addition to a string representing the emoji reacted with. - This parameter should be the last one, and none of the - parameters in the handling functions are optional + Menu with custom controls that output a result (confirmation prompt):: + + from redbot.core.utils.menus import menu + + async def control_yes(*args, **kwargs): + return True + + async def control_no(*args, **kwargs): + return False + + msg = "Do you wish to continue?" + controls = { + "\\N{WHITE HEAVY CHECK MARK}": control_yes, + "\\N{CROSS MARK}": control_no, + } + reply = await menu(ctx, [msg], controls) + if reply: + await ctx.send("Continuing...") + else: + await ctx.send("Okay, I'm not going to perform the requested action.") Parameters ---------- ctx: commands.Context The command context - pages: `list` of `str` or `discord.Embed` + pages: Union[List[str], List[discord.Embed]] The pages of the menu. + All pages need to be of the same type (either `str` or `discord.Embed`). controls: Optional[Mapping[str, Callable]] A mapping of emoji to the function which handles the action for the emoji. The signature of the function should be the same as of this function and should additionally accept an ``emoji`` parameter of type `str`. If not passed, `DEFAULT_CONTROLS` is used *or* only a close menu control is shown when ``pages`` is of length 1. - message: discord.Message + message: Optional[discord.Message] The message representing the menu. Usually :code:`None` when first opening the menu page: int The current page number of the menu timeout: float The time (in seconds) to wait for a reaction + user: Optional[discord.User] + The user allowed to interact with the menu. Defaults to ``ctx.author``. + + .. warning:: + + This parameter is `provisional `. + If no issues arise, we plan on including it under developer guarantees + in the first release made after 2024-05-18. Raises ------ @@ -136,7 +214,7 @@ async def menu( # internally we already include the emojis we expect. if controls == DEFAULT_CONTROLS: view = SimpleMenu(pages, timeout=timeout) - await view.start(ctx) + await view.start(ctx, user=user) await view.wait() return else: @@ -169,7 +247,7 @@ async def menu( view.remove_item(view.stop_button) for emoji, func in to_add.items(): view.add_item(_GenericButton(emoji, func)) - await view.start(ctx) + await view.start(ctx, user=user) _active_menus[view.message.id] = view await view.wait() del _active_menus[view.message.id] @@ -194,7 +272,9 @@ async def menu( return try: - predicates = ReactionPredicate.with_emojis(tuple(controls.keys()), message, ctx.author) + predicates = ReactionPredicate.with_emojis( + tuple(controls.keys()), message, user or ctx.author + ) tasks = [ asyncio.create_task(ctx.bot.wait_for("reaction_add", check=predicates)), asyncio.create_task(ctx.bot.wait_for("reaction_remove", check=predicates)), @@ -230,9 +310,14 @@ async def menu( except discord.NotFound: return else: - return await controls[react.emoji]( - ctx, pages, controls, message, page, timeout, react.emoji - ) + if user is not None: + return await controls[react.emoji]( + ctx, pages, controls, message, page, timeout, react.emoji, user=user + ) + else: + return await controls[react.emoji]( + ctx, pages, controls, message, page, timeout, react.emoji + ) async def next_page( @@ -243,6 +328,8 @@ async def next_page( page: int, timeout: float, emoji: str, + *, + user: Optional[discord.User] = None, ) -> _T: """ Function for showing next page which is suitable @@ -252,7 +339,12 @@ async def next_page( page = 0 # Loop around to the first item else: page = page + 1 - return await menu(ctx, pages, controls, message=message, page=page, timeout=timeout) + if user is not None: + return await menu( + ctx, pages, controls, message=message, page=page, timeout=timeout, user=user + ) + else: + return await menu(ctx, pages, controls, message=message, page=page, timeout=timeout) async def prev_page( @@ -263,6 +355,8 @@ async def prev_page( page: int, timeout: float, emoji: str, + *, + user: Optional[discord.User] = None, ) -> _T: """ Function for showing previous page which is suitable @@ -272,7 +366,12 @@ async def prev_page( page = len(pages) - 1 # Loop around to the last item else: page = page - 1 - return await menu(ctx, pages, controls, message=message, page=page, timeout=timeout) + if user is not None: + return await menu( + ctx, pages, controls, message=message, page=page, timeout=timeout, user=user + ) + else: + return await menu(ctx, pages, controls, message=message, page=page, timeout=timeout) async def close_menu( @@ -283,6 +382,8 @@ async def close_menu( page: int, timeout: float, emoji: str, + *, + user: Optional[discord.User] = None, ) -> None: """ Function for closing (deleting) menu which is suitable diff --git a/redbot/core/utils/views.py b/redbot/core/utils/views.py index f6d2fea48a1..51fb9efa9d6 100644 --- a/redbot/core/utils/views.py +++ b/redbot/core/utils/views.py @@ -136,6 +136,7 @@ def __init__( super().__init__( timeout=timeout, ) + self._fallback_author_to_ctx = True self.author: Optional[discord.abc.User] = None self.message: Optional[discord.Message] = None self._source = _SimplePageSource(items=pages) @@ -192,6 +193,19 @@ def __init__( def source(self): return self._source + @property + def author(self) -> Optional[discord.abc.User]: + if self._author is not None: + return self._author + if self._fallback_author_to_ctx: + return getattr(self.ctx, "author", None) + return None + + @author.setter + def author(self, value: Optional[discord.abc.User]) -> None: + self._fallback_author_to_ctx = False + self._author = value + async def on_timeout(self): try: if self.delete_after_timeout and not self.message.flags.ephemeral: @@ -225,19 +239,38 @@ def _get_select_menu(self): options = self.select_options[:25] return _SelectMenu(options) - async def start(self, ctx: Context, *, ephemeral: bool = False): + async def start( + self, ctx: Context, *, user: Optional[discord.abc.User] = None, ephemeral: bool = False + ): """ Used to start the menu displaying the first page requested. + .. warning:: + + The ``user`` parameter is considered `provisional `. + If no issues arise, we plan on including it under developer guarantees + in the first release made after 2024-05-18. + Parameters ---------- ctx: `commands.Context` The context to start the menu in. + user: discord.User + The user allowed to interact with the menu. + If this is ``None``, ``ctx.author`` will be able to interact with the menu. + + .. warning:: + + This parameter is `provisional `. + If no issues arise, we plan on including it under developer guarantees + in the first release made after 2024-05-18. ephemeral: `bool` Send the message ephemerally. This only works if the context is from a slash command interaction. """ - self.author = ctx.author + self._fallback_author_to_ctx = True + if user is not None: + self.author = user self.ctx = ctx kwargs = await self.get_page(self.current_page) self.message = await ctx.send(**kwargs, ephemeral=ephemeral) From 3a81e8327fa93f4c9c2320368f417ac1793b34b3 Mon Sep 17 00:00:00 2001 From: aikaterna <20862007+aikaterna@users.noreply.github.com> Date: Sun, 17 Mar 2024 17:38:00 -0700 Subject: [PATCH 7/7] [Audio] Update Lavalink.jar build (#6305) --- redbot/cogs/audio/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/audio/manager.py b/redbot/cogs/audio/manager.py index 4400111d68b..6d5d3c6d701 100644 --- a/redbot/cogs/audio/manager.py +++ b/redbot/cogs/audio/manager.py @@ -264,7 +264,7 @@ def __ge__(self, other: object) -> bool: class ServerManager: - JAR_VERSION: Final[str] = LavalinkVersion(3, 7, 8) + JAR_VERSION: Final[str] = LavalinkVersion(3, 7, 11) LAVALINK_DOWNLOAD_URL: Final[str] = ( "https://github.com/Cog-Creators/Lavalink-Jars/releases/download/" f"{JAR_VERSION}/"