diff options
author | 2021-03-16 02:07:28 +0100 | |
---|---|---|
committer | 2021-03-16 02:47:58 +0100 | |
commit | 3beebb973f3cceb5281d1901535185276c9f4714 (patch) | |
tree | b790519ff58741f8707a754b6133c8bef918277d | |
parent | Correct length limits to embed limits (diff) |
Update the symbol_name when fetching the DocItem from get_symbol_item
Moving the block handling the fetching into a separate method meant that
symbol_name was no longer updated inside the create_symbol_embed method, causing
the whole message to be included in the embed title in case the space shortcut
was used
-rw-r--r-- | bot/exts/info/doc/_cog.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py index bf49e0aee..5af95717b 100644 --- a/bot/exts/info/doc/_cog.py +++ b/bot/exts/info/doc/_cog.py @@ -7,7 +7,7 @@ import textwrap from collections import defaultdict from contextlib import suppress from types import SimpleNamespace -from typing import Dict, NamedTuple, Optional, Union +from typing import Dict, NamedTuple, Optional, Tuple, Union import aiohttp import discord @@ -219,11 +219,11 @@ class DocCog(commands.Cog): log.debug("Finished inventory refresh.") self.refresh_event.set() - def get_symbol_item(self, symbol_name: str) -> Optional[DocItem]: + def get_symbol_item(self, symbol_name: str) -> Tuple[str, Optional[DocItem]]: """ - Get the `DocItem` associated with `symbol_name` from the `doc_symbols` dict. + Get the `DocItem` and the symbol name used to fetch it from the `doc_symbols` dict. - If the doc item is not found directly from the name and the name contains a space, + If the doc item is not found directly from the passed in name and the name contains a space, the first word of the name will be attempted to be used to get the item. """ doc_item = self.doc_symbols.get(symbol_name) @@ -231,7 +231,7 @@ class DocCog(commands.Cog): symbol_name = symbol_name.split(" ", maxsplit=1)[0] doc_item = self.doc_symbols.get(symbol_name) - return doc_item + return symbol_name, doc_item async def get_symbol_markdown(self, doc_item: DocItem) -> str: """ @@ -273,7 +273,7 @@ class DocCog(commands.Cog): await self.refresh_event.wait() # Ensure a refresh can't run in case of a context switch until the with block is exited with self.symbol_get_event: - doc_item = self.get_symbol_item(symbol_name) + symbol_name, doc_item = self.get_symbol_item(symbol_name) if doc_item is None: log.debug("Symbol does not exist.") return None |