diff options
author | 2021-03-03 14:21:24 +0100 | |
---|---|---|
committer | 2021-03-05 01:40:16 +0100 | |
commit | 85b1d7751c3cf46c007a4194d984a1921684456b (patch) | |
tree | 9708a0fd35ea5ed52ac8acda666a542771359a17 | |
parent | Add new symbols to front of queue instead of extending the end (diff) |
Use common check for early exit
This introduces a possibly redundant check for the doc_item being None
but results in flatter code with less duplication
-rw-r--r-- | bot/exts/info/doc/_cog.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py index 95a772df3..0c255c449 100644 --- a/bot/exts/info/doc/_cog.py +++ b/bot/exts/info/doc/_cog.py @@ -237,18 +237,15 @@ class DocCog(commands.Cog): await self.refresh_event.wait() doc_item = self.doc_symbols.get(symbol_name) + if doc_item is None and " " in symbol_name: + # If an invalid symbol contains a space, check if the command was invoked + # in the format !d <symbol> <message> + symbol_name = symbol_name.split(" ", maxsplit=1)[0] + doc_item = self.doc_symbols.get(symbol_name) + if doc_item is None: - if symbol_name.count(" "): - # If an invalid symbol contains a space, check if the command was invoked - # in the format !d <symbol> <message> - symbol_name = symbol_name.split(" ", maxsplit=1)[0] - doc_item = self.doc_symbols.get(symbol_name) - if doc_item is None: - log.debug("Symbol does not exist.") - return None - else: - log.debug("Symbol does not exist.") - return None + log.debug("Symbol does not exist.") + return None self.bot.stats.incr(f"doc_fetches.{doc_item.package}") |