From 5776684b2096d55fea3eb9e431655bcedff79040 Mon Sep 17 00:00:00 2001 From: jsl12 Date: Tue, 10 Aug 2021 14:18:17 -0500 Subject: [PATCH] handling timezones datetimes in the 'after' argument --- msg.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/msg.py b/msg.py index 362103b..8adba11 100644 --- a/msg.py +++ b/msg.py @@ -15,7 +15,11 @@ async def message_gen(client: discord.Client, limit=20, days: int = 90, **kwargs channels = filter(lambda c: c.category.name != 'Archive', channels) for channel in channels: print(f'{channel.category.name} #{channel.name}') - async for msg in channel.history(limit=limit, after=(datetime.today() - timedelta(days=days)), **kwargs): + if 'after' not in kwargs: + kwargs['after'] = (datetime.today() - timedelta(days=days)) + elif isinstance((after := kwargs.get('after', None)), datetime): + kwargs['after'] = after.replace(tzinfo=None) + async for msg in channel.history(limit=limit, **kwargs): yield msg