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

fix: always cast PartialMessage(able) IDs to int #2406

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -28,6 +28,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2390](https://github.com/Pycord-Development/pycord/pull/2390))
- Fixed `NameError` in some instances of `Interaction`.
([#2402](https://github.com/Pycord-Development/pycord/pull/2402))
- Fixed interactions being ignored due to `PartialMessage(able).id` being of type `str`.
([#2406](https://github.com/Pycord-Development/pycord/pull/2406))

### Changed

Expand Down
2 changes: 1 addition & 1 deletion discord/channel.py
Expand Up @@ -3189,7 +3189,7 @@ def __init__(
):
self._state: ConnectionState = state
self._channel: Object = Object(id=id)
self.id: int = id
self.id: int = int(id)
Copy link
Member

@Dorukyum Dorukyum Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not change the part where the ID is passed in with the wrong type instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose, but shouldn't we guarantee all IDs are int for parity with full channel objects?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we could change both

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The library usually converts before passing in, so I think we should continue that

self.type: ChannelType | None = type

async def _get_channel(self) -> Object:
Expand Down
2 changes: 1 addition & 1 deletion discord/message.py
Expand Up @@ -1923,7 +1923,7 @@ def __init__(self, *, channel: PartialMessageableChannel, id: int):

self.channel: PartialMessageableChannel = channel
self._state: ConnectionState = channel._state
self.id: int = id
self.id: int = int(id)

def _update(self, data) -> None:
# This is used for duck typing purposes.
Expand Down