diff --git a/sopel/modules/reload.py b/sopel/modules/reload.py index 2d264bb932..befb8f9cc4 100644 --- a/sopel/modules/reload.py +++ b/sopel/modules/reload.py @@ -46,7 +46,10 @@ def f_reload(bot, trigger): bot.setup() return bot.reply('done') - if name not in sys.modules and name not in sopel.loader.enumerate_modules( + # Use OR instead of AND because modules that fail to load will not have been + # added to sys.modules; `reload_module_tree` should not even be reached if + # reload is attempted on a module that failed to load in the first place. + if name not in sys.modules or name not in sopel.loader.enumerate_modules( bot.config): return bot.reply('"%s" not loaded, try the `load` command' % name)