aboutsummaryrefslogtreecommitdiffstats
path: root/bot/__main__.py
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2022-09-18 13:09:26 +0100
committerGravatar Chris Lovering <[email protected]>2022-09-21 23:02:57 +0100
commita2b0e761cb6e61ec18c574479f267a009a638eae (patch)
tree53c530cf7860bb9fa6ae0c7439b79efbe39c24ca /bot/__main__.py
parentMove init tasks to async cog_load functions (diff)
Support loading all extensions in CI
Diffstat (limited to 'bot/__main__.py')
-rw-r--r--bot/__main__.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/bot/__main__.py b/bot/__main__.py
index 5bff1bef..9cf63dc5 100644
--- a/bot/__main__.py
+++ b/bot/__main__.py
@@ -33,6 +33,22 @@ async def _create_redis_session() -> RedisSession:
raise StartupError(e)
+async def test_bot_in_ci(bot: Bot) -> None:
+ """
+ Attempt to import all extensions and then return.
+
+ This is to ensure that all extensions can at least be
+ imported and have a setup function within our CI.
+ """
+ from botcore.utils._extensions import walk_extensions
+
+ from bot import exts
+
+ for _ in walk_extensions(exts):
+ # walk_extensions does all the heavy lifting within the generator.
+ pass
+
+
async def main() -> None:
"""Entry async method for starting the bot."""
allowed_roles = list({discord.Object(id_) for id_ in constants.MODERATION_ROLES})
@@ -62,7 +78,10 @@ async def main() -> None:
channels=constants.WHITELISTED_CHANNELS,
roles=constants.STAFF_ROLES,
))
- await _bot.start(constants.Client.token)
+ if constants.Client.in_ci:
+ await test_bot_in_ci(_bot)
+ else:
+ await _bot.start(constants.Client.token)
asyncio.run(main())