aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts
diff options
context:
space:
mode:
Diffstat (limited to 'bot/exts')
-rw-r--r--bot/exts/fun/game.py4
-rw-r--r--bot/exts/holidays/halloween/spookynamerate.py4
-rw-r--r--bot/exts/utilities/reddit.py5
3 files changed, 4 insertions, 9 deletions
diff --git a/bot/exts/fun/game.py b/bot/exts/fun/game.py
index 56e6314f..4ed2e93e 100644
--- a/bot/exts/fun/game.py
+++ b/bot/exts/fun/game.py
@@ -185,9 +185,7 @@ class Games(Cog):
self.genres: dict[str, int] = {}
self.headers = BASE_HEADERS
- self.bot.loop.create_task(self.renew_access_token())
-
- async def renew_access_token(self) -> None:
+ async def cog_load(self) -> None:
"""Refeshes V4 access token a number of seconds before expiry. See `ACCESS_TOKEN_RENEWAL_WINDOW`."""
while True:
async with self.http_session.post(OAUTH_URL, params=OAUTH_PARAMS) as resp:
diff --git a/bot/exts/holidays/halloween/spookynamerate.py b/bot/exts/holidays/halloween/spookynamerate.py
index 8c801a2f..5d41ce6d 100644
--- a/bot/exts/holidays/halloween/spookynamerate.py
+++ b/bot/exts/holidays/halloween/spookynamerate.py
@@ -95,8 +95,6 @@ class SpookyNameRate(Cog):
self.bot = bot
self.name = None
- self.bot.loop.create_task(self.load_vars())
-
self.first_time = None
self.poll = False
self.announce_name.start()
@@ -104,7 +102,7 @@ class SpookyNameRate(Cog):
# Define an asyncio.Lock() to make sure the dictionary isn't changed
# when checking the messages for duplicate emojis'
- async def load_vars(self) -> None:
+ async def cog_load(self) -> None:
"""Loads the variables that couldn't be loaded in __init__."""
self.first_time = await self.data.get("first_time", True)
self.name = await self.data.get("name")
diff --git a/bot/exts/utilities/reddit.py b/bot/exts/utilities/reddit.py
index d6148abd..07222d79 100644
--- a/bot/exts/utilities/reddit.py
+++ b/bot/exts/utilities/reddit.py
@@ -38,16 +38,15 @@ class Reddit(Cog):
self.access_token = None
self.client_auth = BasicAuth(RedditConfig.client_id, RedditConfig.secret)
- bot.loop.create_task(self.init_reddit_ready())
self.auto_poster_loop.start()
- def cog_unload(self) -> None:
+ async def cog_unload(self) -> None:
"""Stop the loop task and revoke the access token when the cog is unloaded."""
self.auto_poster_loop.cancel()
if self.access_token and self.access_token.expires_at > datetime.utcnow():
asyncio.create_task(self.revoke_access_token())
- async def init_reddit_ready(self) -> None:
+ async def cog_load(self) -> None:
"""Sets the reddit webhook when the cog is loaded."""
await self.bot.wait_until_guild_available()
if not self.webhook: