From 664b5cbaf0fe667e234c9e7924c4205868ffe5f1 Mon Sep 17 00:00:00 2001 From: Middledot Date: Thu, 17 Nov 2022 18:18:32 -0500 Subject: [PATCH 1/5] feat(ext.bridge): add bridge_commands attribute --- discord/ext/bridge/bot.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/discord/ext/bridge/bot.py b/discord/ext/bridge/bot.py index 3db78d5f42..411003ac8e 100644 --- a/discord/ext/bridge/bot.py +++ b/discord/ext/bridge/bot.py @@ -22,8 +22,9 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from abc import ABC +from __future__ import annotations +from abc import ABC from discord.interactions import Interaction from discord.message import Message @@ -36,6 +37,21 @@ class BotBase(ABC): + _bridge_commands: list[BridgeCommand | BridgeCommandGroup] + + @property + def bridge_commands(self) -> list[BridgeCommand | BridgeCommandGroup]: + """Returns all of the bot's bridge commands.""" + + if cmds := getattr(self, "_bridge_commands", []): + self._bridge_commands = cmds = [] + + return cmds + + @bridge_commands.setter + def bridge_commands(self, cmds): + self._bridge_commands = cmds + async def get_application_context( self, interaction: Interaction, cls=None ) -> BridgeApplicationContext: @@ -56,6 +72,7 @@ def add_bridge_command(self, command: BridgeCommand): """ # Ignore the type hinting error here. All subclasses of BotBase pass the type checks. command.add_to(self) # type: ignore + self._bridge_commands.append(command) def bridge_command(self, **kwargs): """A shortcut decorator that invokes :func:`bridge_command` and adds it to From 4d7f0030c6c42417b5e91d1d19ebb48e92bfa8bc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 17 Nov 2022 23:28:50 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- discord/ext/bridge/bot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/discord/ext/bridge/bot.py b/discord/ext/bridge/bot.py index 411003ac8e..42b3ff2540 100644 --- a/discord/ext/bridge/bot.py +++ b/discord/ext/bridge/bot.py @@ -25,6 +25,7 @@ from __future__ import annotations from abc import ABC + from discord.interactions import Interaction from discord.message import Message From fd9b3c2a2991542c87b856acd1fcab979b3a4d80 Mon Sep 17 00:00:00 2001 From: Middledot Date: Sat, 19 Nov 2022 07:52:35 -0500 Subject: [PATCH 3/5] chore(changelog): add changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e131764b4..16f64f576b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ These changes are available on the `master` branch, but have not yet been releas order. ([#1636](https://github.com/Pycord-Development/pycord/pull/1636)) - Support for new thread attributes `total_message_sent` and `is_pinned`. ([#1636](https://github.com/Pycord-Development/pycord/pull/1636)) +- Added `bridge_commands` attribute for access to bridge command objects. + ([#1787](https://github.com/Pycord-Development/pycord/pull/1787)) ### Fixed From 3fca441488f3ba6b3e89b85e99f8160f941392f2 Mon Sep 17 00:00:00 2001 From: Middledot <78228142+Middledot@users.noreply.github.com> Date: Sat, 19 Nov 2022 09:51:48 -0500 Subject: [PATCH 4/5] chore(changelog): clarify Co-authored-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 528aeaae29..f2c93062da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ These changes are available on the `master` branch, but have not yet been releas order. ([#1636](https://github.com/Pycord-Development/pycord/pull/1636)) - Support for new thread attributes `total_message_sent` and `is_pinned`. ([#1636](https://github.com/Pycord-Development/pycord/pull/1636)) -- Added `bridge_commands` attribute for access to bridge command objects. +- Added `bridge_commands` attribute to `ext.bridge.Bot` for access to bridge command objects. ([#1787](https://github.com/Pycord-Development/pycord/pull/1787)) ### Fixed From 09faf1e0077d2ddf412ae0169c045f3730ca901e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 19 Nov 2022 14:52:29 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2c93062da..5b61e6a663 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,8 +26,8 @@ These changes are available on the `master` branch, but have not yet been releas order. ([#1636](https://github.com/Pycord-Development/pycord/pull/1636)) - Support for new thread attributes `total_message_sent` and `is_pinned`. ([#1636](https://github.com/Pycord-Development/pycord/pull/1636)) -- Added `bridge_commands` attribute to `ext.bridge.Bot` for access to bridge command objects. - ([#1787](https://github.com/Pycord-Development/pycord/pull/1787)) +- Added `bridge_commands` attribute to `ext.bridge.Bot` for access to bridge command + objects. ([#1787](https://github.com/Pycord-Development/pycord/pull/1787)) ### Fixed