[Downloader] Only prompt reload of loaded cogs (#2233)

This commit is contained in:
Michael H 2018-10-15 08:29:56 -04:00 committed by Toby Harradine
parent 5ba95090d9
commit c510ebe5e5

View File

@ -372,13 +372,18 @@ class Downloader(commands.Cog):
await self._reinstall_libraries(installed_and_updated) await self._reinstall_libraries(installed_and_updated)
message = _("Cog update completed successfully.") message = _("Cog update completed successfully.")
cognames = [c.name for c in installed_and_updated] cognames = {c.name for c in installed_and_updated}
message += _("\nUpdated: ") + humanize_list(tuple(map(inline, cognames))) message += _("\nUpdated: ") + humanize_list(tuple(map(inline, cognames)))
else: else:
await ctx.send(_("All installed cogs are already up to date.")) await ctx.send(_("All installed cogs are already up to date."))
return return
await ctx.send(message) await ctx.send(message)
cognames &= set(ctx.bot.extensions.keys()) # only reload loaded cogs
if not cognames:
return await ctx.send(
_("None of the updated cogs were previously loaded. Update complete.")
)
message = _("Would you like to reload the updated cogs?") message = _("Would you like to reload the updated cogs?")
can_react = ctx.channel.permissions_for(ctx.me).add_reactions can_react = ctx.channel.permissions_for(ctx.me).add_reactions
if not can_react: if not can_react:
@ -402,7 +407,6 @@ class Downloader(commands.Cog):
if can_react: if can_react:
with contextlib.suppress(discord.Forbidden): with contextlib.suppress(discord.Forbidden):
await query.clear_reactions() await query.clear_reactions()
await ctx.invoke(ctx.bot.get_cog("Core").reload, *cognames) await ctx.invoke(ctx.bot.get_cog("Core").reload, *cognames)
else: else:
if can_react: if can_react: