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

[ext.bridge] Permission decorators and invoke function #1642

Merged
merged 23 commits into from
Oct 2, 2022
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ebd3d50
fix: outdated use of bridge methods
Middledot Aug 24, 2022
b719e96
feat: allow BridgeCommand classes to be invokable
Middledot Aug 24, 2022
8ea3dae
feat: globally usable wrap for guild_only
Middledot Aug 24, 2022
a7e2420
Revert "fix: outdated use of bridge methods"
Middledot Sep 16, 2022
ff542e8
feat: actual invoke
Middledot Sep 16, 2022
1ccb346
Merge branch 'Pycord-Development:master' into ext-bridge-dev
Middledot Sep 16, 2022
433101d
fix: it's raining the same validation errors
Middledot Sep 17, 2022
deb6ec0
refactor: cleanup
Middledot Sep 17, 2022
77eb294
fix: only run on slash groups
Middledot Sep 21, 2022
e230f7f
feat: implement bridge.has_permissions
Middledot Sep 21, 2022
ebe95d2
refactor: shortcuts
Middledot Sep 21, 2022
d665aab
chore: docs
Middledot Sep 21, 2022
8f54782
fix: invoke bug
Middledot Sep 21, 2022
cb674d9
refactor: remove comment
Middledot Sep 21, 2022
ba8c89a
Update discord/ext/bridge/core.py
Lulalaby Sep 26, 2022
9a806d9
Merge branch 'master' into ext-bridge-dev
BobDotCom Sep 30, 2022
963674d
feat: add more extensive usage
Middledot Oct 1, 2022
a58d8b0
Merge branch 'master' into ext-bridge-dev
Middledot Oct 1, 2022
a01444a
fix: var assignment error
Middledot Oct 1, 2022
79e4412
Merge branch 'ext-bridge-dev' of https://github.com/Middledot/pycord …
Middledot Oct 1, 2022
5642146
Merge branch 'master' into ext-bridge-dev
Lulalaby Oct 1, 2022
9f7683b
Merge branch 'master' into ext-bridge-dev
BobDotCom Oct 2, 2022
b287741
Update CHANGELOG.md
BobDotCom Oct 2, 2022
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
Next Next commit
fix: outdated use of bridge methods
  • Loading branch information
Middledot committed Aug 24, 2022
commit ebd3d50bd3e750e55e559313a4121bfab6b79c6d
19 changes: 10 additions & 9 deletions discord/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import sys
import types
from typing import (
TYPE_CHECKING,
Any,
Callable,
ClassVar,
Expand All @@ -56,6 +57,10 @@
_BaseCommand,
)

if TYPE_CHECKING:
from .ext.bridge import BridgeCommand


__all__ = (
"CogMeta",
"Cog",
Expand Down Expand Up @@ -195,20 +200,16 @@ def __new__(cls: Type[CogMeta], *args: Any, **kwargs: Any) -> CogMeta:
raise TypeError(no_bot_cog.format(base, elem))
commands[elem] = value

try:
# a test to see if this value is a BridgeCommand
getattr(value, "add_to")

# a test to see if this value is a BridgeCommand
if hasattr(value, "add_to"):
value: BridgeCommand
if is_static_method:
raise TypeError(f"Command in method {base}.{elem!r} must not be staticmethod.")
if elem.startswith(("cog_", "bot_")):
raise TypeError(no_bot_cog.format(base, elem))

commands[f"ext_{elem}"] = value.get_ext_command()
commands[f"application_{elem}"] = value.get_application_command()
except AttributeError:
# we are confident that the value is not a Bridge Command
pass
commands[f"ext_{elem}"] = value.ext_variant
commands[f"application_{elem}"] = value.slash_variant

if inspect.iscoroutinefunction(value):
try:
Expand Down