GrafeasGroup / buttercup

Our personal assistant in Discord
MIT License
5 stars 2 forks source link

Fix `/leaderboard` when `after` is `None` but `before` is given #141

Closed TimJentzsch closed 2 years ago

TimJentzsch commented 2 years ago

Stack trace:

Dec 25 20:27:02 localhost python[4381]: 2021-12-25 20:27:02,809 | WARNING |              /u/Tim3303 | leaderboard | [3a6e2248-20ac-444c-9c27-22b457518e08] TypeError: can't subtract offset-naive and offset-aware datetimes
Dec 25 20:27:02 localhost python[4381]: Traceback (most recent call last):
Dec 25 20:27:02 localhost python[4381]:   File "/data/buttercup/.venv/lib/python3.9/site-packages/discord_slash/client.py", line 872, in invoke_command
Dec 25 20:27:02 localhost python[4381]:     await func.invoke(ctx, args)
Dec 25 20:27:02 localhost python[4381]:   File "/data/buttercup/.venv/lib/python3.9/site-packages/discord_slash/model.py", line 291, in invoke
Dec 25 20:27:02 localhost python[4381]:     return await coro
Dec 25 20:27:02 localhost python[4381]:   File "/data/buttercup/buttercup/cogs/leaderboard.py", line 166, in leaderboard
Dec 25 20:27:02 localhost python[4381]:     time_frame = format_leaderboard_timeframe(after_time, before_time)
Dec 25 20:27:02 localhost python[4381]:   File "/data/buttercup/buttercup/cogs/leaderboard.py", line 45, in format_leaderboard_timeframe
Dec 25 20:27:02 localhost python[4381]:     delta = (before or datetime.now(tz=pytz.utc)) - (after or datetime(2017, 4, 1))
Dec 25 20:27:02 localhost python[4381]: TypeError: can't subtract offset-naive and offset-aware datetimes
Dec 25 20:27:02 localhost python[4381]: 2021-12-25 20:27:02,809 | WARNING | [3a6e2248-20ac-444c-9c27-22b457518e08] TypeError: can't subtract offset-naive and offset-aware datetimes
Dec 25 20:27:02 localhost python[4381]: Traceback (most recent call last):
Dec 25 20:27:02 localhost python[4381]:   File "/data/buttercup/.venv/lib/python3.9/site-packages/discord_slash/client.py", line 872, in invoke_command
Dec 25 20:27:02 localhost python[4381]:     await func.invoke(ctx, args)
Dec 25 20:27:02 localhost python[4381]:   File "/data/buttercup/.venv/lib/python3.9/site-packages/discord_slash/model.py", line 291, in invoke
Dec 25 20:27:02 localhost python[4381]:     return await coro
Dec 25 20:27:02 localhost python[4381]:   File "/data/buttercup/buttercup/cogs/leaderboard.py", line 166, in leaderboard
Dec 25 20:27:02 localhost python[4381]:     time_frame = format_leaderboard_timeframe(after_time, before_time)
Dec 25 20:27:02 localhost python[4381]:   File "/data/buttercup/buttercup/cogs/leaderboard.py", line 45, in format_leaderboard_timeframe
Dec 25 20:27:02 localhost python[4381]:     delta = (before or datetime.now(tz=pytz.utc)) - (after or datetime(2017, 4, 1))
Dec 25 20:27:02 localhost python[4381]: TypeError: can't subtract offset-naive and offset-aware datetimes