From f51057b41ad21e77d874eba31af8fdcd8e4ad94b Mon Sep 17 00:00:00 2001 From: plun1331 Date: Wed, 4 Sep 2024 02:30:48 -0700 Subject: [PATCH] fix: allow PartialMessage to have PartialMessageable as a channel (#2568) * fix: allow PartialMessage to have PartialMessageable as a channel Signed-off-by: plun1331 * Update CHANGELOG.md Signed-off-by: plun1331 * style(pre-commit): auto fixes from pre-commit.com hooks --------- Signed-off-by: plun1331 Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- CHANGELOG.md | 2 ++ discord/message.py | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef3e6995ba..80929555d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#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)) +- Fixed `PartialMessage`s causing errors when created from `PartialMessageable`. + ([#2568](https://github.com/Pycord-Development/pycord/pull/2500)) ## [2.6.0] - 2024-07-09 diff --git a/discord/message.py b/discord/message.py index 37ffd86f53..56d1cec968 100644 --- a/discord/message.py +++ b/discord/message.py @@ -42,6 +42,7 @@ from urllib.parse import parse_qs, urlparse from . import utils +from .channel import PartialMessageable from .components import _component_factory from .embeds import Embed from .emoji import Emoji @@ -2001,6 +2002,7 @@ class PartialMessage(Hashable): - :meth:`DMChannel.get_partial_message` - :meth:`VoiceChannel.get_partial_message` - :meth:`StageChannel.get_partial_message` + - :meth:`PartialMessageable.get_partial_message` Note that this class is trimmed down and has no rich attributes. @@ -2022,7 +2024,7 @@ class PartialMessage(Hashable): Attributes ---------- - channel: Union[:class:`TextChannel`, :class:`Thread`, :class:`DMChannel`, :class:`VoiceChannel`, :class:`StageChannel`] + channel: Union[:class:`TextChannel`, :class:`Thread`, :class:`DMChannel`, :class:`VoiceChannel`, :class:`StageChannel`, :class:`PartialMessageable`] The channel associated with this partial message. id: :class:`int` The message ID. @@ -2053,9 +2055,9 @@ def __init__(self, *, channel: PartialMessageableChannel, id: int): ChannelType.news_thread, ChannelType.public_thread, ChannelType.private_thread, - ): + ) and not isinstance(channel, PartialMessageable): raise TypeError( - "Expected TextChannel, VoiceChannel, StageChannel, DMChannel or Thread not" + "Expected TextChannel, VoiceChannel, StageChannel, DMChannel, Thread or PartialMessageable not" f" {type(channel)!r}" )