From c5c79015a996e0cf4b3a1d3453f8cbbefa52eea3 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Thu, 14 Sep 2023 11:22:53 -0400 Subject: [PATCH 1/3] Correct spelling. --- config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.py b/config.py index 9f31c11..8867357 100644 --- a/config.py +++ b/config.py @@ -12,7 +12,7 @@ class Params: active_category_id: int admin_channel_id: int # might want to rename this... - annoucement_category_id: int + announcement_category_id: int archive_channel_group_id: int clan_council_elect_role_id: int clan_council_role_id: int From 7d1b2f7cac5b9906b681dc3ba03ae3cde46e3435 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Thu, 14 Sep 2023 11:24:25 -0400 Subject: [PATCH 2/3] Create cakedays function. --- cogs/loops/daily_loop.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cogs/loops/daily_loop.py b/cogs/loops/daily_loop.py index 665647f..0f7741c 100644 --- a/cogs/loops/daily_loop.py +++ b/cogs/loops/daily_loop.py @@ -54,6 +54,8 @@ class DailyLoop(commands.Cog, name="Daily Loop"): kandy: nextcord.User = await self.bot.fetch_user(239547993106284544) await kandy.send('Happy "Birthday"!') + await self.cakedays() + @daily_loop.before_loop async def before_loop(self): """ @@ -104,3 +106,22 @@ class DailyLoop(commands.Cog, name="Daily Loop"): with Session(engine) as session: to_add = session.scalars(stmt) birthday_list.extend(to_add.all()) + + async def cakedays(self) -> None: + """ + Loops through the guild's humans checking for joined_at dates that match today's date. Sends a message + saying happy cakeday. + """ + + 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.announcement_category_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 + ] + + for member in cakedays: + years = today.year - member.joined_at.year + msg = f"Happy Cake day! <@{member.id}> joined the discord {years} ago!" + await announce_channel.send(msg) From 85eb52d2e1d8c91d99845f1ac16b1a68168b3441 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Thu, 14 Sep 2023 11:33:27 -0400 Subject: [PATCH 3/3] add word to message string. --- cogs/loops/daily_loop.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cogs/loops/daily_loop.py b/cogs/loops/daily_loop.py index 0f7741c..68681a9 100644 --- a/cogs/loops/daily_loop.py +++ b/cogs/loops/daily_loop.py @@ -123,5 +123,6 @@ class DailyLoop(commands.Cog, name="Daily Loop"): for member in cakedays: years = today.year - member.joined_at.year - msg = f"Happy Cake day! <@{member.id}> joined the discord {years} ago!" + year_str = "years" if years > 1 else "year" + msg = f"Happy Cake day! <@{member.id}> joined the discord {years} {year_str} ago!" await announce_channel.send(msg)