def reload(name: str):
""" Reload a plugin.
This must be called from an on_reload function or coroutine.
"""
if name in plugins:
# Remove all registered commands
if hasattr(plugins[name], "__commands"):
delattr(plugins[name], "__commands")
# Remove all registered events from the given plugin
for event_name, funcs in events.items():
for func in funcs:
if func.__module__.endswith(name):
events[event_name].remove(func)
plugins[name] = importlib.reload(plugins[name])
logging.debug("Reloaded plugin {}".format(name))
评论列表
文章目录