4 Commits
Author SHA1 Message Date
imcompiling f79d63c78d Add timestamp to description.
build_develop / build (push) Successful in 22s
2025-03-20 09:27:36 -04:00
imcompiling 5a8119f5e4 Add the daily loop for open raid.
build_develop / build (push) Successful in 22s
2025-03-19 21:27:58 -04:00
imcompiling d5e6ffdedb Correct raid time.
build_develop / build (push) Successful in 21s
2025-03-19 19:36:21 -04:00
imcompiling 661c864ba2 Edit a docustring. 2025-03-19 19:19:34 -04:00
3 changed files with 35 additions and 4 deletions
+23 -1
View File
@@ -13,6 +13,7 @@ from off_cooldown_bot.app import birthday_list
from off_cooldown_bot.database.db import engine
from off_cooldown_bot.database.models import UserBirthday
from off_cooldown_bot.logger import ocd_logger
from off_cooldown_bot.open_raid import OpenRaid, build_raid_embed
from off_cooldown_bot.settings import settings
@@ -25,14 +26,35 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
self.update_birthdays()
self.daily_loop.start()
@tasks.loop(time=time(hour=0, tzinfo=timezone("UTC")))
@tasks.loop(time=time(hour=0, tzinfo=UTC))
async def daily_loop(self) -> None:
"""Run daily repeated functions."""
self.update_birthdays()
await self.cakedays()
@tasks.loop(time=time(hour=20, tzinfo=timezone("CST")))
async def open_raid(self) -> None:
"""
Define the open raid loop.
Checks daily if it is Thursday and then posts the open raid sign up.
"""
today = datetime.now(timezone("CST"))
if today.day + 2 == 5:
# open raid is on Saturday, post 2 days before
if (guild := self.bot.get_guild(settings.params.guild_id)) is None:
ocd_logger.error("Guild id not correct.")
return
if (channel := guild.get_channel(settings.channel_ids.raid)) is None or not isinstance(
channel, nextcord.TextChannel
):
ocd_logger.error("Raid channel is not defined or is not a text channel.")
return
await channel.send(embed=build_raid_embed(), view=OpenRaid())
@daily_loop.before_loop
@open_raid.before_loop
async def before_loop(self) -> None:
"""Actions run before the loop starts. Want to wait for bot to be ready and get the current cycle."""
await self.bot.wait_until_ready()
+11 -3
View File
@@ -131,11 +131,19 @@ def build_raid_embed() -> nextcord.Embed:
Build the open raid embed.
Returns:
nextcord.Embed: _description_
nextcord.Embed: Embed that shows the raid's sign-ups.
"""
raid_time = datetime.datetime.now(tz=datetime.UTC) # TODO make this to the next saturday at 8pm CST
embed = nextcord.Embed(title="Off Cooldown Open Raid", timestamp=raid_time)
today = datetime.datetime.now(tz=datetime.UTC).replace(hour=20)
saturday_idx = 5
days_delta = saturday_idx - today.weekday()
if days_delta < 0:
days_delta += 7
raid_time = today + datetime.timedelta(days_delta)
embed = nextcord.Embed(
title="Off Cooldown Open Raid", description=f"Raid time: t:{int(raid_time.timestamp())}:F", timestamp=raid_time
)
embed.add_field(name="Tanks", value="", inline=False)
embed.add_field(name="Healers", value="", inline=False)
embed.add_field(name="DPS", value="", inline=False)
+1
View File
@@ -12,6 +12,7 @@ class ChannelIds:
"""Class holds all channel ids needed by bot."""
general: int
raid: int
@dataclass