simple-modlogs icon indicating copy to clipboard operation
simple-modlogs copied to clipboard

DateTime error

Open IIDarkNessYT opened this issue 2 years ago • 1 comments

Problem code:

@client.event
async def on_member_ban(gld, usr):
    await asyncio.sleep(0.5)
    found_entry = None
    async for entry in gld.audit_logs(limit = 50, action = discord.AuditLogAction.ban, after = datetime.datetime.utcnow() - datetime.timedelta(seconds = 15), oldest_first = False):
        if entry.created_at < datetime.datetime.utcnow() - datetime.timedelta(seconds = 10):
            continue
        if entry.target.id == usr.id:
            found_entry = entry
            break
    if not found_entry:
        return
    await post_modlog(guild = gld, type = "BAN", user = found_entry.user, target = usr, reason = found_entry.reason)

@client.event
async def on_member_unban(gld, usr):
    await asyncio.sleep(0.5)
    found_entry = None
    async for entry in gld.audit_logs(limit = 50, action = discord.AuditLogAction.unban, after = datetime.datetime.utcnow() - datetime.timedelta(seconds = 15), oldest_first = False):
        if entry.created_at < datetime.datetime.utcnow() - datetime.timedelta(seconds = 10):
            continue
        if entry.target.id == usr.id:
            found_entry = entry
            break
    if not found_entry:
        return
    await post_modlog(guild = gld, type = "UNBAN", user = found_entry.user, target = usr, reason = found_entry.reason)

`

Error: 2022-06-23 14:12:56 ERROR discord.client Ignoring exception in on_member_ban Traceback (most recent call last): File "/home/darkness/Рабочий стол/discord-bot/discord.py/discord/client.py", line 456, in _run_event await coro(*args, **kwargs) File "/home/darkness/Рабочий стол/discord-bot/python/MCPL - System/src/bot/core.py", line 671, in on_member_ban if entry.created_at < datetime.datetime.utcnow() - datetime.timedelta(seconds = 10): TypeError: can't compare offset-naive and offset-aware datetimes 2022-06-23 14:13:24 ERROR discord.client Ignoring exception in on_member_unban Traceback (most recent call last): File "/home/darkness/Рабочий стол/discord-bot/discord.py/discord/client.py", line 456, in _run_event await coro(*args, **kwargs) File "/home/darkness/Рабочий стол/discord-bot/python/MCPL - System/src/bot/core.py", line 685, in on_member_unban if entry.created_at < datetime.datetime.utcnow() - datetime.timedelta(seconds = 10): TypeError: can't compare offset-naive and offset-aware datetimes

IIDarkNessYT avatar Jun 23 '22 11:06 IIDarkNessYT

yes, the software is deprecated

nerrixde avatar Jul 07 '22 08:07 nerrixde