aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/backend
diff options
context:
space:
mode:
Diffstat (limited to 'bot/exts/backend')
-rw-r--r--bot/exts/backend/branding/__init__.py4
-rw-r--r--bot/exts/backend/branding/_cog.py7
-rw-r--r--bot/exts/backend/config_verifier.py8
-rw-r--r--bot/exts/backend/error_handler.py4
-rw-r--r--bot/exts/backend/logging.py4
-rw-r--r--bot/exts/backend/sync/__init__.py4
-rw-r--r--bot/exts/backend/sync/_cog.py4
7 files changed, 16 insertions, 19 deletions
diff --git a/bot/exts/backend/branding/__init__.py b/bot/exts/backend/branding/__init__.py
index 20a747b7f..8460465cb 100644
--- a/bot/exts/backend/branding/__init__.py
+++ b/bot/exts/backend/branding/__init__.py
@@ -2,6 +2,6 @@ from bot.bot import Bot
from bot.exts.backend.branding._cog import Branding
-def setup(bot: Bot) -> None:
+async def setup(bot: Bot) -> None:
"""Load Branding cog."""
- bot.add_cog(Branding(bot))
+ await bot.add_cog(Branding(bot))
diff --git a/bot/exts/backend/branding/_cog.py b/bot/exts/backend/branding/_cog.py
index 0c5839a7a..e55aa1995 100644
--- a/bot/exts/backend/branding/_cog.py
+++ b/bot/exts/backend/branding/_cog.py
@@ -17,7 +17,6 @@ from bot.constants import Branding as BrandingConfig, Channels, Colours, Guild,
from bot.decorators import mock_in_debug
from bot.exts.backend.branding._repository import BrandingRepository, Event, RemoteObject
from bot.log import get_logger
-from bot.utils import scheduling
log = get_logger(__name__)
@@ -127,7 +126,9 @@ class Branding(commands.Cog):
self.bot = bot
self.repository = BrandingRepository(bot)
- scheduling.create_task(self.maybe_start_daemon(), event_loop=self.bot.loop) # Start depending on cache.
+ async def cog_load(self) -> None:
+ """Carry out cog asynchronous initialisation."""
+ await self.maybe_start_daemon() # Start depending on cache.
# region: Internal logic & state management
@@ -413,7 +414,7 @@ class Branding(commands.Cog):
if should_begin:
self.daemon_loop.start()
- def cog_unload(self) -> None:
+ async def cog_unload(self) -> None:
"""
Cancel the daemon in case of cog unload.
diff --git a/bot/exts/backend/config_verifier.py b/bot/exts/backend/config_verifier.py
index dc85a65a2..97c8869a1 100644
--- a/bot/exts/backend/config_verifier.py
+++ b/bot/exts/backend/config_verifier.py
@@ -3,7 +3,6 @@ from discord.ext.commands import Cog
from bot import constants
from bot.bot import Bot
from bot.log import get_logger
-from bot.utils import scheduling
log = get_logger(__name__)
@@ -13,9 +12,8 @@ class ConfigVerifier(Cog):
def __init__(self, bot: Bot):
self.bot = bot
- self.channel_verify_task = scheduling.create_task(self.verify_channels(), event_loop=self.bot.loop)
- async def verify_channels(self) -> None:
+ async def cog_load(self) -> None:
"""
Verify channels.
@@ -34,6 +32,6 @@ class ConfigVerifier(Cog):
log.warning(f"Configured channels do not exist in server: {', '.join(invalid_channels)}.")
-def setup(bot: Bot) -> None:
+async def setup(bot: Bot) -> None:
"""Load the ConfigVerifier cog."""
- bot.add_cog(ConfigVerifier(bot))
+ await bot.add_cog(ConfigVerifier(bot))
diff --git a/bot/exts/backend/error_handler.py b/bot/exts/backend/error_handler.py
index c79c7b2a7..fabb2dbb5 100644
--- a/bot/exts/backend/error_handler.py
+++ b/bot/exts/backend/error_handler.py
@@ -328,6 +328,6 @@ class ErrorHandler(Cog):
log.error(f"Error executing command invoked by {ctx.message.author}: {ctx.message.content}", exc_info=e)
-def setup(bot: Bot) -> None:
+async def setup(bot: Bot) -> None:
"""Load the ErrorHandler cog."""
- bot.add_cog(ErrorHandler(bot))
+ await bot.add_cog(ErrorHandler(bot))
diff --git a/bot/exts/backend/logging.py b/bot/exts/backend/logging.py
index 469331ae5..b9504c2eb 100644
--- a/bot/exts/backend/logging.py
+++ b/bot/exts/backend/logging.py
@@ -36,6 +36,6 @@ class Logging(Cog):
await self.bot.get_channel(Channels.dev_log).send(embed=embed)
-def setup(bot: Bot) -> None:
+async def setup(bot: Bot) -> None:
"""Load the Logging cog."""
- bot.add_cog(Logging(bot))
+ await bot.add_cog(Logging(bot))
diff --git a/bot/exts/backend/sync/__init__.py b/bot/exts/backend/sync/__init__.py
index 829098f79..1978917e6 100644
--- a/bot/exts/backend/sync/__init__.py
+++ b/bot/exts/backend/sync/__init__.py
@@ -1,8 +1,8 @@
from bot.bot import Bot
-def setup(bot: Bot) -> None:
+async def setup(bot: Bot) -> None:
"""Load the Sync cog."""
# Defer import to reduce side effects from importing the sync package.
from bot.exts.backend.sync._cog import Sync
- bot.add_cog(Sync(bot))
+ await bot.add_cog(Sync(bot))
diff --git a/bot/exts/backend/sync/_cog.py b/bot/exts/backend/sync/_cog.py
index 80f5750bc..58aabc141 100644
--- a/bot/exts/backend/sync/_cog.py
+++ b/bot/exts/backend/sync/_cog.py
@@ -9,7 +9,6 @@ from bot.api import ResponseCodeError
from bot.bot import Bot
from bot.exts.backend.sync import _syncers
from bot.log import get_logger
-from bot.utils import scheduling
log = get_logger(__name__)
@@ -19,9 +18,8 @@ class Sync(Cog):
def __init__(self, bot: Bot) -> None:
self.bot = bot
- scheduling.create_task(self.sync_guild(), event_loop=self.bot.loop)
- async def sync_guild(self) -> None:
+ async def cog_load(self) -> None:
"""Syncs the roles/users of the guild with the database."""
await self.bot.wait_until_guild_available()