handling timezones datetimes in the 'after' argument
This commit is contained in:
6
msg.py
6
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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user