From e51a7509c6c43c29b99de499a293489bb64b7bb0 Mon Sep 17 00:00:00 2001 From: flifloo Date: Thu, 28 May 2020 17:44:22 +0200 Subject: [PATCH] Fix Task creation date --- db/Task.py | 6 ++++-- extensions/reminders.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/db/Task.py b/db/Task.py index b39c7df..4c06d0d 100644 --- a/db/Task.py +++ b/db/Task.py @@ -10,10 +10,12 @@ class Task(Base): user = Column(BigInteger, nullable=False) channel = Column(BigInteger, nullable=False) date = Column(DateTime, nullable=False) - creation_date = Column(DateTime, default=datetime.now()) + creation_date = Column(DateTime, nullable=False, default=datetime.now()) - def __init__(self, message: str, user: int, channel: int, date: datetime): + def __init__(self, message: str, user: int, channel: int, date: datetime, creation_date: datetime = None): self.message = message self.user = user self.channel = channel self.date = date + if creation_date: + self.creation_date = creation_date diff --git a/extensions/reminders.py b/extensions/reminders.py index d55e58f..a3f4d28 100644 --- a/extensions/reminders.py +++ b/extensions/reminders.py @@ -49,7 +49,7 @@ class Reminders(commands.Cog): time = time_pars(time) now = datetime.now() s = db.Session() - s.add(db.Task(message, ctx.author.id, ctx.channel.id, now + time)) + s.add(db.Task(message, ctx.author.id, ctx.channel.id, now + time, ctx.message.created_at)) s.commit() s.close()