From 5d05006a236ac036d00f749ded3ff223fa6a45ec Mon Sep 17 00:00:00 2001 From: imcompiling Date: Mon, 1 Jan 2024 14:11:07 -0500 Subject: [PATCH] Prevent unneeded exceptions. --- cogs/loops/daily_loop.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cogs/loops/daily_loop.py b/cogs/loops/daily_loop.py index ffb8caf..3f33795 100644 --- a/cogs/loops/daily_loop.py +++ b/cogs/loops/daily_loop.py @@ -79,6 +79,10 @@ class DailyLoop(commands.Cog, name="Daily Loop"): config: DakinyConfig = self.bot.config cycle = get_current_cycle(config) + # prevent exception from using cycle as an Int in an array + if cycle is None: + return None + return ElectionCycle(cycle, config, self.bot.get_guild(config.params.guild_id)) def update_birthdays(self) -> None: @@ -107,10 +111,14 @@ class DailyLoop(commands.Cog, name="Daily Loop"): today = datetime.today() guild: nextcord.Guild = self.bot.get_guild(self.bot.config.params.guild_id) - announce_channel: nextcord.TextChannel = guild.get_channel(self.bot.config.params.general_channel_id) + announce_channel: nextcord.TextChannel = guild.get_channel( + self.bot.config.params.general_channel_id + ) cakedays: list[nextcord.Member] = [ - human for human in guild.humans if human.joined_at.month == today.month and human.joined_at.day == today.day + human + for human in guild.humans + if human.joined_at.month == today.month and human.joined_at.day == today.day ] for member in cakedays: