Skip to content

Commit

Permalink
fix: Missing slots attributes, wrong variable type, duplicate http me…
Browse files Browse the repository at this point in the history
…thods (Pycord-Development#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 <[email protected]>
Signed-off-by: Readeem <[email protected]>

* Update CHANGELOG.md

Co-authored-by: JustaSqu1d <[email protected]>
Signed-off-by: Readeem <[email protected]>

* Update CHANGELOG.md

Co-authored-by: JustaSqu1d <[email protected]>
Signed-off-by: Readeem <[email protected]>

* 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 <[email protected]>

* style(pre-commit): auto fixes from pre-commit.com hooks

---------

Signed-off-by: Readeem <[email protected]>
Signed-off-by: Lala Sabathil <[email protected]>
Signed-off-by: plun1331 <[email protected]>
Co-authored-by: Readeem <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: JustaSqu1d <[email protected]>
Co-authored-by: Lala Sabathil <[email protected]>
Co-authored-by: plun1331 <[email protected]>
  • Loading branch information
6 people authored and baribarton committed Oct 24, 2024
1 parent 6892f40 commit 57abefa
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 32 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
31 changes: 2 additions & 29 deletions discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
22 changes: 20 additions & 2 deletions discord/raw_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -807,7 +817,15 @@ class RawMessagePollVoteEvent(_RawReprMixin):
The raw data sent by the `gateway <https://discord.com/developers/docs/topics/gateway#message-poll-vote-add>`
"""

__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"])
Expand Down
2 changes: 1 addition & 1 deletion discord/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions discord/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 57abefa

Please sign in to comment.