[V3 Core] Fix unload_extension for module-less cogs (#1984)

Fixes #1943

This just skips cogs when  `__module__` is None. Also:
- backported rapptz/discord.py#621
- moved RPC handler unregister to remove_cog()
- raise an exception when a load would overwrite an existing extension
This commit is contained in:
Caleb Johnson
2018-08-07 20:26:14 -04:00
committed by Toby Harradine
parent aec3ad382a
commit 872cce784a
2 changed files with 25 additions and 22 deletions

View File

@@ -111,7 +111,7 @@ class RPCMixin:
super().__init__(**kwargs)
self.rpc = RPC()
self.rpc_handlers = {} # Lowered cog name to method
self.rpc_handlers = {} # Uppercase cog name to method
def register_rpc_handler(self, method):
"""
@@ -132,6 +132,7 @@ class RPCMixin:
self.rpc.add_method(method)
cog_name = method.__self__.__class__.__name__.upper()
if cog_name not in self.rpc_handlers:
self.rpc_handlers[cog_name] = []