mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-10-21 16:03:10 +00:00
[commands] Make Command a descriptor for #426.
This commit is contained in:
@@ -651,7 +651,6 @@ class Bot(GroupMixin, discord.Client):
|
|||||||
for name, member in members:
|
for name, member in members:
|
||||||
# register commands the cog has
|
# register commands the cog has
|
||||||
if isinstance(member, Command):
|
if isinstance(member, Command):
|
||||||
member.instance = cog
|
|
||||||
if member.parent is None:
|
if member.parent is None:
|
||||||
self.add_command(member)
|
self.add_command(member)
|
||||||
continue
|
continue
|
||||||
@@ -699,7 +698,6 @@ class Bot(GroupMixin, discord.Client):
|
|||||||
for name, member in members:
|
for name, member in members:
|
||||||
# remove commands the cog has
|
# remove commands the cog has
|
||||||
if isinstance(member, Command):
|
if isinstance(member, Command):
|
||||||
member.instance = None
|
|
||||||
if member.parent is None:
|
if member.parent is None:
|
||||||
self.remove_command(member.name)
|
self.remove_command(member.name)
|
||||||
continue
|
continue
|
||||||
|
@@ -163,6 +163,11 @@ class Command:
|
|||||||
finally:
|
finally:
|
||||||
ctx.bot.dispatch('command_error', error, ctx)
|
ctx.bot.dispatch('command_error', error, ctx)
|
||||||
|
|
||||||
|
def __get__(self, instance, owner):
|
||||||
|
if instance is not None:
|
||||||
|
self.instance = instance
|
||||||
|
return self
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def do_conversion(self, ctx, converter, argument):
|
def do_conversion(self, ctx, converter, argument):
|
||||||
if converter is bool:
|
if converter is bool:
|
||||||
|
Reference in New Issue
Block a user