Actually implement !reloadallmodules in modules.py

This commit is contained in:
jesopo 2018-09-24 13:18:15 +01:00
parent b7f7c9342b
commit 967ed65e00

View file

@ -57,18 +57,23 @@ class Module(object):
def reload_all(self, event): def reload_all(self, event):
reloaded = [] reloaded = []
failed = [] failed = []
for name in self.bot.modules.modules.keys(): for name in list(self.bot.modules.modules.keys()):
try: try:
self._reload(name) self._reload(name)
except ModuleManager.ModuleNotFoundException: except ModuleWarning:
failed.append continue
if not self._reload(event): except:
failed.append(name) failed.append(name)
else: continue
reloaded.append(name) reloaded.append(name)
event["stdout"].write("Reloaded modules: %s" % \ if reloaded and failed:
" ".join(modules_reloaded)) event["stdout"].write("Reloaded %d modules, %d failed" % (
len(reloaded), len(failed)))
elif failed:
event["stdout"].write("Failed to reload all modules")
else:
event["stdout"].write("Reloaded %d modules" % len(reloaded))
def enable(self, event): def enable(self, event):
name = event["args_split"][0].lower() name = event["args_split"][0].lower()