@@ -398,12 +398,12 @@ class CCmd(Command[Context], _Group, metaclass=CogCommandType, _root=True):
398398
399399 Also called :class:`CogCmd`
400400 """
401- def __init__ (self , func : Optional [ AsyncCallable ] = None , ** kwargs ):
402- super (). __init__ ( func = func , ** kwargs )
403- for i in self . __class__ . __fut_sub_cmds__ . values ( ):
404- # -- Let errors be raised ; DESC:: [This handles all the stuff that is
405- self . add_command ( i ) # usually done for an instance in a cog]
406- i . cogcmd = self
401+ def copy (self ):
402+ ret = super (Command , self ). copy ( )
403+ for cmd in map ( lambda x : x . copy (), self . commands ):
404+ ret . add_command ( cmd )
405+ cmd . cogcmd = ret
406+ return ret
407407
408408 async def on_subcommand_error (self , ctx : Context , error : CommandError ) -> Any :
409409 """|overridecoro|
@@ -431,7 +431,7 @@ async def subcommand_after_invoke(self, ctx: Context) -> Any:
431431
432432## Decorators ##
433433
434- G = TypeVar ("G" , bound = _Command )
434+ G = TypeVar ("G" , bound = Command )
435435
436436def inject (** kwargs ) -> Callable [[Type [G ]], G ]:
437437 """This is a Decorator.
@@ -466,5 +466,10 @@ class MyCmd(Command):
466466 def decorator (cls : Type [G ]) -> G :
467467 if isinstance (cls , _Command ):
468468 raise TypeError ("Can not inject a command instance, expected a <class 'type'>" )
469+ if issubclass (cls , CCmd ):
470+ self = cls (** kwargs )
471+ for i in cls .__fut_sub_cmds__ .values ():
472+ self .add_command (i )
473+ i .cogcmd = self
469474 return cls (** kwargs )
470475 return decorator
0 commit comments