Run null check on needed API keys before loading cogs.#1269
Conversation
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.
wookie184
left a comment
There was a problem hiding this comment.
There's currently an error log for bot.exts.utilities.reddit when missing the token, could we make that a warning for consistency?
| if not Tokens.giphy: | ||
| log.warning("No Youtube token. All youtube related commands in Snakes cog won't work.") |
There was a problem hiding this comment.
Looks like the wrong constant? Also capitalise youtube as YouTube
There was a problem hiding this comment.
There's currently an error log for
bot.exts.utilities.redditwhen missing the token, could we make that a warning for consistency?
Yessir we can 0e202c0
|
|
||
| async def setup(bot: Bot) -> None: | ||
| """Load the Wolfram cog.""" | ||
| if not Wolfram.key: |
There was a problem hiding this comment.
Wolfram is the cog, not the constants config. This causes an error.
There was a problem hiding this comment.
My bad, I hadn't still tested this yet, and I was trying to get something in a PR before I left the house.
5ba5275
Co-authored-by: wookie184 <wookie1840@gmail.com>
wookie184
left a comment
There was a problem hiding this comment.
This is a nice QOL improvement, thanks!
We have a lot of Cogs that need some API key to function.
If the key isn't present, it would result in constant 401s.
This PR adds a change that won't load these Cogs & log a warning whenever these keys aren't present.