aboutsummaryrefslogtreecommitdiffstats
path: root/bot/seasons
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2020-03-23 19:31:23 +0100
committerGravatar kwzrd <[email protected]>2020-03-23 19:31:23 +0100
commit79376abcb7d305484bf5283f95d3a32641aeb6d5 (patch)
tree659d6fa3f5b5655531ea8909f07571bec1c0c92d /bot/seasons
parentDeseasonify: remove `load_extensions` method (diff)
Deseasonify: abdicate responsibility to wait until bot is ready
The wrapper will no longer wait for the bot to be ready before it calls the wrapped function for the first time. If the function requires the bot's cache to be ready, it is responsible for awaiting the method itself. This removes the need to acquire a reference to the bot instance inside the decorator, which seems to be difficult to do cleanly. As Mark adds, this may in fact be safer as the bot may temporarily disconnect while the task is active, and awaiting the bot's ready status every time will prevent issues in such a situation. Co-authored-by: MarkKoz <[email protected]>
Diffstat (limited to 'bot/seasons')
-rw-r--r--bot/seasons/easter/egg_facts.py2
-rw-r--r--bot/seasons/pride/pride_facts.py2
2 files changed, 4 insertions, 0 deletions
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())