Archived
generated from imcompiling/discord-bot-template
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -12,6 +12,7 @@ class ChannelIds:
|
||||
"""Class holds all channel ids needed by bot."""
|
||||
|
||||
general: int
|
||||
raid: int
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
Reference in New Issue
Block a user