Skip to content

Commit 96ef126

Browse files
authored
Merge branch 'master' into unittest
2 parents 99cf7dd + 40fbdbf commit 96ef126

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ These changes are available on the `master` branch, but have not yet been releas
2626
order. ([#1636](https://github.com/Pycord-Development/pycord/pull/1636))
2727
- Support for new thread attributes `total_message_sent` and `is_pinned`.
2828
([#1636](https://github.com/Pycord-Development/pycord/pull/1636))
29+
- Added `bridge_commands` attribute to `ext.bridge.Bot` for access to bridge command
30+
objects. ([#1787](https://github.com/Pycord-Development/pycord/pull/1787))
2931

3032
### Fixed
3133

discord/ext/bridge/bot.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2323
DEALINGS IN THE SOFTWARE.
2424
"""
25+
from __future__ import annotations
26+
2527
from abc import ABC
2628

2729
from discord.interactions import Interaction
@@ -36,6 +38,21 @@
3638

3739

3840
class BotBase(ABC):
41+
_bridge_commands: list[BridgeCommand | BridgeCommandGroup]
42+
43+
@property
44+
def bridge_commands(self) -> list[BridgeCommand | BridgeCommandGroup]:
45+
"""Returns all of the bot's bridge commands."""
46+
47+
if cmds := getattr(self, "_bridge_commands", []):
48+
self._bridge_commands = cmds = []
49+
50+
return cmds
51+
52+
@bridge_commands.setter
53+
def bridge_commands(self, cmds):
54+
self._bridge_commands = cmds
55+
3956
async def get_application_context(
4057
self, interaction: Interaction, cls=None
4158
) -> BridgeApplicationContext:
@@ -56,6 +73,7 @@ def add_bridge_command(self, command: BridgeCommand):
5673
"""
5774
# Ignore the type hinting error here. All subclasses of BotBase pass the type checks.
5875
command.add_to(self) # type: ignore
76+
self._bridge_commands.append(command)
5977

6078
def bridge_command(self, **kwargs):
6179
"""A shortcut decorator that invokes :func:`bridge_command` and adds it to

0 commit comments

Comments
 (0)