diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 32c4ea989..1a356b199 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -82,17 +82,21 @@ class Core: async def _reload(self, ctx, *, cog_name: str): """Reloads a package""" ctx.bot.unload_extension(cog_name) - self.cleanup_and_refresh_modules(cog_name) + + spec = await find_spec(ctx.bot, cog_name) + if spec is None: + await ctx.send(_("No module by that name was found in any" + " cog path.")) + return + + self.cleanup_and_refresh_modules(spec.name) try: - spec = await ctx.bot.cog_mgr.find_cog(cog_name) ctx.bot.load_extension(spec) except Exception as e: log.exception("Package reloading failed", exc_info=e) await ctx.send(_("Failed to reload package. Check your console or " "logs for details.")) else: - curr_pkgs = await ctx.bot.db.packages() - await ctx.bot.save_packages_status(curr_pkgs) await ctx.send(_("Done.")) @commands.command(name="shutdown") @@ -120,7 +124,7 @@ class Core: else: importlib._bootstrap._exec(lib.__spec__, lib) - modules = itertools.accumulate(splitted, lambda old, next: "{}.{}".format(old, next)) + modules = itertools.accumulate(splitted, "{}.{}".format) for m in modules: maybe_reload(m)