diff --git a/cogs/school.py b/cogs/school.py index a2ca9b9..fd12d13 100644 --- a/cogs/school.py +++ b/cogs/school.py @@ -61,8 +61,7 @@ class School(commands.Cog): # Add all the user's courses def customizeSchedule(self, ctx, year, semester): - with open("files/schedules/{}{}.json".format(year, semester), "r") as fp: - schedule = json.load(fp) + schedule = les.getSchedule(semester, year) member = self.client.get_guild(int(constants.CallOfCode)).get_member(ctx.author.id) for role in member.roles: diff --git a/cogs/tasks.py b/cogs/tasks.py index 2acccb3..32175af 100644 --- a/cogs/tasks.py +++ b/cogs/tasks.py @@ -5,7 +5,7 @@ from enums.numbers import Numbers from functions import timeFormatters from functions.database import currency, poke, prison, birthdays, stats import json -from random import random +import random import requests import time @@ -183,7 +183,7 @@ class Tasks(commands.Cog): # Don't do it multiple times a day if bot dc's, ... with open("files/lastTasks.json", "r") as fp: lastTasks = json.load(fp) - if int(self.getCurrentHour()) == 21 and int(time.time()) - int(lastTasks["remind"]) > 10000: + if int(self.getCurrentHour()) == 22 and int(time.time()) - int(lastTasks["remind"]) > 10000: reminders = Reminders() for category in reminders.categories: @@ -200,9 +200,9 @@ class Tasks(commands.Cog): else: await userInstance.send(random.choice(category["messages"]), embed=category["embed"]) - # with open("files/lastTasks.json", "w") as fp: - # lastTasks["remind"] = round(time.time()) - # json.dump(lastTasks, fp) + with open("files/lastTasks.json", "w") as fp: + lastTasks["remind"] = round(time.time()) + json.dump(lastTasks, fp) def getCurrentHour(self): return timeFormatters.dateTimeNow().hour diff --git a/data/remind.py b/data/remind.py index 7fbb69a..8b3bc58 100644 --- a/data/remind.py +++ b/data/remind.py @@ -1,3 +1,4 @@ +from functions import les from functions.database import remind @@ -11,6 +12,13 @@ class Reminders: self._les = [int(user[0]) for user in rows if user[2]] self._lesMessages = ["Lessenrooster voor vandaag:"] - self.les = {"users": self._les, "messages": self._lesMessages, "embed": None} + self.les = {"users": self._les, "messages": self._lesMessages, "embed": self.lesEmbed()} self.categories = [self.nightly, self.les] + + def lesEmbed(self): + day, dayDatetime, semester, year = les.parseArgs([])[1:] + + schedule = les.getSchedule(semester, year) + + return les.createEmbed(day, dayDatetime, semester, year, schedule) \ No newline at end of file diff --git a/functions/database/remind.py b/functions/database/remind.py index ebbebf5..83dd632 100644 --- a/functions/database/remind.py +++ b/functions/database/remind.py @@ -17,7 +17,7 @@ def getOrAddUser(userid): res = cursor.fetchall() if not res: - cursor.execute("INSERT INTO remind(userid) VALUES %s", (int(userid),)) + cursor.execute("INSERT INTO remind(userid) VALUES(%s)", (int(userid),)) connection.commit() return getOrAddUser(userid) @@ -36,7 +36,7 @@ def switchReminder(userid, column): # Switch the column value to = not (res[columns.index(column)]) - cursor.execute("UPDATE remind SET %s = %s WHERE userid = %s", (column, to, int(userid),)) + cursor.execute("UPDATE remind SET {} = %s WHERE userid = %s".format(column), (to, int(userid),)) connection.commit() return to