Skip to content

Commit

Permalink
Merge pull request #152 from stijndcl/change-calendar-loading
Browse files Browse the repository at this point in the history
Load calendars on startup & disable task
  • Loading branch information
stijndcl authored Nov 2, 2022
2 parents 65671f2 + 4c4b7ec commit 465456f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
14 changes: 1 addition & 13 deletions didier/cogs/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def cog_load(self) -> None:
if settings.BIRTHDAY_ANNOUNCEMENT_CHANNEL is not None:
self.check_birthdays.start()

# Only pull free gmaes if a channel was provided
# Only pull free games if a channel was provided
if settings.FREE_GAMES_CHANNEL is not None:
self.pull_free_games.start()

Expand All @@ -73,10 +73,8 @@ def cog_load(self) -> None:
self.remove_old_ufora_announcements.start()

# Start other tasks
self.init_schedules.start()
self.reminders.start()
self.reset_wordle_word.start()
self.pull_schedules.start()

@overrides
def cog_unload(self) -> None:
Expand Down Expand Up @@ -135,16 +133,6 @@ async def check_birthdays(self, **kwargs):
async def _before_check_birthdays(self):
await self.client.wait_until_ready()

@tasks.loop(count=1)
async def init_schedules(self, **kwargs):
"""Tasks that loads the schedules in memory on startup"""
_ = kwargs
await self.client.load_schedules()

@init_schedules.before_loop
async def _before_init_schedules(self):
await self.client.wait_until_ready()

@tasks.loop(minutes=15)
async def pull_free_games(self, **kwargs):
"""Task that checks for free games occasionally"""
Expand Down
4 changes: 4 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
async def run_bot():
"""Run Didier"""
didier = Didier()

# Schedules are quite heavy - do this once before connecting
await didier.load_schedules()

try:
await didier.start(settings.DISCORD_TOKEN)
finally:
Expand Down

0 comments on commit 465456f

Please sign in to comment.