Skip to content

Commit 33ead34

Browse files
authored
Merge branch 'master' into search
Signed-off-by: Nelo <41271523+NeloBlivion@users.noreply.github.com>
2 parents e1492c5 + ec7419c commit 33ead34

12 files changed

Lines changed: 358 additions & 41 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
git fetch origin
130130
if ! git show-ref --verify --quiet refs/heads/$VERSION_BRANCH; then
131131
git checkout -b $VERSION_BRANCH
132-
git push origin $VERSION_BRANCH
132+
git push origin $VERSION_BRANCH -f
133133
fi
134134
git checkout $VERSION_BRANCH
135135
- name: "Setup Python"

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ These changes are available on the `master` branch, but have not yet been releas
1818
### Changed
1919

2020
- Changed that `read_only` team members aren't considered as owner.
21+
- `read_only` team members aren't considered as owners anymore when checking for app
22+
ownership permissions.
2123

2224
### Fixed
2325

@@ -32,6 +34,10 @@ These changes are available on the `master` branch, but have not yet been releas
3234
- Fixed incorrect type hints for `MessagePinIterator`.
3335
([#3178](https://github.com/Pycord-Development/pycord/pull/3178))
3436
- Fixed team `permissions` keyerror by replacing deprecated permissions with `role`.
37+
- Fixed a `KeyError` when fetching an app's information or checking for app ownership
38+
with `is_owner`.
39+
- Fixed certain scenarios where received components could crash the app.
40+
([#3059](https://github.com/Pycord-Development/pycord/pull/3059))
3541

3642
### Deprecated
3743

discord/abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,7 @@ async def send(
17351735
if view.is_dispatchable():
17361736
state.store_view(view, ret.id)
17371737
view.message = ret
1738-
view.refresh(ret.components)
1738+
view._refresh(ret.components)
17391739

17401740
if delete_after is not None:
17411741
await ret.delete(delay=delete_after)

discord/bot.py

Lines changed: 150 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
UserCommand,
5858
command,
5959
)
60-
from .enums import IntegrationType, InteractionContextType, InteractionType
60+
from .enums import IntegrationType, InteractionContextType, InteractionType, TeamRole
6161
from .errors import CheckFailure, DiscordException
6262
from .interactions import Interaction
6363
from .shard import AutoShardedClient
@@ -66,7 +66,13 @@
6666
from .utils import MISSING, async_all, find, get
6767

6868
if TYPE_CHECKING:
69+
from typing_extensions import Never
70+
71+
from .cog import Cog
72+
from .commands import Option
73+
from .ext.commands import Cooldown
6974
from .member import Member
75+
from .permissions import Permissions
7076

7177
C = TypeVar("C", bound=MessageCommand | SlashCommand | UserCommand)
7278
CoroFunc = Callable[..., Coroutine[Any, Any, Any]]
@@ -909,7 +915,26 @@ async def callback() -> None:
909915
if not autocomplete_task.done():
910916
autocomplete_task.cancel()
911917

912-
def slash_command(self, **kwargs):
918+
def slash_command(
919+
self,
920+
*,
921+
checks: list[Callable[[ApplicationContext], bool]] | None = MISSING,
922+
cog: Cog | None = MISSING,
923+
contexts: set[InteractionContextType] | None = MISSING,
924+
cooldown: Cooldown | None = MISSING,
925+
default_member_permissions: Permissions | None = MISSING,
926+
description: str | None = MISSING,
927+
description_localizations: dict[str, str] | None = MISSING,
928+
guild_ids: list[int] | None = MISSING,
929+
guild_only: bool | None = MISSING,
930+
integration_types: set[IntegrationType] | None = MISSING,
931+
name: str | None = MISSING,
932+
name_localizations: dict[str, str] | None = MISSING,
933+
nsfw: bool | None = MISSING,
934+
options: list[Option] | None = MISSING,
935+
parent: SlashCommandGroup | None = MISSING,
936+
**kwargs: Never,
937+
) -> Callable[..., SlashCommand]:
913938
"""A shortcut decorator for adding a slash command to the bot.
914939
This is equivalent to using :meth:`application_command`, providing
915940
the :class:`SlashCommand` class.
@@ -922,9 +947,42 @@ def slash_command(self, **kwargs):
922947
A decorator that converts the provided function into a :class:`.SlashCommand`,
923948
adds it to the bot, and returns it.
924949
"""
925-
return self.application_command(cls=SlashCommand, **kwargs)
950+
return self.application_command(
951+
cls=SlashCommand,
952+
checks=checks,
953+
cog=cog,
954+
contexts=contexts,
955+
cooldown=cooldown,
956+
default_member_permissions=default_member_permissions,
957+
description=description,
958+
description_localizations=description_localizations,
959+
guild_ids=guild_ids,
960+
guild_only=guild_only,
961+
integration_types=integration_types,
962+
name=name,
963+
name_localizations=name_localizations,
964+
nsfw=nsfw,
965+
options=options,
966+
parent=parent,
967+
**kwargs,
968+
)
926969

927-
def user_command(self, **kwargs):
970+
def user_command(
971+
self,
972+
*,
973+
checks: list[Callable[[ApplicationContext], bool]] | None = MISSING,
974+
cog: Cog | None = MISSING,
975+
contexts: set[InteractionContextType] | None = MISSING,
976+
cooldown: Cooldown | None = MISSING,
977+
default_member_permissions: Permissions | None = MISSING,
978+
guild_ids: list[int] | None = MISSING,
979+
guild_only: bool | None = MISSING,
980+
integration_types: set[IntegrationType] | None = MISSING,
981+
name: str | None = MISSING,
982+
name_localizations: dict[str, str] | None = MISSING,
983+
nsfw: bool | None = MISSING,
984+
**kwargs: Never,
985+
) -> Callable[..., UserCommand]:
928986
"""A shortcut decorator for adding a user command to the bot.
929987
This is equivalent to using :meth:`application_command`, providing
930988
the :class:`UserCommand` class.
@@ -937,9 +995,38 @@ def user_command(self, **kwargs):
937995
A decorator that converts the provided function into a :class:`.UserCommand`,
938996
adds it to the bot, and returns it.
939997
"""
940-
return self.application_command(cls=UserCommand, **kwargs)
998+
return self.application_command(
999+
cls=UserCommand,
1000+
checks=checks,
1001+
cog=cog,
1002+
contexts=contexts,
1003+
cooldown=cooldown,
1004+
default_member_permissions=default_member_permissions,
1005+
guild_ids=guild_ids,
1006+
guild_only=guild_only,
1007+
integration_types=integration_types,
1008+
name=name,
1009+
name_localizations=name_localizations,
1010+
nsfw=nsfw,
1011+
**kwargs,
1012+
)
9411013

942-
def message_command(self, **kwargs):
1014+
def message_command(
1015+
self,
1016+
*,
1017+
checks: list[Callable[[ApplicationContext], bool]] | None = MISSING,
1018+
cog: Cog | None = MISSING,
1019+
contexts: set[InteractionContextType] | None = MISSING,
1020+
cooldown: Cooldown | None = MISSING,
1021+
default_member_permissions: Permissions | None = MISSING,
1022+
guild_ids: list[int] | None = MISSING,
1023+
guild_only: bool | None = MISSING,
1024+
integration_types: set[IntegrationType] | None = MISSING,
1025+
name: str | None = MISSING,
1026+
name_localizations: dict[str, str] | None = MISSING,
1027+
nsfw: bool | None = MISSING,
1028+
**kwargs: Never,
1029+
) -> Callable[..., MessageCommand]:
9431030
"""A shortcut decorator for adding a message command to the bot.
9441031
This is equivalent to using :meth:`application_command`, providing
9451032
the :class:`MessageCommand` class.
@@ -952,9 +1039,43 @@ def message_command(self, **kwargs):
9521039
A decorator that converts the provided function into a :class:`.MessageCommand`,
9531040
adds it to the bot, and returns it.
9541041
"""
955-
return self.application_command(cls=MessageCommand, **kwargs)
1042+
return self.application_command(
1043+
cls=MessageCommand,
1044+
checks=checks,
1045+
cog=cog,
1046+
contexts=contexts,
1047+
cooldown=cooldown,
1048+
default_member_permissions=default_member_permissions,
1049+
guild_ids=guild_ids,
1050+
guild_only=guild_only,
1051+
integration_types=integration_types,
1052+
name=name,
1053+
name_localizations=name_localizations,
1054+
nsfw=nsfw,
1055+
**kwargs,
1056+
)
9561057

957-
def application_command(self, cls: type[C] = SlashCommand, **kwargs):
1058+
def application_command(
1059+
self,
1060+
*,
1061+
cls: type[C] = SlashCommand,
1062+
checks: list[Callable[[ApplicationContext], bool]] | None = MISSING,
1063+
cog: Cog | None = MISSING,
1064+
contexts: set[InteractionContextType] | None = MISSING,
1065+
cooldown: Cooldown | None = MISSING,
1066+
default_member_permissions: Permissions | None = MISSING,
1067+
description: str | None = MISSING,
1068+
description_localizations: dict[str, str] | None = MISSING,
1069+
guild_ids: list[int] | None = MISSING,
1070+
guild_only: bool | None = MISSING,
1071+
integration_types: set[IntegrationType] | None = MISSING,
1072+
name: str | None = MISSING,
1073+
name_localizations: dict[str, str] | None = MISSING,
1074+
nsfw: bool | None = MISSING,
1075+
options: list[Option] | None = MISSING,
1076+
parent: SlashCommandGroup | None = MISSING,
1077+
**kwargs: Any,
1078+
) -> Callable[..., C]:
9581079
"""A shortcut decorator that converts the provided function into
9591080
an application command via :func:`command` and adds it to
9601081
the internal command list via :meth:`~.Bot.add_application_command`.
@@ -976,6 +1097,26 @@ class be provided, it must be a subclass of either
9761097
adds it to the bot, and returns it.
9771098
"""
9781099

1100+
params = {
1101+
"checks": checks,
1102+
"cog": cog,
1103+
"contexts": contexts,
1104+
"cooldown": cooldown,
1105+
"default_member_permissions": default_member_permissions,
1106+
"description": description,
1107+
"description_localizations": description_localizations,
1108+
"guild_ids": guild_ids,
1109+
"guild_only": guild_only,
1110+
"integration_types": integration_types,
1111+
"name": name,
1112+
"name_localizations": name_localizations,
1113+
"nsfw": nsfw,
1114+
"options": options,
1115+
"parent": parent,
1116+
**kwargs,
1117+
}
1118+
kwargs = {k: v for k, v in params.items() if v is not MISSING}
1119+
9791120
def decorator(func) -> C:
9801121
result = command(cls=cls, **kwargs)(func)
9811122
self.add_application_command(result)
@@ -1467,7 +1608,7 @@ async def is_owner(self, user: User | Member) -> bool:
14671608
app = await self.application_info() # type: ignore
14681609
if app.team:
14691610
self.owner_ids = ids = {
1470-
m.id for m in app.team.members if m.role != "read_only"
1611+
m.id for m in app.team.members if m.role is not TeamRole.read_only
14711612
}
14721613
return user.id in ids
14731614
else:

0 commit comments

Comments
 (0)