how to turn message.created_at into a timezone aware datetime with the timezone of utc?

Viewed 48

I am trying to check if a message is older then a day, then I delete it with discord.py, but it returns a error
TypeError: unsupported operand type(s) for -: 'coroutine' and 'datetime.datetime'
My code currently is

    async def _now(self):
    return datetime.now(timezone.utc)

and the check function

    async def _clean_channel(self, ignore = None):
    def check(message: Message):
        if ignore and message.id == ignore.id:
            return False

        return self._now() - message.created_at < timedelta(days=1)

    await self.bump_channel.purge(check=check)

I do not know what causes this error, but I think it is because of timezones in datetime objects

0 Answers
Related