From bbf257d659c02174585029b6052d2b833c12aefb Mon Sep 17 00:00:00 2001 From: Paillat-dev Date: Wed, 10 Jun 2026 17:17:25 +0200 Subject: [PATCH 1/2] fix: Fix `Poll.to_dict` and add better types --- discord/poll.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/discord/poll.py b/discord/poll.py index a6878275b6..8773e39cbe 100644 --- a/discord/poll.py +++ b/discord/poll.py @@ -355,9 +355,9 @@ def __init__( self.duration: int | None = duration self.allow_multiselect: bool = allow_multiselect self.layout_type: PollLayoutType = layout_type - self.results = None - self._expiry = None - self._message = None + self.results: PollResults | None = None + self._expiry: str | None = None + self._message: Message | PartialMessage | None = None @cached_property def expiry(self) -> datetime.datetime | None: @@ -372,8 +372,8 @@ def to_dict(self) -> PollPayload: "allow_multiselect": self.allow_multiselect, "layout_type": self.layout_type.value, } - if self.results: - dict_["results"] = [r.to_dict() for r in self.results] + if self.results is not None: + dict_["results"] = self.results.to_dict() if self._expiry: dict_["expiry"] = self._expiry return dict_ From 720a45650f38f93c5a23fea595f91c21c04236e8 Mon Sep 17 00:00:00 2001 From: Paillat-dev Date: Wed, 10 Jun 2026 17:29:20 +0200 Subject: [PATCH 2/2] docs: CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5173e5795c..3c63e882b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#3231](https://github.com/Pycord-Development/pycord/pull/3231)) - Allow `ForumTag` to be created without an emoji. ([#3245](https://github.com/Pycord-Development/pycord/pull/3245)) +- Fix `TypeError` in `Poll.to_dict` for closed polls. + ([#3261](https://github.com/Pycord-Development/pycord/pull/3261)) ### Deprecated