[Downloader] Differentiate core and local cogs in [p]findcog (#3969)

This commit is contained in:
Vexed 2020-06-21 17:59:52 +01:00 committed by GitHub
parent aad36c7430
commit d2de3c109a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1388,7 +1388,6 @@ class Downloader(commands.Cog):
cog_name = self.cog_name_from_instance(cog) cog_name = self.cog_name_from_instance(cog)
installed, cog_installable = await self.is_installed(cog_name) installed, cog_installable = await self.is_installed(cog_name)
if installed: if installed:
is_installable = True
made_by = humanize_list(cog_installable.author) or _("Missing from info.json") made_by = humanize_list(cog_installable.author) or _("Missing from info.json")
repo_url = ( repo_url = (
_("Missing from installed repos") _("Missing from installed repos")
@ -1396,12 +1395,14 @@ class Downloader(commands.Cog):
else cog_installable.repo.clean_url else cog_installable.repo.clean_url
) )
cog_name = cog_installable.name cog_name = cog_installable.name
else: elif cog.__module__.startswith("redbot."): # core commands or core cog
# Assume it's in a base cog made_by = "Cog Creators"
is_installable = False
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.__class__.__name__ cog_name = cog.__class__.__name__
else: # assume not installed via downloader
made_by = _("Unknown")
repo_url = _("None - this cog wasn't installed via downloader")
cog_name = cog.__class__.__name__
else: else:
msg = _("This command is not provided by a cog.") msg = _("This command is not provided by a cog.")
await ctx.send(msg) await ctx.send(msg)
@ -1413,7 +1414,7 @@ class Downloader(commands.Cog):
embed.add_field(name=_("Cog Name:"), value=cog_name, inline=False) embed.add_field(name=_("Cog Name:"), value=cog_name, inline=False)
embed.add_field(name=_("Made by:"), value=made_by, inline=False) embed.add_field(name=_("Made by:"), value=made_by, inline=False)
embed.add_field(name=_("Repo URL:"), value=repo_url, inline=False) embed.add_field(name=_("Repo URL:"), value=repo_url, inline=False)
if is_installable and cog_installable.repo is not None and cog_installable.repo.branch: if installed and cog_installable.repo is not None and cog_installable.repo.branch:
embed.add_field( embed.add_field(
name=_("Repo branch:"), value=cog_installable.repo.branch, inline=False name=_("Repo branch:"), value=cog_installable.repo.branch, inline=False
) )
@ -1423,7 +1424,7 @@ class Downloader(commands.Cog):
msg = _( msg = _(
"Command: {command}\nCog name: {cog}\nMade by: {author}\nRepo URL: {repo_url}\n" "Command: {command}\nCog name: {cog}\nMade by: {author}\nRepo URL: {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 is_installable and cog_installable.repo is not None and cog_installable.repo.branch: if installed 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
) )