65
65
66
66
import typing_extensions
67
67
68
- _ClientT = typing .TypeVar ("_ClientT" , bound = "Client" )
69
-
70
68
class _MessageContextMakerProto (typing .Protocol ):
71
69
def __call__ (
72
70
self ,
@@ -1104,7 +1102,7 @@ async def declare_application_commands(
1104
1102
1105
1103
return responses
1106
1104
1107
- def set_auto_defer_after (self : _ClientT , time : typing .Optional [float ], / ) -> _ClientT :
1105
+ def set_auto_defer_after (self , time : typing .Optional [float ], / ) -> typing_extensions . Self :
1108
1106
"""Set when this client should automatically defer execution of commands.
1109
1107
1110
1108
.. warning::
@@ -1119,7 +1117,7 @@ def set_auto_defer_after(self: _ClientT, time: typing.Optional[float], /) -> _Cl
1119
1117
self ._auto_defer_after = float (time ) if time is not None else None
1120
1118
return self
1121
1119
1122
- def set_ephemeral_default (self : _ClientT , state : bool , / ) -> _ClientT :
1120
+ def set_ephemeral_default (self , state : bool , / ) -> typing_extensions . Self :
1123
1121
"""Set whether slash contexts spawned by this client should default to ephemeral responses.
1124
1122
1125
1123
Parameters
@@ -1139,7 +1137,7 @@ def set_ephemeral_default(self: _ClientT, state: bool, /) -> _ClientT:
1139
1137
self ._defaults_to_ephemeral = state
1140
1138
return self
1141
1139
1142
- def set_hikari_trait_injectors (self : _ClientT , bot : hikari_traits .RESTAware , / ) -> _ClientT :
1140
+ def set_hikari_trait_injectors (self , bot : hikari_traits .RESTAware , / ) -> typing_extensions . Self :
1143
1141
"""Set type based dependency injection based on the hikari traits found in `bot`.
1144
1142
1145
1143
This is a short hand for calling `Client.add_type_dependency` for all
@@ -1156,7 +1154,7 @@ def set_hikari_trait_injectors(self: _ClientT, bot: hikari_traits.RESTAware, /)
1156
1154
1157
1155
return self
1158
1156
1159
- def set_interaction_not_found (self : _ClientT , message : typing .Optional [str ], / ) -> _ClientT :
1157
+ def set_interaction_not_found (self , message : typing .Optional [str ], / ) -> typing_extensions . Self :
1160
1158
"""Set the response message for when an interaction command is not found.
1161
1159
1162
1160
.. warning::
@@ -1172,7 +1170,7 @@ def set_interaction_not_found(self: _ClientT, message: typing.Optional[str], /)
1172
1170
self ._interaction_not_found = message
1173
1171
return self
1174
1172
1175
- def set_message_accepts (self : _ClientT , accepts : MessageAcceptsEnum , / ) -> _ClientT :
1173
+ def set_message_accepts (self , accepts : MessageAcceptsEnum , / ) -> typing_extensions . Self :
1176
1174
"""Set the kind of messages commands should be executed based on.
1177
1175
1178
1176
Parameters
@@ -1186,7 +1184,9 @@ def set_message_accepts(self: _ClientT, accepts: MessageAcceptsEnum, /) -> _Clie
1186
1184
self ._accepts = accepts
1187
1185
return self
1188
1186
1189
- def set_message_ctx_maker (self : _ClientT , maker : _MessageContextMakerProto = context .MessageContext , / ) -> _ClientT :
1187
+ def set_message_ctx_maker (
1188
+ self , maker : _MessageContextMakerProto = context .MessageContext , /
1189
+ ) -> typing_extensions .Self :
1190
1190
"""Set the message context maker to use when creating context for a message.
1191
1191
1192
1192
.. warning::
@@ -1209,7 +1209,7 @@ def set_message_ctx_maker(self: _ClientT, maker: _MessageContextMakerProto = con
1209
1209
self ._make_message_context = maker
1210
1210
return self
1211
1211
1212
- def set_slash_ctx_maker (self : _ClientT , maker : _SlashContextMakerProto = context .SlashContext , / ) -> _ClientT :
1212
+ def set_slash_ctx_maker (self , maker : _SlashContextMakerProto = context .SlashContext , / ) -> typing_extensions . Self :
1213
1213
"""Set the slash context maker to use when creating context for a slash command.
1214
1214
1215
1215
.. warning::
@@ -1232,7 +1232,7 @@ def set_slash_ctx_maker(self: _ClientT, maker: _SlashContextMakerProto = context
1232
1232
self ._make_slash_context = maker
1233
1233
return self
1234
1234
1235
- def set_human_only (self : _ClientT , value : bool = True ) -> _ClientT :
1235
+ def set_human_only (self , value : bool = True ) -> typing_extensions . Self :
1236
1236
"""Set whether or not message commands execution should be limited to "human" users.
1237
1237
1238
1238
.. note::
@@ -1258,7 +1258,7 @@ def set_human_only(self: _ClientT, value: bool = True) -> _ClientT:
1258
1258
1259
1259
return self
1260
1260
1261
- def add_check (self : _ClientT , check : _CheckSig , / ) -> _ClientT :
1261
+ def add_check (self , check : _CheckSig , / ) -> typing_extensions . Self :
1262
1262
"""Add a generic check to this client.
1263
1263
1264
1264
This will be applied to both message and slash command execution.
@@ -1280,7 +1280,7 @@ def add_check(self: _ClientT, check: _CheckSig, /) -> _ClientT:
1280
1280
1281
1281
return self
1282
1282
1283
- def remove_check (self : _ClientT , check : _CheckSig , / ) -> _ClientT :
1283
+ def remove_check (self , check : _CheckSig , / ) -> typing_extensions . Self :
1284
1284
"""Remove a check from the client.
1285
1285
1286
1286
Parameters
@@ -1317,7 +1317,9 @@ def with_check(self, check: _CheckSigT, /) -> _CheckSigT:
1317
1317
async def check (self , ctx : tanjun_abc .Context , / ) -> bool :
1318
1318
return await utilities .gather_checks (ctx , self ._checks )
1319
1319
1320
- def add_component (self : _ClientT , component : tanjun_abc .Component , / , * , add_injector : bool = False ) -> _ClientT :
1320
+ def add_component (
1321
+ self , component : tanjun_abc .Component , / , * , add_injector : bool = False
1322
+ ) -> typing_extensions .Self :
1321
1323
"""Add a component to this client.
1322
1324
1323
1325
Parameters
@@ -1354,7 +1356,7 @@ def get_component_by_name(self, name: str, /) -> typing.Optional[tanjun_abc.Comp
1354
1356
# <<inherited docstring from tanjun.abc.Client>>.
1355
1357
return self ._components .get (name )
1356
1358
1357
- def remove_component (self : _ClientT , component : tanjun_abc .Component , / ) -> _ClientT :
1359
+ def remove_component (self , component : tanjun_abc .Component , / ) -> typing_extensions . Self :
1358
1360
# <<inherited docstring from tanjun.abc.Client>>.
1359
1361
stored_component = self ._components .get (component .name )
1360
1362
if not stored_component or stored_component != component :
@@ -1373,13 +1375,13 @@ def remove_component(self: _ClientT, component: tanjun_abc.Component, /) -> _Cli
1373
1375
1374
1376
return self
1375
1377
1376
- def remove_component_by_name (self : _ClientT , name : str , / ) -> _ClientT :
1378
+ def remove_component_by_name (self , name : str , / ) -> typing_extensions . Self :
1377
1379
# <<inherited docstring from tanjun.abc.Client>>.
1378
1380
return self .remove_component (self ._components [name ])
1379
1381
1380
1382
def add_client_callback (
1381
- self : _ClientT , name : typing .Union [str , tanjun_abc .ClientCallbackNames ], callback : _MetaEventSig , /
1382
- ) -> _ClientT :
1383
+ self , name : typing .Union [str , tanjun_abc .ClientCallbackNames ], callback : _MetaEventSig , /
1384
+ ) -> typing_extensions . Self :
1383
1385
# <<inherited docstring from tanjun.abc.Client>>.
1384
1386
descriptor = injecting .CallbackDescriptor (callback )
1385
1387
name = name .casefold ()
@@ -1415,8 +1417,8 @@ def get_client_callbacks(
1415
1417
return ()
1416
1418
1417
1419
def remove_client_callback (
1418
- self : _ClientT , name : typing .Union [str , tanjun_abc .ClientCallbackNames ], callback : _MetaEventSig , /
1419
- ) -> _ClientT :
1420
+ self , name : typing .Union [str , tanjun_abc .ClientCallbackNames ], callback : _MetaEventSig , /
1421
+ ) -> typing_extensions . Self :
1420
1422
# <<inherited docstring from tanjun.abc.Client>>.
1421
1423
name = name .casefold ()
1422
1424
self ._client_callbacks [name ].remove (typing .cast ("injecting.CallbackDescriptor[None]" , callback ))
@@ -1435,7 +1437,9 @@ def decorator(callback: _MetaEventSigT, /) -> _MetaEventSigT:
1435
1437
1436
1438
return decorator
1437
1439
1438
- def add_listener (self : _ClientT , event_type : type [_EventT ], callback : _ListenerCallbackSig [_EventT ], / ) -> _ClientT :
1440
+ def add_listener (
1441
+ self , event_type : type [_EventT ], callback : _ListenerCallbackSig [_EventT ], /
1442
+ ) -> typing_extensions .Self :
1439
1443
# <<inherited docstring from tanjun.abc.Client>>.
1440
1444
injected : injecting .SelfInjectingCallback [None ] = injecting .SelfInjectingCallback (self , callback )
1441
1445
try :
@@ -1453,8 +1457,8 @@ def add_listener(self: _ClientT, event_type: type[_EventT], callback: _ListenerC
1453
1457
return self
1454
1458
1455
1459
def remove_listener (
1456
- self : _ClientT , event_type : type [_EventT ], callback : _ListenerCallbackSig [_EventT ], /
1457
- ) -> _ClientT :
1460
+ self , event_type : type [_EventT ], callback : _ListenerCallbackSig [_EventT ], /
1461
+ ) -> typing_extensions . Self :
1458
1462
# <<inherited docstring from tanjun.abc.Client>>.
1459
1463
index = self ._listeners [event_type ].index (typing .cast ("injecting.SelfInjectingCallback[None]" , callback ))
1460
1464
registered_callback = self ._listeners [event_type ].pop (index )
@@ -1477,7 +1481,7 @@ def decorator(callback: _ListenerCallbackSigT, /) -> _ListenerCallbackSigT:
1477
1481
1478
1482
return decorator
1479
1483
1480
- def add_prefix (self : _ClientT , prefixes : typing .Union [collections .Iterable [str ], str ], / ) -> _ClientT :
1484
+ def add_prefix (self , prefixes : typing .Union [collections .Iterable [str ], str ], / ) -> typing_extensions . Self :
1481
1485
"""Add a prefix used to filter message command calls.
1482
1486
1483
1487
This will be matched against the first character(s) in a message's
@@ -1504,7 +1508,7 @@ def add_prefix(self: _ClientT, prefixes: typing.Union[collections.Iterable[str],
1504
1508
1505
1509
return self
1506
1510
1507
- def remove_prefix (self : _ClientT , prefix : str , / ) -> _ClientT :
1511
+ def remove_prefix (self , prefix : str , / ) -> typing_extensions . Self :
1508
1512
"""Remove a message content prefix from the client.
1509
1513
1510
1514
Parameters
@@ -1525,7 +1529,7 @@ def remove_prefix(self: _ClientT, prefix: str, /) -> _ClientT:
1525
1529
self ._prefixes .remove (prefix )
1526
1530
return self
1527
1531
1528
- def set_prefix_getter (self : _ClientT , getter : typing .Optional [_PrefixGetterSig ], / ) -> _ClientT :
1532
+ def set_prefix_getter (self , getter : typing .Optional [_PrefixGetterSig ], / ) -> typing_extensions . Self :
1529
1533
"""Set the callback used to retrieve message prefixes set for the relevant guild.
1530
1534
1531
1535
Parameters
@@ -1753,7 +1757,7 @@ async def fetch_rest_application_id(self) -> hikari.Snowflake:
1753
1757
1754
1758
return self ._cached_application_id
1755
1759
1756
- def set_hooks (self : _ClientT , hooks : typing .Optional [tanjun_abc .AnyHooks ], / ) -> _ClientT :
1760
+ def set_hooks (self , hooks : typing .Optional [tanjun_abc .AnyHooks ], / ) -> typing_extensions . Self :
1757
1761
"""Set the general command execution hooks for this client.
1758
1762
1759
1763
The callbacks within this hook will be added to every slash and message
@@ -1774,7 +1778,7 @@ def set_hooks(self: _ClientT, hooks: typing.Optional[tanjun_abc.AnyHooks], /) ->
1774
1778
self ._hooks = hooks
1775
1779
return self
1776
1780
1777
- def set_slash_hooks (self : _ClientT , hooks : typing .Optional [tanjun_abc .SlashHooks ], / ) -> _ClientT :
1781
+ def set_slash_hooks (self , hooks : typing .Optional [tanjun_abc .SlashHooks ], / ) -> typing_extensions . Self :
1778
1782
"""Set the slash command execution hooks for this client.
1779
1783
1780
1784
The callbacks within this hook will be added to every slash command
@@ -1796,7 +1800,7 @@ def set_slash_hooks(self: _ClientT, hooks: typing.Optional[tanjun_abc.SlashHooks
1796
1800
self ._slash_hooks = hooks
1797
1801
return self
1798
1802
1799
- def set_message_hooks (self : _ClientT , hooks : typing .Optional [tanjun_abc .MessageHooks ], / ) -> _ClientT :
1803
+ def set_message_hooks (self , hooks : typing .Optional [tanjun_abc .MessageHooks ], / ) -> typing_extensions . Self :
1800
1804
"""Set the message command execution hooks for this client.
1801
1805
1802
1806
The callbacks within this hook will be added to every message command
@@ -1842,7 +1846,7 @@ def _load_module(self, module: types.ModuleType, module_repr: str) -> None:
1842
1846
if not found :
1843
1847
raise RuntimeError (f"Didn't find any loaders in { module_repr } " )
1844
1848
1845
- def load_modules (self : _ClientT , * modules : typing .Union [str , pathlib .Path ], _log : bool = True ) -> _ClientT :
1849
+ def load_modules (self , * modules : typing .Union [str , pathlib .Path ], _log : bool = True ) -> typing_extensions . Self :
1846
1850
# <<inherited docstring from tanjun.abc.Client>>.
1847
1851
for module_path in modules :
1848
1852
if isinstance (module_path , str ):
@@ -1889,7 +1893,7 @@ def _unload_module(self, module: types.ModuleType, module_repr: str) -> None:
1889
1893
if not found :
1890
1894
raise RuntimeError (f"Didn't find any unloaders in { module_repr } " )
1891
1895
1892
- def unload_modules (self : _ClientT , * modules : typing .Union [str , pathlib .Path ], _log : bool = True ) -> _ClientT :
1896
+ def unload_modules (self , * modules : typing .Union [str , pathlib .Path ], _log : bool = True ) -> typing_extensions . Self :
1893
1897
# <<inherited docstring from tanjun.abc.Client>>.
1894
1898
for module_path in modules :
1895
1899
if isinstance (module_path , str ):
@@ -1909,7 +1913,7 @@ def unload_modules(self: _ClientT, *modules: typing.Union[str, pathlib.Path], _l
1909
1913
1910
1914
return self
1911
1915
1912
- def reload_modules (self : _ClientT , * modules : typing .Union [str , pathlib .Path ]) -> _ClientT :
1916
+ def reload_modules (self , * modules : typing .Union [str , pathlib .Path ]) -> typing_extensions . Self :
1913
1917
# <<inherited docstring from tanjun.abc.Client>>.
1914
1918
for module_path in modules :
1915
1919
if isinstance (module_path , str ):
0 commit comments