From 385da926b4144ea3b05ef6eac16b23a6c8858f09 Mon Sep 17 00:00:00 2001 From: Thorsten Date: Sat, 7 Sep 2024 14:19:02 +0200 Subject: [PATCH] fix bug --- src/distbot/plugins/votepoll.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/distbot/plugins/votepoll.py b/src/distbot/plugins/votepoll.py index 06852d2..3ee0a1f 100644 --- a/src/distbot/plugins/votepoll.py +++ b/src/distbot/plugins/votepoll.py @@ -154,10 +154,11 @@ class VotePoll(Worker): if active_key: return self.get_poll(active_key) - def get_poll(self, key: str): + def get_poll(self, key: str) -> Poll | None: poll_bin = self.db.get(key.encode()) - poll = json.loads(poll_bin.decode("utf-8")) - return Poll.from_json(poll) + if poll_bin: + poll = json.loads(poll_bin.decode("utf-8")) + return Poll.from_json(poll) def persist(self, poll: Poll): self.db.put(poll.key.encode(), poll.to_json().encode()) -- 2.39.2