mirror of https://github.com/stijndcl/didier
Load calendars once on startup (before connecting)
parent
8707f467d5
commit
4c4b7ec0cf
|
@ -63,7 +63,7 @@ class Tasks(commands.Cog):
|
||||||
if settings.BIRTHDAY_ANNOUNCEMENT_CHANNEL is not None:
|
if settings.BIRTHDAY_ANNOUNCEMENT_CHANNEL is not None:
|
||||||
self.check_birthdays.start()
|
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:
|
if settings.FREE_GAMES_CHANNEL is not None:
|
||||||
self.pull_free_games.start()
|
self.pull_free_games.start()
|
||||||
|
|
||||||
|
@ -73,10 +73,8 @@ class Tasks(commands.Cog):
|
||||||
self.remove_old_ufora_announcements.start()
|
self.remove_old_ufora_announcements.start()
|
||||||
|
|
||||||
# Start other tasks
|
# Start other tasks
|
||||||
self.init_schedules.start()
|
|
||||||
self.reminders.start()
|
self.reminders.start()
|
||||||
self.reset_wordle_word.start()
|
self.reset_wordle_word.start()
|
||||||
self.pull_schedules.start()
|
|
||||||
|
|
||||||
@overrides
|
@overrides
|
||||||
def cog_unload(self) -> None:
|
def cog_unload(self) -> None:
|
||||||
|
@ -135,16 +133,6 @@ class Tasks(commands.Cog):
|
||||||
async def _before_check_birthdays(self):
|
async def _before_check_birthdays(self):
|
||||||
await self.client.wait_until_ready()
|
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)
|
@tasks.loop(minutes=15)
|
||||||
async def pull_free_games(self, **kwargs):
|
async def pull_free_games(self, **kwargs):
|
||||||
"""Task that checks for free games occasionally"""
|
"""Task that checks for free games occasionally"""
|
||||||
|
|
4
main.py
4
main.py
|
@ -11,6 +11,10 @@ from didier import Didier
|
||||||
async def run_bot():
|
async def run_bot():
|
||||||
"""Run Didier"""
|
"""Run Didier"""
|
||||||
didier = Didier()
|
didier = Didier()
|
||||||
|
|
||||||
|
# Schedules are quite heavy - do this once before connecting
|
||||||
|
await didier.load_schedules()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await didier.start(settings.DISCORD_TOKEN)
|
await didier.start(settings.DISCORD_TOKEN)
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Reference in New Issue