[Downloader] Fix AttributeError in [p]findcog for cogs that weren't installed through Downloader (#3278)

* Update downloader.py

* Create 3278.misc.rst
This commit is contained in:
jack1142 2020-01-06 22:48:43 +01:00 committed by Michael H
parent a2b68ea7fc
commit d3c97eedfe
2 changed files with 4 additions and 1 deletions

View File

@ -0,0 +1 @@
Fix `AttributeError` in ``[p]findcog`` for cogs that weren't installed through Downloader.

View File

@ -1281,6 +1281,7 @@ class Downloader(commands.Cog):
""" """
if isinstance(cog_installable, Installable): if isinstance(cog_installable, Installable):
is_installable = True
made_by = ", ".join(cog_installable.author) or _("Missing from info.json") made_by = ", ".join(cog_installable.author) or _("Missing from info.json")
repo_url = ( repo_url = (
_("Missing from installed repos") _("Missing from installed repos")
@ -1289,6 +1290,7 @@ class Downloader(commands.Cog):
) )
cog_name = cog_installable.name cog_name = cog_installable.name
else: else:
is_installable = False
made_by = "26 & co." made_by = "26 & co."
repo_url = "https://github.com/Cog-Creators/Red-DiscordBot" repo_url = "https://github.com/Cog-Creators/Red-DiscordBot"
cog_name = cog_installable.__class__.__name__ cog_name = cog_installable.__class__.__name__
@ -1296,7 +1298,7 @@ class Downloader(commands.Cog):
msg = _( msg = _(
"Command: {command}\nCog name: {cog}\nMade by: {author}\nRepo: {repo_url}\n" "Command: {command}\nCog name: {cog}\nMade by: {author}\nRepo: {repo_url}\n"
).format(command=command_name, author=made_by, repo_url=repo_url, cog=cog_name) ).format(command=command_name, author=made_by, repo_url=repo_url, cog=cog_name)
if cog_installable.repo is not None and cog_installable.repo.branch: if is_installable and cog_installable.repo is not None and cog_installable.repo.branch:
msg += _("Repo branch: {branch_name}\n").format( msg += _("Repo branch: {branch_name}\n").format(
branch_name=cog_installable.repo.branch branch_name=cog_installable.repo.branch
) )