Skip to content

Commit

Permalink
Merge branch 'master' into patch-31
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Nov 20, 2022
2 parents ede4fbe + 40fbdbf commit 5bd30ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 to `ext.bridge.Bot` for access to bridge command
objects. ([#1787](https://github.com/Pycord-Development/pycord/pull/1787))
- Updated `Guild.features` to include new and previously missing features.
([#1788](https://github.com/Pycord-Development/pycord/pull/1788))

Expand Down
18 changes: 18 additions & 0 deletions discord/ext/bridge/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
from __future__ import annotations

from abc import ABC

from discord.interactions import Interaction
Expand All @@ -36,6 +38,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:
Expand All @@ -56,6 +73,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
Expand Down

0 comments on commit 5bd30ff

Please sign in to comment.