File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed
Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ def __init_subclass__(cls, **kwargs):
4444 def __init__ (self , bot : "Bot" ):
4545 self .bot = bot
4646 resp = [getattr (self , x ) for x in dir (self )]
47- self .commands : typing .List [Command ] = [x for x in resp if isinstance (x , Command )]
47+ self .commands : typing .List [Command ] = [x for x in resp if isinstance (x , Command ) and not x . is_subcommand ]
4848 self .listeners : typing .List [Listener ] = [x for x in resp if isinstance (x , Listener )]
4949 self .interactions : typing .List ["InteractionCommand" ] = [x for x in resp if InteractionCommand is not None and isinstance (x , InteractionCommand )]
5050 self .callbacks : typing .List ["ComponentCallback" ] = [x for x in resp if ComponentCallback is not None and isinstance (x , ComponentCallback )]
Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ def __init__(self,
3232 self .addon_names : typing .List [str ] = []
3333 self .modules : typing .List [str ] = []
3434
35+ async def get_owners (self ) -> typing .List [dico .Snowflake ]:
36+ if not self .application :
37+ await self .request_current_bot_application_information ()
38+ return self .application .owner_ids if self .application .owner_ids else [self .application .owner .id ]
39+
3540 async def verify_prefix (self , message : dico .Message ):
3641 final_prefixes = [(await x (message )) if is_coro (x ) else x (message ) if inspect .isfunction (x ) else x for x in self .prefixes ]
3742 prefix_result = [* map (lambda x : message .content .startswith (x ), final_prefixes )]
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ def __init__(self,
99 func ,
1010 name : str ,
1111 checks : typing .Optional [typing .List [typing .Callable [[Context ], bool ]]] = None ,
12- aliases : typing .Optional [typing .List [str ]] = None ):
12+ aliases : typing .Optional [typing .List [str ]] = None ,
13+ is_subcommand : bool = False ):
1314 self .func = func
1415 self .name = name
1516 self .checks = checks or []
@@ -21,16 +22,20 @@ def __init__(self,
2122 if hasattr (func , "_checks" ):
2223 self .checks .extend (func ._checks )
2324 self .addon = None
25+ self .is_subcommand = is_subcommand
2426
2527 def subcommand (self , * args , ** kwargs ):
2628 def wrap (coro ):
2729 cmd = command (* args , ** kwargs )(coro )
30+ cmd .is_subcommand = True
2831 self .subcommands [cmd .name ] = cmd
2932 return cmd
3033 return wrap
3134
3235 def register_addon (self , addon ):
3336 self .addon = addon
37+ for x in self .subcommands .values ():
38+ x .register_addon (addon )
3439
3540 async def execute_error_handler (self , ctx , ex ):
3641 if not self .error_handler :
You can’t perform that action at this time.
0 commit comments