diff options
| -rw-r--r-- | bot/exts/info/source.py | 19 | 
1 files changed, 11 insertions, 8 deletions
| diff --git a/bot/exts/info/source.py b/bot/exts/info/source.py index ef07c77a1..723ae5aba 100644 --- a/bot/exts/info/source.py +++ b/bot/exts/info/source.py @@ -7,8 +7,9 @@ from discord.ext import commands  from bot.bot import Bot  from bot.constants import URLs +from bot.exts.info.tags import TagIdentifier -SourceType = Union[commands.HelpCommand, commands.Command, commands.Cog, str, commands.ExtensionNotLoaded] +SourceType = Union[commands.HelpCommand, commands.Command, commands.Cog, TagIdentifier, commands.ExtensionNotLoaded]  class SourceConverter(commands.Converter): @@ -33,8 +34,10 @@ class SourceConverter(commands.Converter):          if not tags_cog:              show_tag = False -        elif argument.lower() in tags_cog._cache: -            return argument.lower() +        else: +            identifier = TagIdentifier.from_string(argument.lower()) +            if identifier in tags_cog.tags: +                return identifier          escaped_arg = utils.escape_markdown(argument) @@ -72,9 +75,9 @@ class BotSource(commands.Cog):              source_item = inspect.unwrap(source_item.callback)              src = source_item.__code__              filename = src.co_filename -        elif isinstance(source_item, str): +        elif isinstance(source_item, TagIdentifier):              tags_cog = self.bot.get_cog("Tags") -            filename = tags_cog._cache[source_item]["location"] +            filename = tags_cog.tags[source_item].file_path          else:              src = type(source_item)              try: @@ -82,7 +85,7 @@ class BotSource(commands.Cog):              except TypeError:                  raise commands.BadArgument("Cannot get source for a dynamically-created object.") -        if not isinstance(source_item, str): +        if not isinstance(source_item, TagIdentifier):              try:                  lines, first_line_no = inspect.getsourcelines(src)              except OSError: @@ -95,7 +98,7 @@ class BotSource(commands.Cog):          # Handle tag file location differently than others to avoid errors in some cases          if not first_line_no: -            file_location = Path(filename).relative_to("/bot/") +            file_location = Path(filename).relative_to("bot/")          else:              file_location = Path(filename).relative_to(Path.cwd()).as_posix() @@ -113,7 +116,7 @@ class BotSource(commands.Cog):          elif isinstance(source_object, commands.Command):              description = source_object.short_doc              title = f"Command: {source_object.qualified_name}" -        elif isinstance(source_object, str): +        elif isinstance(source_object, TagIdentifier):              title = f"Tag: {source_object}"              description = ""          else: | 
