64
64
from .hybrid import hybrid_command , hybrid_group , HybridCommand , HybridGroup
65
65
66
66
if TYPE_CHECKING :
67
- from typing_extensions import Self
67
+ from typing_extensions import Self , Unpack
68
68
69
69
import importlib .machinery
70
70
80
80
MaybeAwaitableFunc ,
81
81
)
82
82
from .core import Command
83
- from .hybrid import CommandCallback , ContextT , P
83
+ from .hybrid import CommandCallback , ContextT , P , _HybridCommandDecoratorKwargs , _HybridGroupDecoratorKwargs
84
+ from discord .client import _ClientOptions
85
+ from discord .shard import _AutoShardedClientOptions
84
86
85
87
_Prefix = Union [Iterable [str ], str ]
86
88
_PrefixCallable = MaybeAwaitableFunc [[BotT , Message ], _Prefix ]
87
89
PrefixType = Union [_Prefix , _PrefixCallable [BotT ]]
88
90
91
+ class _BotOptions (_ClientOptions , total = False ):
92
+ owner_id : int
93
+ owner_ids : Collection [int ]
94
+ strip_after_prefix : bool
95
+ case_insensitive : bool
96
+
97
+ class _AutoShardedBotOptions (_AutoShardedClientOptions , _BotOptions ):
98
+ ...
99
+
100
+
89
101
__all__ = (
90
102
'when_mentioned' ,
91
103
'when_mentioned_or' ,
@@ -169,7 +181,7 @@ def __init__(
169
181
allowed_contexts : app_commands .AppCommandContext = MISSING ,
170
182
allowed_installs : app_commands .AppInstallationType = MISSING ,
171
183
intents : discord .Intents ,
172
- ** options : Any ,
184
+ ** options : Unpack [ _BotOptions ] ,
173
185
) -> None :
174
186
super ().__init__ (intents = intents , ** options )
175
187
self .command_prefix : PrefixType [BotT ] = command_prefix # type: ignore
@@ -281,7 +293,7 @@ def hybrid_command(
281
293
name : Union [str , app_commands .locale_str ] = MISSING ,
282
294
with_app_command : bool = True ,
283
295
* args : Any ,
284
- ** kwargs : Any ,
296
+ ** kwargs : Unpack [ _HybridCommandDecoratorKwargs ], # type: ignore # name, with_app_command
285
297
) -> Callable [[CommandCallback [Any , ContextT , P , T ]], HybridCommand [Any , P , T ]]:
286
298
"""A shortcut decorator that invokes :func:`~discord.ext.commands.hybrid_command` and adds it to
287
299
the internal command list via :meth:`add_command`.
@@ -293,8 +305,8 @@ def hybrid_command(
293
305
"""
294
306
295
307
def decorator (func : CommandCallback [Any , ContextT , P , T ]):
296
- kwargs .setdefault ('parent' , self )
297
- result = hybrid_command (name = name , * args , with_app_command = with_app_command , ** kwargs )(func )
308
+ kwargs .setdefault ('parent' , self ) # type: ignore # parent is not for the user to set
309
+ result = hybrid_command (name = name , * args , with_app_command = with_app_command , ** kwargs )(func ) # type: ignore # name, with_app_command
298
310
self .add_command (result )
299
311
return result
300
312
@@ -305,7 +317,7 @@ def hybrid_group(
305
317
name : Union [str , app_commands .locale_str ] = MISSING ,
306
318
with_app_command : bool = True ,
307
319
* args : Any ,
308
- ** kwargs : Any ,
320
+ ** kwargs : Unpack [ _HybridGroupDecoratorKwargs ], # type: ignore # name, with_app_command
309
321
) -> Callable [[CommandCallback [Any , ContextT , P , T ]], HybridGroup [Any , P , T ]]:
310
322
"""A shortcut decorator that invokes :func:`~discord.ext.commands.hybrid_group` and adds it to
311
323
the internal command list via :meth:`add_command`.
@@ -317,8 +329,8 @@ def hybrid_group(
317
329
"""
318
330
319
331
def decorator (func : CommandCallback [Any , ContextT , P , T ]):
320
- kwargs .setdefault ('parent' , self )
321
- result = hybrid_group (name = name , * args , with_app_command = with_app_command , ** kwargs )(func )
332
+ kwargs .setdefault ('parent' , self ) # type: ignore # parent is not for the user to set
333
+ result = hybrid_group (name = name , * args , with_app_command = with_app_command , ** kwargs )(func ) # type: ignore # name, with_app_command
322
334
self .add_command (result )
323
335
return result
324
336
@@ -1527,4 +1539,18 @@ class AutoShardedBot(BotBase, discord.AutoShardedClient):
1527
1539
.. versionadded:: 2.0
1528
1540
"""
1529
1541
1530
- pass
1542
+ if TYPE_CHECKING :
1543
+
1544
+ def __init__ (
1545
+ self ,
1546
+ command_prefix : PrefixType [BotT ],
1547
+ * ,
1548
+ help_command : Optional [HelpCommand ] = _default ,
1549
+ tree_cls : Type [app_commands .CommandTree [Any ]] = app_commands .CommandTree ,
1550
+ description : Optional [str ] = None ,
1551
+ allowed_contexts : app_commands .AppCommandContext = MISSING ,
1552
+ allowed_installs : app_commands .AppInstallationType = MISSING ,
1553
+ intents : discord .Intents ,
1554
+ ** kwargs : Unpack [_AutoShardedBotOptions ],
1555
+ ) -> None :
1556
+ ...
0 commit comments