diff options
-rw-r--r-- | bot/decorators.py | 10 | ||||
-rw-r--r-- | bot/seasons/easter/egg_facts.py | 2 | ||||
-rw-r--r-- | bot/seasons/pride/pride_facts.py | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/bot/decorators.py b/bot/decorators.py index 74976cd6..400f1bbb 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -12,7 +12,6 @@ from discord import Colour, Embed from discord.ext import commands from discord.ext.commands import CheckFailure, Context -from bot.bot import bot from bot.constants import ERROR_REPLIES, Month ONE_DAY = 24 * 60 * 60 @@ -41,16 +40,13 @@ def seasonal_task(*allowed_months: Month, sleep_time: typing.Union[float, int] = The decorated function will be called once every `sleep_time` seconds while the current UTC month is in `allowed_months`. Sleep time defaults to 24 hours. + + The wrapped task is responsible for waiting for the bot to be ready, if necessary. """ def decorator(task_body: typing.Callable) -> typing.Callable: @functools.wraps(task_body) async def decorated_task(*args, **kwargs) -> None: - """ - Call `task_body` once every `sleep_time` seconds in `allowed_months`. - - Wait for bot to be ready before calling `task_body` for the first time. - """ - await bot.wait_until_ready() + """Call `task_body` once every `sleep_time` seconds in `allowed_months`.""" log.info(f"Starting seasonal task {task_body.__qualname__} ({allowed_months})") while True: diff --git a/bot/seasons/easter/egg_facts.py b/bot/seasons/easter/egg_facts.py index f61f9da4..d20df3de 100644 --- a/bot/seasons/easter/egg_facts.py +++ b/bot/seasons/easter/egg_facts.py @@ -35,6 +35,8 @@ class EasterFacts(commands.Cog): @seasonal_task(Month.april) async def send_egg_fact_daily(self) -> None: """A background task that sends an easter egg fact in the event channel everyday.""" + await self.bot.wait_until_ready() + channel = self.bot.get_channel(Channels.seasonalbot_commands) await channel.send(embed=self.make_embed()) diff --git a/bot/seasons/pride/pride_facts.py b/bot/seasons/pride/pride_facts.py index 417a49a6..1a02eaaa 100644 --- a/bot/seasons/pride/pride_facts.py +++ b/bot/seasons/pride/pride_facts.py @@ -35,6 +35,8 @@ class PrideFacts(commands.Cog): @seasonal_task(Month.june) async def send_pride_fact_daily(self) -> None: """Background task to post the daily pride fact every day.""" + await self.bot.wait_until_ready() + channel = self.bot.get_channel(Channels.seasonalbot_commands) await self.send_select_fact(channel, datetime.utcnow()) |