From 0ef9aaa8c3bedbff4c964a155ec1c09cd50bb8aa Mon Sep 17 00:00:00 2001 From: osmarks Date: Fri, 30 Oct 2020 12:49:13 +0000 Subject: [PATCH] relative time in reminders for purposes --- src/reminders.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/reminders.py b/src/reminders.py index b6060d4..fa99559 100644 --- a/src/reminders.py +++ b/src/reminders.py @@ -1,6 +1,6 @@ import json import logging -from datetime import datetime +from datetime import datetime, timezone import discord.ext.tasks as tasks import util @@ -23,13 +23,14 @@ def setup(bot): } try: time = util.parse_time(time) + now = datetime.now(tz=timezone.utc) except: await ctx.send(embed=util.error_embed("Invalid time (wrong format/too large/non-integer months or years)")) return await bot.database.execute("INSERT INTO reminders (remind_timestamp, created_timestamp, reminder, expired, extra) VALUES (?, ?, ?, ?, ?)", - (time.timestamp(), util.timestamp(), reminder, 0, util.json_encode(extra_data))) + (time.timestamp(), now.timestamp(), reminder, 0, util.json_encode(extra_data))) await bot.database.commit() - await ctx.send(f"Reminder scheduled for {util.format_time(time)}.") + await ctx.send(f"Reminder scheduled for {util.format_time(time)} ({util.format_timedelta(now, time)}).") async def send_to_channel(info, text): channel = bot.get_channel(info["channel_id"])