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 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_