diff options
author | 2023-05-06 14:06:53 +0100 | |
---|---|---|
committer | 2023-05-06 14:06:53 +0100 | |
commit | cd16be11b5686f4d8e63db303b884ed88efb18d1 (patch) | |
tree | f4fbc6bc4cd93ba2a89b1c4cc6c5c2012549421e /bot/exts | |
parent | use the new code jam variable (#1267) (diff) |
Run null check on needed api keys before loading cogs.
This makes sure that all cogs that need keys won't load.
Which helps in avoiding exceptions at runtime, and give a clearer warning at startup time.
Diffstat (limited to 'bot/exts')
-rw-r--r-- | bot/exts/events/hacktoberfest/hacktoberstats.py | 2 | ||||
-rw-r--r-- | bot/exts/fun/movie.py | 3 | ||||
-rw-r--r-- | bot/exts/fun/snakes/__init__.py | 3 | ||||
-rw-r--r-- | bot/exts/holidays/halloween/scarymovie.py | 3 | ||||
-rw-r--r-- | bot/exts/holidays/halloween/spookygif.py | 3 | ||||
-rw-r--r-- | bot/exts/utilities/wolfram.py | 3 |
6 files changed, 17 insertions, 0 deletions
diff --git a/bot/exts/events/hacktoberfest/hacktoberstats.py b/bot/exts/events/hacktoberfest/hacktoberstats.py index 0b4266d8..5bfac93f 100644 --- a/bot/exts/events/hacktoberfest/hacktoberstats.py +++ b/bot/exts/events/hacktoberfest/hacktoberstats.py @@ -434,4 +434,6 @@ class HacktoberStats(commands.Cog): async def setup(bot: Bot) -> None: """Load the Hacktober Stats Cog.""" + if not Tokens.github: + log.warning("No GitHub token was provided. The HacktoberStats Cog won't be fully functional.") await bot.add_cog(HacktoberStats(bot)) diff --git a/bot/exts/fun/movie.py b/bot/exts/fun/movie.py index 73ef0a3c..21183e0f 100644 --- a/bot/exts/fun/movie.py +++ b/bot/exts/fun/movie.py @@ -208,4 +208,7 @@ class Movie(Cog): async def setup(bot: Bot) -> None: """Load the Movie Cog.""" + if not Tokens.tmdb: + logger.warning("No TMDB token. Not loading Movie Cog.") + return await bot.add_cog(Movie(bot)) diff --git a/bot/exts/fun/snakes/__init__.py b/bot/exts/fun/snakes/__init__.py index 8aa39fb5..37d0e255 100644 --- a/bot/exts/fun/snakes/__init__.py +++ b/bot/exts/fun/snakes/__init__.py @@ -1,6 +1,7 @@ import logging from bot.bot import Bot +from bot.constants import Tokens from bot.exts.fun.snakes._snakes_cog import Snakes log = logging.getLogger(__name__) @@ -8,4 +9,6 @@ log = logging.getLogger(__name__) async def setup(bot: Bot) -> None: """Load the Snakes Cog.""" + if not Tokens.giphy: + log.warning("No Youtube token. All youtube related commands in Snakes cog won't work.") await bot.add_cog(Snakes(bot)) diff --git a/bot/exts/holidays/halloween/scarymovie.py b/bot/exts/holidays/halloween/scarymovie.py index 00c96153..fbab3dd2 100644 --- a/bot/exts/holidays/halloween/scarymovie.py +++ b/bot/exts/holidays/halloween/scarymovie.py @@ -135,4 +135,7 @@ class ScaryMovie(commands.Cog): async def setup(bot: Bot) -> None: """Load the Scary Movie Cog.""" + if not Tokens.tmdb: + log.warning("No TMDB Token. Not loading ScaryMovie Cog.") + return await bot.add_cog(ScaryMovie(bot)) diff --git a/bot/exts/holidays/halloween/spookygif.py b/bot/exts/holidays/halloween/spookygif.py index 7a90a8a9..41488678 100644 --- a/bot/exts/holidays/halloween/spookygif.py +++ b/bot/exts/holidays/halloween/spookygif.py @@ -35,4 +35,7 @@ class SpookyGif(commands.Cog): async def setup(bot: Bot) -> None: """Spooky GIF Cog load.""" + if not Tokens.giphy: + log.warning("No Giphy token. Not loading Giphy cog.") + return await bot.add_cog(SpookyGif(bot)) diff --git a/bot/exts/utilities/wolfram.py b/bot/exts/utilities/wolfram.py index a036b50f..9d28608c 100644 --- a/bot/exts/utilities/wolfram.py +++ b/bot/exts/utilities/wolfram.py @@ -303,4 +303,7 @@ class Wolfram(Cog): async def setup(bot: Bot) -> None: """Load the Wolfram cog.""" + if not Wolfram.key: + log.warning("No Wolfram API Key was provided. Not loading Wolfram Cog.") + return await bot.add_cog(Wolfram(bot)) |