diff --git a/cogs/random.py b/cogs/randomCog.py similarity index 100% rename from cogs/random.py rename to cogs/randomCog.py diff --git a/cogs/tasks.py b/cogs/tasks.py index 2dfdbc9..7f17b2d 100644 --- a/cogs/tasks.py +++ b/cogs/tasks.py @@ -202,6 +202,12 @@ class Tasks(commands.Cog): if (not category["weekends"]) and weekday > 4: continue + # Create embed once because this can be heavy + if "embed" in category: + embed = category["embed"]() + else: + embed = None + for user in category["users"]: userInstance = self.client.get_user(user) @@ -213,7 +219,7 @@ class Tasks(commands.Cog): if "embed" not in category: await userInstance.send(random.choice(category["messages"])) else: - await userInstance.send(random.choice(category["messages"]), embed=category["embed"]) + await userInstance.send(random.choice(category["messages"]), embed=embed) with open("files/lastTasks.json", "w") as fp: lastTasks["remind"] = round(time.time()) diff --git a/data/remind.py b/data/remind.py index 403fb37..39f6dd3 100644 --- a/data/remind.py +++ b/data/remind.py @@ -13,7 +13,7 @@ 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": self.lesEmbed(), "weekends": False, "disabled": True} + self.les = {"users": self._les, "messages": self._lesMessages, "embed": self.lesEmbed, "weekends": False, "disabled": True} self.categories = [self.nightly, self.les]