Skip to content

Commit

Permalink
Update reactpoll.py
Browse files Browse the repository at this point in the history
Fix for flapjax#154 - Check for NoneType and strip timezone from non-Nonetype before comparing.
  • Loading branch information
ThatOneRoadie authored Dec 5, 2023
1 parent eef5e9c commit a8d6c7b
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions reactpoll/reactpoll.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import discord
import asyncio
from datetime import datetime, timedelta
import pytz
import logging
import re

Expand Down Expand Up @@ -100,17 +101,18 @@ async def poll_closer(self):
poll.end_time = datetime.utcfromtimestamp(poll.end_time)
if isinstance(poll.end_time, int):
poll.end_time = datetime.utcfromtimestamp(poll.end_time)
if poll.end_time and poll.end_time <= now_time:
log.debug("ending poll")
try:
await poll.close_poll()
except Exception:
pass
# probs a better way to do this
to_remove.append(m_id)
# also need to delete from config
guild = discord.Object(id=g_id)
await self.delete_poll(guild, poll)
if poll.end_time is not None:
if poll.end_time.replace(tzinfo=None) and poll.end_time.replace(tzinfo=None) <= now_time.replace(tzinfo=None):
log.debug("ending poll")
try:
await poll.close_poll()
except Exception:
pass
# probs a better way to do this
to_remove.append(m_id)
# also need to delete from config
guild = discord.Object(id=g_id)
await self.delete_poll(guild, poll)
if count // 10:
count = 0
await self.store_poll(poll)
Expand Down

0 comments on commit a8d6c7b

Please sign in to comment.