Browse Source

[commands] Unload cog when command registration fails in _inject

pull/8265/head
Sebastian Law 3 years ago
committed by GitHub
parent
commit
9c109ae59b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      discord/ext/commands/cog.py

3
discord/ext/commands/cog.py

@ -616,6 +616,9 @@ class Cog(metaclass=CogMeta):
for to_undo in self.__cog_commands__[:index]: for to_undo in self.__cog_commands__[:index]:
if to_undo.parent is None: if to_undo.parent is None:
bot.remove_command(to_undo.name) bot.remove_command(to_undo.name)
try:
await maybe_coroutine(self.cog_unload)
finally:
raise e raise e
# check if we're overriding the default # check if we're overriding the default

Loading…
Cancel
Save