hollowstrawberry / crab-cogs

Red Discord bot cogs for the Crab friend group
GNU General Public License v3.0
16 stars 3 forks source link

Update gamealert.py #34

Closed DJTOMATO closed 8 months ago

DJTOMATO commented 8 months ago
hollowstrawberry commented 8 months ago

Thank you! What's the advantage of doing timezone like this? I thought the other one worked, to get it to compare datetime with the timezone-aware discord datetime.

DJTOMATO commented 8 months ago
 if alert and (datetime.utcnow().astimezone(timezone.utc) - activity.created_at).total_seconds() > 60 * alert['delay_minutes']:
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 TypeError: can't subtract offset-naive and offset-aware datetimes

As it was before one included the timezone and the other didn't. works on cog reload now, but im waiting for tests +30, 60+90 minutes, etc

hollowstrawberry commented 8 months ago

I think it worked fine before: datetime.now(timezone.utc). I had recently fixed it.

hollowstrawberry commented 8 months ago

It seems to work now though, so no reason to change it back.

DJTOMATO commented 8 months ago

i think I messed up, now doesn't throw errors, but reports as soon as someone opens the app (doing lots of spam), it's not doing the time calculation right =(