@@ -358,21 +358,24 @@ def _fill_data(self, data) -> ApplicationCommand:
358
358
return self
359
359
360
360
async def can_run (self , * args , ** kwargs ) -> bool :
361
+ #if self.cog:
362
+ # args = (self.cog, *args)
361
363
check_func = kwargs .pop ('__func' , self )
362
364
checks = getattr (check_func , '__commands_checks__' , getattr (self .func , '__commands_checks__' , None ))
363
365
if not checks :
364
366
return True
365
-
366
367
return await async_all (check (* args ) for check in checks )
367
368
368
369
async def invoke (self , interaction , * args , ** kwargs ):
369
- if self .cog is not None :
370
- args = (self .cog , interaction , * args )
371
- else :
372
- args = (interaction , * args )
370
+ if not self .func :
371
+ return
372
+ args = (interaction , * args )
373
373
try :
374
374
if await self .can_run (* args ):
375
- await self .func (* args , ** kwargs )
375
+ if self .cog :
376
+ await self .func (self .cog , * args , ** kwargs )
377
+ else :
378
+ await self .func (* args , ** kwargs )
376
379
except Exception as exc :
377
380
if hasattr (self , 'on_error' ):
378
381
if self .cog is not None :
@@ -840,8 +843,8 @@ def to_dict(self):
840
843
return base
841
844
842
845
async def can_run (self , * args , ** kwargs ):
843
- if self .cog is not None :
844
- args = (self .cog , * args )
846
+ # if self.cog is not None:
847
+ # args = (self.cog, *args)
845
848
check_func = kwargs .pop ('__func' , self )
846
849
checks = getattr (check_func , '__commands_checks__' , getattr (self .func , '__commands_checks__' , None ))
847
850
if not checks :
@@ -850,13 +853,15 @@ async def can_run(self, *args, **kwargs):
850
853
return await async_all (check (* args , ** kwargs ) for check in checks )
851
854
852
855
async def invoke (self , interaction , * args , ** kwargs ):
853
- if self .cog is not None :
854
- args = (self .cog , interaction , * args )
855
- else :
856
- args = (interaction , * args )
856
+ if not self .func :
857
+ return
858
+ args = (interaction , * args )
857
859
try :
858
860
if await self .can_run (* args ):
859
- await self .func (* args , ** kwargs )
861
+ if self .cog :
862
+ await self .func (self .cog , * args , ** kwargs )
863
+ else :
864
+ await self .func (* args , ** kwargs )
860
865
except Exception as exc :
861
866
if hasattr (self , 'on_error' ):
862
867
if self .cog is not None :
@@ -886,10 +891,7 @@ async def invoke_autocomplete(self, interaction, *args, **kwargs):
886
891
warnings .warn (f'Sub-Command { self .name } of { self .parent } has options with autocomplete enabled but no autocomplete function.' )
887
892
return
888
893
889
- if self .cog is not None :
890
- args = (self .cog , interaction , * args )
891
- else :
892
- args = (interaction , * args )
894
+ args = (interaction , * args )
893
895
try :
894
896
if await self .can_run (* args , __func = self .autocomplete_func ):
895
897
await self .autocomplete_func (* args , ** kwargs )
@@ -1096,10 +1098,7 @@ async def invoke_autocomplete(self, interaction, *args, **kwargs):
1096
1098
if self .autocomplete_func is None :
1097
1099
warnings .warn (f'Application Command { self .name } has options with autocomplete enabled but no autocomplete function.' )
1098
1100
return
1099
- if self .cog is not None :
1100
- args = (self .cog , interaction , * args )
1101
- else :
1102
- args = (interaction , * args )
1101
+ args = (interaction , * args )
1103
1102
1104
1103
try :
1105
1104
if await self .can_run (* args , __func = self .autocomplete_func ):
@@ -1154,14 +1153,13 @@ def _filter_id_out(argument):
1154
1153
async def invoke (self , interaction , * args , ** kwargs ):
1155
1154
if not self .func :
1156
1155
return
1157
- if self .cog is not None :
1158
- args = (self .cog , interaction , * args )
1159
- else :
1160
- args = (interaction , * args )
1161
-
1156
+ args = (interaction , * args )
1162
1157
try :
1163
1158
if await self .can_run (* args ):
1164
- await self .func (* args , ** kwargs )
1159
+ if self .cog :
1160
+ await self .func (self .cog , * args , ** kwargs )
1161
+ else :
1162
+ await self .func (* args , ** kwargs )
1165
1163
except Exception as exc :
1166
1164
if hasattr (self , 'on_error' ):
1167
1165
if self .cog is not None :
0 commit comments