Merge branch '25-cakeday'
build_latest / build (push) Successful in 44s
build_develop / build (push) Successful in 45s
build_release / build (push) Successful in 43s

This commit is contained in:
2023-09-14 11:34:14 -04:00
2 changed files with 23 additions and 1 deletions
+22
View File
@@ -54,6 +54,8 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
kandy: nextcord.User = await self.bot.fetch_user(239547993106284544) kandy: nextcord.User = await self.bot.fetch_user(239547993106284544)
await kandy.send('Happy "Birthday"!') await kandy.send('Happy "Birthday"!')
await self.cakedays()
@daily_loop.before_loop @daily_loop.before_loop
async def before_loop(self): async def before_loop(self):
""" """
@@ -104,3 +106,23 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
with Session(engine) as session: with Session(engine) as session:
to_add = session.scalars(stmt) to_add = session.scalars(stmt)
birthday_list.extend(to_add.all()) 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
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)
+1 -1
View File
@@ -12,7 +12,7 @@ class Params:
active_category_id: int active_category_id: int
admin_channel_id: int # might want to rename this... admin_channel_id: int # might want to rename this...
annoucement_category_id: int announcement_category_id: int
archive_channel_group_id: int archive_channel_group_id: int
clan_council_elect_role_id: int clan_council_elect_role_id: int
clan_council_role_id: int clan_council_role_id: int