From 57abefa58c7dbd4de3854d96d10bc27d152976b7 Mon Sep 17 00:00:00 2001 From: Readeem <99687127+Readeem@users.noreply.github.com> Date: Thu, 29 Aug 2024 21:50:31 +0300 Subject: [PATCH] fix: Missing slots attributes, wrong variable type, duplicate http methods (#2500) * remove duplicates, fix unused parameter * polls state storage typehint fix * fix RawReactionClearEmojiEvent __slots__ * fix RawMessagePollVoteEvent __slots__ * fix ForumChannel.default_sort_order type the value were actually int instead of SortOrder enum * style(pre-commit): auto fixes from pre-commit.com hooks * changelog * style(pre-commit): auto fixes from pre-commit.com hooks * Update CHANGELOG.md Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com> Signed-off-by: Readeem <99687127+Readeem@users.noreply.github.com> * Update CHANGELOG.md Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com> Signed-off-by: Readeem <99687127+Readeem@users.noreply.github.com> * Update CHANGELOG.md Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com> Signed-off-by: Readeem <99687127+Readeem@users.noreply.github.com> * style(pre-commit): auto fixes from pre-commit.com hooks * style(pre-commit): auto fixes from pre-commit.com hooks * Apply suggestions from code review Signed-off-by: plun1331 * style(pre-commit): auto fixes from pre-commit.com hooks --------- Signed-off-by: Readeem <99687127+Readeem@users.noreply.github.com> Signed-off-by: Lala Sabathil Signed-off-by: plun1331 Co-authored-by: Readeem Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com> Co-authored-by: Lala Sabathil Co-authored-by: plun1331 --- CHANGELOG.md | 13 +++++++++++++ discord/channel.py | 3 +++ discord/http.py | 31 ++----------------------------- discord/raw_models.py | 22 ++++++++++++++++++++-- discord/state.py | 2 +- discord/utils.py | 1 + 6 files changed, 40 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04eace050e..ee6a54ee88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,19 @@ These changes are available on the `master` branch, but have not yet been releas - Fixed `EntitlementIterator` behavior with `limit > 100`. ([#2555](https://github.com/Pycord-Development/pycord/pull/2555)) +### Fixed + +- Fixed missing `stacklevel` parameter in `warn_deprecated` function call inside + `@utils.deprecated`. ([#2500](https://github.com/Pycord-Development/pycord/pull/2500)) +- Fixed the typehint in `ConnectionState._polls` to reflect actual behavior, changing it + from `Guild` to `Poll`. + ([#2500](https://github.com/Pycord-Development/pycord/pull/2500)) +- Fixed missing `__slots__` attributes in `RawReactionClearEmojiEvent` and + `RawMessagePollVoteEvent`. + ([#2500](https://github.com/Pycord-Development/pycord/pull/2500)) +- Fixed the type of `ForumChannel.default_sort_order`, changing it from `int` to + `SortOrder`. ([#2500](https://github.com/Pycord-Development/pycord/pull/2500)) + ## [2.6.0] - 2024-07-09 ### Added diff --git a/discord/channel.py b/discord/channel.py index 7608e1757d..27230a380f 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -1036,6 +1036,9 @@ def _update(self, guild: Guild, data: ForumChannelPayload) -> None: for tag in (data.get("available_tags") or []) ] self.default_sort_order: SortOrder | None = data.get("default_sort_order", None) + if self.default_sort_order is not None: + self.default_sort_order = try_enum(SortOrder, self.default_sort_order) + reaction_emoji_ctx: dict = data.get("default_reaction_emoji") if reaction_emoji_ctx is not None: emoji_name = reaction_emoji_ctx.get("emoji_name") diff --git a/discord/http.py b/discord/http.py index 7813d20a23..f42bcdc233 100644 --- a/discord/http.py +++ b/discord/http.py @@ -2592,35 +2592,6 @@ def bulk_upsert_guild_commands( ) return self.request(r, json=payload) - # Application commands (permissions) - - def get_command_permissions( - self, - application_id: Snowflake, - guild_id: Snowflake, - command_id: Snowflake, - ) -> Response[interactions.GuildApplicationCommandPermissions]: - r = Route( - "GET", - "/applications/{application_id}/guilds/{guild_id}/commands/{command_id}/permissions", - application_id=application_id, - guild_id=guild_id, - ) - return self.request(r) - - def get_guild_command_permissions( - self, - application_id: Snowflake, - guild_id: Snowflake, - ) -> Response[list[interactions.GuildApplicationCommandPermissions]]: - r = Route( - "GET", - "/applications/{application_id}/guilds/{guild_id}/commands/permissions", - application_id=application_id, - guild_id=guild_id, - ) - return self.request(r) - # Guild Automod Rules def get_auto_moderation_rules( @@ -2858,6 +2829,8 @@ def delete_followup_message( ) return self.request(r) + # Application commands (permissions) + def get_guild_application_command_permissions( self, application_id: Snowflake, diff --git a/discord/raw_models.py b/discord/raw_models.py index e59507dd48..a2881839a6 100644 --- a/discord/raw_models.py +++ b/discord/raw_models.py @@ -327,7 +327,17 @@ class RawReactionClearEmojiEvent(_RawReprMixin): .. versionadded:: 2.5 """ - __slots__ = ("message_id", "channel_id", "guild_id", "emoji", "burst", "data") + __slots__ = ( + "message_id", + "channel_id", + "guild_id", + "emoji", + "burst", + "data", + "burst_colours", + "burst_colors", + "type", + ) def __init__(self, data: ReactionClearEmojiEvent, emoji: PartialEmoji) -> None: self.emoji: PartialEmoji = emoji @@ -807,7 +817,15 @@ class RawMessagePollVoteEvent(_RawReprMixin): The raw data sent by the `gateway ` """ - __slots__ = ("user_id", "message_id", "channel_id", "guild_id", "data", "added") + __slots__ = ( + "user_id", + "message_id", + "answer_id", + "channel_id", + "guild_id", + "data", + "added", + ) def __init__(self, data: MessagePollVoteEvent, added: bool) -> None: self.user_id: int = int(data["user_id"]) diff --git a/discord/state.py b/discord/state.py index c8d8d4dced..4170d33fef 100644 --- a/discord/state.py +++ b/discord/state.py @@ -276,7 +276,7 @@ def clear(self, *, views: bool = True) -> None: self._emojis: dict[int, Emoji] = {} self._stickers: dict[int, GuildSticker] = {} self._guilds: dict[int, Guild] = {} - self._polls: dict[int, Guild] = {} + self._polls: dict[int, Poll] = {} if views: self._view_store: ViewStore = ViewStore(self) self._modal_store: ModalStore = ModalStore(self) diff --git a/discord/utils.py b/discord/utils.py index b95678a1c4..9f01f53e71 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -377,6 +377,7 @@ def decorated(*args: P.args, **kwargs: P.kwargs) -> T: since=since, removed=removed, reference=reference, + stacklevel=stacklevel, ) return func(*args, **kwargs)