@@ -385,7 +385,6 @@ def __init__(self, func: Callable, *args, **kwargs) -> None:
385
385
validate_chat_input_description (description )
386
386
self .description : str = description
387
387
self .parent = kwargs .get ('parent' )
388
- self .is_subcommand : bool = self .parent is not None
389
388
390
389
self .cog = None
391
390
@@ -472,6 +471,10 @@ def _is_typing_union(self, annotation):
472
471
def _is_typing_optional (self , annotation ):
473
472
return self ._is_typing_union (annotation ) and type (None ) in annotation .__args__ # type: ignore
474
473
474
+ @property
475
+ def is_subcommand (self ) -> bool :
476
+ return self .parent is not None
477
+
475
478
def to_dict (self ) -> Dict :
476
479
as_dict = {
477
480
"name" : self .name ,
@@ -719,8 +722,15 @@ class SlashCommandGroup(ApplicationCommand, Option):
719
722
720
723
def __new__ (cls , * args , ** kwargs ) -> SlashCommandGroup :
721
724
self = super ().__new__ (cls )
722
-
723
725
self .__original_kwargs__ = kwargs .copy ()
726
+
727
+ self .__initial_commands__ = []
728
+ for i , c in cls .__dict__ .items ():
729
+ if isinstance (c , (SlashCommand , SlashCommandGroup )):
730
+ print (c .parent )
731
+ c .parent = self
732
+ self .__initial_commands__ .append (c )
733
+
724
734
return self
725
735
726
736
def __init__ (
@@ -738,7 +748,7 @@ def __init__(
738
748
name = name ,
739
749
description = description ,
740
750
)
741
- self .subcommands : List [Union [SlashCommand , SlashCommandGroup ]] = []
751
+ self .subcommands : List [Union [SlashCommand , SlashCommandGroup ]] = self . __initial_commands__
742
752
self .guild_ids = guild_ids
743
753
self .parent = parent
744
754
self .checks = []
0 commit comments