hikari-arc 1.4.0__py3-none-any.whl → 2.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- arc/__init__.py +79 -84
- arc/abc/__init__.py +14 -14
- arc/abc/client.py +113 -146
- arc/abc/command.py +54 -11
- arc/abc/option.py +6 -6
- arc/abc/plugin.py +84 -14
- arc/client.py +45 -17
- arc/command/__init__.py +27 -27
- arc/command/message.py +10 -5
- arc/command/option/__init__.py +16 -16
- arc/command/option/custom/__init__.py +2 -2
- arc/command/option/float.py +1 -1
- arc/command/option/int.py +1 -1
- arc/command/option/str.py +1 -1
- arc/command/slash.py +18 -10
- arc/command/user.py +10 -5
- arc/context/__init__.py +1 -1
- arc/context/autocomplete.py +19 -5
- arc/context/base.py +77 -15
- arc/internal/__init__.py +1 -10
- arc/internal/about.py +1 -6
- arc/internal/sync.py +6 -3
- arc/internal/version.py +1 -1
- arc/locale.py +3 -3
- arc/plugin.py +15 -7
- arc/utils/__init__.py +19 -19
- arc/utils/concurrency_limiter.py +7 -7
- arc/utils/hooks/__init__.py +8 -8
- arc/utils/hooks/basic.py +1 -4
- arc/utils/hooks/limiters.py +3 -3
- arc/utils/loops.py +2 -2
- arc/utils/ratelimiter.py +1 -1
- {hikari_arc-1.4.0.dist-info → hikari_arc-2.1.0.dist-info}/METADATA +20 -34
- hikari_arc-2.1.0.dist-info/RECORD +59 -0
- {hikari_arc-1.4.0.dist-info → hikari_arc-2.1.0.dist-info}/WHEEL +1 -2
- hikari_arc-1.4.0.dist-info/RECORD +0 -60
- hikari_arc-1.4.0.dist-info/top_level.txt +0 -1
- {hikari_arc-1.4.0.dist-info → hikari_arc-2.1.0.dist-info/licenses}/LICENSE +0 -0
arc/__init__.py
CHANGED
|
@@ -76,7 +76,7 @@ from .errors import (
|
|
|
76
76
|
)
|
|
77
77
|
from .events import ArcEvent, CommandErrorEvent, StartedEvent, StoppingEvent
|
|
78
78
|
from .extension import loader, unloader
|
|
79
|
-
from .internal.about import
|
|
79
|
+
from .internal.about import __version__
|
|
80
80
|
from .locale import (
|
|
81
81
|
CommandLocaleRequest,
|
|
82
82
|
CustomLocaleRequest,
|
|
@@ -107,113 +107,108 @@ from .utils import (
|
|
|
107
107
|
)
|
|
108
108
|
|
|
109
109
|
__all__ = (
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
"__license__",
|
|
114
|
-
"__url__",
|
|
115
|
-
"__maintainer__",
|
|
116
|
-
"AutodeferMode",
|
|
117
|
-
"inject",
|
|
118
|
-
"Injector",
|
|
110
|
+
"ArcError",
|
|
111
|
+
"ArcEvent",
|
|
112
|
+
"AttachmentParams",
|
|
119
113
|
"AutocompleteData",
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"InjectorOverridingContext",
|
|
114
|
+
"AutocompleteError",
|
|
115
|
+
"AutodeferMode",
|
|
123
116
|
"BoolParams",
|
|
124
|
-
"
|
|
125
|
-
"StrParams",
|
|
126
|
-
"FloatParams",
|
|
127
|
-
"UserParams",
|
|
117
|
+
"BotMissingPermissionsError",
|
|
128
118
|
"ChannelParams",
|
|
129
|
-
"RoleParams",
|
|
130
|
-
"MentionableParams",
|
|
131
|
-
"AttachmentParams",
|
|
132
|
-
"MemberParams",
|
|
133
119
|
"ColorParams",
|
|
134
120
|
"ColourParams",
|
|
135
|
-
"
|
|
136
|
-
"SlashCommand",
|
|
137
|
-
"SlashGroup",
|
|
138
|
-
"SlashSubCommand",
|
|
139
|
-
"SlashSubGroup",
|
|
140
|
-
"MessageCommand",
|
|
141
|
-
"UserCommand",
|
|
142
|
-
"message_command",
|
|
143
|
-
"user_command",
|
|
144
|
-
"slash_command",
|
|
145
|
-
"slash_subcommand",
|
|
146
|
-
"GatewayClientBase",
|
|
147
|
-
"RESTClientBase",
|
|
148
|
-
"GatewayClient",
|
|
149
|
-
"RESTClient",
|
|
150
|
-
"OptionType",
|
|
151
|
-
"ArcError",
|
|
152
|
-
"AutocompleteError",
|
|
153
|
-
"UnderCooldownError",
|
|
154
|
-
"InvokerMissingPermissionsError",
|
|
155
|
-
"GuildOnlyError",
|
|
156
|
-
"NotOwnerError",
|
|
157
|
-
"DMOnlyError",
|
|
121
|
+
"CommandErrorEvent",
|
|
158
122
|
"CommandInvokeError",
|
|
123
|
+
"CommandLocaleRequest",
|
|
159
124
|
"CommandPublishFailedError",
|
|
160
|
-
"
|
|
161
|
-
"
|
|
162
|
-
"
|
|
163
|
-
"
|
|
164
|
-
"NoResponseIssuedError",
|
|
165
|
-
"ResponseAlreadyIssuedError",
|
|
125
|
+
"Context",
|
|
126
|
+
"CustomLocaleRequest",
|
|
127
|
+
"DMOnlyError",
|
|
128
|
+
"EmojiParams",
|
|
166
129
|
"ExtensionError",
|
|
167
130
|
"ExtensionLoadError",
|
|
168
131
|
"ExtensionUnloadError",
|
|
169
|
-
"
|
|
170
|
-
"
|
|
171
|
-
"
|
|
172
|
-
"PluginBase",
|
|
173
|
-
"RESTPluginBase",
|
|
174
|
-
"GatewayPluginBase",
|
|
175
|
-
"loader",
|
|
176
|
-
"unloader",
|
|
177
|
-
"ArcEvent",
|
|
178
|
-
"CommandErrorEvent",
|
|
179
|
-
"StartedEvent",
|
|
180
|
-
"StoppingEvent",
|
|
181
|
-
"InteractionResponse",
|
|
132
|
+
"FloatParams",
|
|
133
|
+
"GatewayClient",
|
|
134
|
+
"GatewayClientBase",
|
|
182
135
|
"GatewayContext",
|
|
183
|
-
"RESTContext",
|
|
184
|
-
"RESTPlugin",
|
|
185
136
|
"GatewayPlugin",
|
|
137
|
+
"GatewayPluginBase",
|
|
138
|
+
"GlobalCommandPublishFailedError",
|
|
139
|
+
"GuildCommandPublishFailedError",
|
|
140
|
+
"GuildOnlyError",
|
|
141
|
+
"HookAbortError",
|
|
186
142
|
"HookResult",
|
|
143
|
+
"Injector",
|
|
144
|
+
"InjectorOverridingContext",
|
|
145
|
+
"IntParams",
|
|
146
|
+
"InteractionResponse",
|
|
147
|
+
"InteractionResponseError",
|
|
148
|
+
"InvokerMissingPermissionsError",
|
|
187
149
|
"LocaleRequest",
|
|
188
150
|
"LocaleRequestType",
|
|
189
151
|
"LocaleResponse",
|
|
190
|
-
"
|
|
191
|
-
"
|
|
152
|
+
"MaxConcurrencyReachedError",
|
|
153
|
+
"MemberParams",
|
|
154
|
+
"MentionableParams",
|
|
155
|
+
"MessageCommand",
|
|
156
|
+
"NoResponseIssuedError",
|
|
157
|
+
"NotOwnerError",
|
|
158
|
+
"Option",
|
|
159
|
+
"OptionConverterFailureError",
|
|
192
160
|
"OptionLocaleRequest",
|
|
161
|
+
"OptionType",
|
|
162
|
+
"PluginBase",
|
|
163
|
+
"RESTClient",
|
|
164
|
+
"RESTClientBase",
|
|
165
|
+
"RESTContext",
|
|
166
|
+
"RESTPlugin",
|
|
167
|
+
"RESTPluginBase",
|
|
168
|
+
"ResponseAlreadyIssuedError",
|
|
169
|
+
"RoleParams",
|
|
170
|
+
"SlashCommand",
|
|
171
|
+
"SlashGroup",
|
|
172
|
+
"SlashSubCommand",
|
|
173
|
+
"SlashSubGroup",
|
|
174
|
+
"StartedEvent",
|
|
175
|
+
"StoppingEvent",
|
|
176
|
+
"StrParams",
|
|
177
|
+
"UnderCooldownError",
|
|
178
|
+
"UserCommand",
|
|
179
|
+
"UserParams",
|
|
180
|
+
"__version__",
|
|
193
181
|
"abc",
|
|
194
|
-
"utils",
|
|
195
|
-
"command",
|
|
196
|
-
"ext",
|
|
197
|
-
"with_hook",
|
|
198
|
-
"with_post_hook",
|
|
199
182
|
"bot_has_permissions",
|
|
200
|
-
"
|
|
201
|
-
"guild_only",
|
|
202
|
-
"has_permissions",
|
|
203
|
-
"owner_only",
|
|
204
|
-
"global_limiter",
|
|
205
|
-
"guild_limiter",
|
|
206
|
-
"with_concurrency_limit",
|
|
183
|
+
"channel_concurrency",
|
|
207
184
|
"channel_limiter",
|
|
208
|
-
"
|
|
209
|
-
"
|
|
185
|
+
"command",
|
|
186
|
+
"custom_concurrency",
|
|
210
187
|
"custom_limiter",
|
|
188
|
+
"dm_only",
|
|
189
|
+
"ext",
|
|
211
190
|
"global_concurrency",
|
|
212
|
-
"
|
|
191
|
+
"global_limiter",
|
|
213
192
|
"guild_concurrency",
|
|
214
|
-
"
|
|
193
|
+
"guild_limiter",
|
|
194
|
+
"guild_only",
|
|
195
|
+
"has_permissions",
|
|
196
|
+
"inject",
|
|
197
|
+
"loader",
|
|
215
198
|
"member_concurrency",
|
|
216
|
-
"
|
|
199
|
+
"member_limiter",
|
|
200
|
+
"message_command",
|
|
201
|
+
"owner_only",
|
|
202
|
+
"slash_command",
|
|
203
|
+
"slash_subcommand",
|
|
204
|
+
"unloader",
|
|
205
|
+
"user_command",
|
|
206
|
+
"user_concurrency",
|
|
207
|
+
"user_limiter",
|
|
208
|
+
"utils",
|
|
209
|
+
"with_concurrency_limit",
|
|
210
|
+
"with_hook",
|
|
211
|
+
"with_post_hook",
|
|
217
212
|
)
|
|
218
213
|
|
|
219
214
|
# MIT License
|
arc/abc/__init__.py
CHANGED
|
@@ -19,30 +19,30 @@ from .option import (
|
|
|
19
19
|
from .plugin import PluginBase
|
|
20
20
|
|
|
21
21
|
__all__ = (
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
22
|
+
"CallableCommandBase",
|
|
23
|
+
"CallableCommandProto",
|
|
24
|
+
"Client",
|
|
25
25
|
"CommandBase",
|
|
26
|
+
"CommandOptionBase",
|
|
26
27
|
"CommandProto",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
28
|
+
"ConcurrencyLimiterProto",
|
|
29
|
+
"ConverterOption",
|
|
30
|
+
"HasConcurrencyLimiter",
|
|
31
|
+
"HasErrorHandler",
|
|
32
|
+
"HookResult",
|
|
33
|
+
"Hookable",
|
|
34
|
+
"Injector",
|
|
35
|
+
"LimiterProto",
|
|
29
36
|
"Option",
|
|
30
37
|
"OptionBase",
|
|
31
|
-
"OptionType",
|
|
32
|
-
"CommandOptionBase",
|
|
33
|
-
"ConverterOption",
|
|
34
38
|
"OptionParams",
|
|
39
|
+
"OptionType",
|
|
35
40
|
"OptionWithChoices",
|
|
36
41
|
"OptionWithChoicesParams",
|
|
37
|
-
"Client",
|
|
38
42
|
"PluginBase",
|
|
39
|
-
"
|
|
40
|
-
"HookResult",
|
|
41
|
-
"LimiterProto",
|
|
42
|
-
"ConcurrencyLimiterProto",
|
|
43
|
+
"with_concurrency_limit",
|
|
43
44
|
"with_hook",
|
|
44
45
|
"with_post_hook",
|
|
45
|
-
"with_concurrency_limit",
|
|
46
46
|
)
|
|
47
47
|
|
|
48
48
|
# MIT License
|
arc/abc/client.py
CHANGED
|
@@ -22,7 +22,6 @@ from arc.command.slash import SlashCommand, SlashGroup, SlashSubCommand, SlashSu
|
|
|
22
22
|
from arc.command.user import UserCommand
|
|
23
23
|
from arc.context import AutodeferMode, Context
|
|
24
24
|
from arc.errors import ExtensionLoadError, ExtensionUnloadError
|
|
25
|
-
from arc.internal.deprecation import warn_deprecate
|
|
26
25
|
from arc.internal.sync import _sync_commands
|
|
27
26
|
from arc.internal.types import (
|
|
28
27
|
AppT,
|
|
@@ -37,7 +36,6 @@ from arc.internal.types import (
|
|
|
37
36
|
PostHookT,
|
|
38
37
|
ResponseBuilderT,
|
|
39
38
|
)
|
|
40
|
-
from arc.internal.version import Version
|
|
41
39
|
from arc.locale import CommandLocaleRequest, LocaleResponse, OptionLocaleRequest
|
|
42
40
|
|
|
43
41
|
if t.TYPE_CHECKING:
|
|
@@ -78,9 +76,12 @@ class Client(t.Generic[AppT], abc.ABC):
|
|
|
78
76
|
is_nsfw : bool
|
|
79
77
|
Whether to mark commands as NSFW
|
|
80
78
|
This applies to all commands, and can be overridden on a per-command basis.
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
integration_types : t.Sequence[hikari.ApplicationIntegrationType] | hikari.UndefinedType
|
|
80
|
+
The integration types that commands will support the installation of
|
|
83
81
|
This applies to all commands, and can be overridden on a per-command basis.
|
|
82
|
+
invocation_contexts : t.Sequence[hikari.ApplicationContextType] | hikari.UndefinedType
|
|
83
|
+
The context types that commands can be invoked in
|
|
84
|
+
This applies to all commands, and can be overridden on a per-command basis
|
|
84
85
|
provided_locales : t.Sequence[hikari.Locale] | None
|
|
85
86
|
The locales that will be provided to the client by locale provider callbacks
|
|
86
87
|
injector : alluka.Client | None
|
|
@@ -90,30 +91,30 @@ class Client(t.Generic[AppT], abc.ABC):
|
|
|
90
91
|
|
|
91
92
|
__slots__: t.Sequence[str] = (
|
|
92
93
|
"_app",
|
|
93
|
-
"_default_enabled_guilds",
|
|
94
94
|
"_application",
|
|
95
|
-
"_slash_commands",
|
|
96
|
-
"_message_commands",
|
|
97
|
-
"_user_commands",
|
|
98
|
-
"_injector",
|
|
99
95
|
"_autosync",
|
|
100
|
-
"
|
|
101
|
-
"
|
|
96
|
+
"_cmd_settings",
|
|
97
|
+
"_command_locale_provider",
|
|
98
|
+
"_concurrency_limiter",
|
|
99
|
+
"_custom_locale_provider",
|
|
100
|
+
"_default_enabled_guilds",
|
|
101
|
+
"_error_handler",
|
|
102
102
|
"_hooks",
|
|
103
|
-
"_post_hooks",
|
|
104
103
|
"_injection_hooks",
|
|
104
|
+
"_injector",
|
|
105
|
+
"_loaded_extensions",
|
|
106
|
+
"_message_commands",
|
|
107
|
+
"_option_locale_provider",
|
|
105
108
|
"_owner_ids",
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"_shutdown_hooks",
|
|
109
|
+
"_plugins",
|
|
110
|
+
"_post_hooks",
|
|
109
111
|
"_provided_locales",
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
"_custom_locale_provider",
|
|
113
|
-
"_cmd_settings",
|
|
114
|
-
"_concurrency_limiter",
|
|
115
|
-
"_tasks",
|
|
112
|
+
"_shutdown_hooks",
|
|
113
|
+
"_slash_commands",
|
|
116
114
|
"_started",
|
|
115
|
+
"_startup_hooks",
|
|
116
|
+
"_tasks",
|
|
117
|
+
"_user_commands",
|
|
117
118
|
)
|
|
118
119
|
|
|
119
120
|
def __init__(
|
|
@@ -126,7 +127,14 @@ class Client(t.Generic[AppT], abc.ABC):
|
|
|
126
127
|
autodefer: bool | AutodeferMode = True,
|
|
127
128
|
default_permissions: hikari.Permissions | hikari.UndefinedType = hikari.UNDEFINED,
|
|
128
129
|
is_nsfw: bool = False,
|
|
129
|
-
|
|
130
|
+
integration_types: t.Sequence[hikari.ApplicationIntegrationType] = [
|
|
131
|
+
hikari.ApplicationIntegrationType.GUILD_INSTALL
|
|
132
|
+
],
|
|
133
|
+
invocation_contexts: t.Sequence[hikari.ApplicationContextType] = [
|
|
134
|
+
hikari.ApplicationContextType.GUILD,
|
|
135
|
+
hikari.ApplicationContextType.PRIVATE_CHANNEL,
|
|
136
|
+
hikari.ApplicationContextType.BOT_DM,
|
|
137
|
+
],
|
|
130
138
|
provided_locales: t.Sequence[hikari.Locale] | None = None,
|
|
131
139
|
injector: alluka.abc.Client | None = None,
|
|
132
140
|
) -> None:
|
|
@@ -141,8 +149,9 @@ class Client(t.Generic[AppT], abc.ABC):
|
|
|
141
149
|
self._cmd_settings = _CommandSettings(
|
|
142
150
|
autodefer=AutodeferMode(autodefer),
|
|
143
151
|
default_permissions=default_permissions,
|
|
152
|
+
invocation_contexts=invocation_contexts,
|
|
153
|
+
integration_types=integration_types,
|
|
144
154
|
is_nsfw=is_nsfw,
|
|
145
|
-
is_dm_enabled=is_dm_enabled,
|
|
146
155
|
)
|
|
147
156
|
|
|
148
157
|
self._slash_commands: dict[str, SlashCommandLike[te.Self]] = {}
|
|
@@ -160,8 +169,8 @@ class Client(t.Generic[AppT], abc.ABC):
|
|
|
160
169
|
self._application: hikari.Application | None = None
|
|
161
170
|
self._error_handler: ErrorHandlerCallbackT[te.Self] | None = None
|
|
162
171
|
self._concurrency_limiter: ConcurrencyLimiterProto[te.Self] | None = None
|
|
163
|
-
self._startup_hooks: list[LifeCycleHookT[te.Self]
|
|
164
|
-
self._shutdown_hooks: list[LifeCycleHookT[te.Self]
|
|
172
|
+
self._startup_hooks: list[LifeCycleHookT[te.Self]] = []
|
|
173
|
+
self._shutdown_hooks: list[LifeCycleHookT[te.Self]] = []
|
|
165
174
|
self._command_locale_provider: CommandLocaleRequestT | None = None
|
|
166
175
|
self._option_locale_provider: OptionLocaleRequestT | None = None
|
|
167
176
|
self._custom_locale_provider: CustomLocaleRequestT | None = None
|
|
@@ -291,12 +300,11 @@ class Client(t.Generic[AppT], abc.ABC):
|
|
|
291
300
|
|
|
292
301
|
try:
|
|
293
302
|
for hook in self._startup_hooks:
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
traceback.print_exc()
|
|
303
|
+
try:
|
|
304
|
+
await hook(self)
|
|
305
|
+
except Exception as e:
|
|
306
|
+
logger.error(f"Error in startup hook '{hook.__name__}': {e}")
|
|
307
|
+
traceback.print_exc()
|
|
300
308
|
finally:
|
|
301
309
|
self._started.set()
|
|
302
310
|
|
|
@@ -305,12 +313,11 @@ class Client(t.Generic[AppT], abc.ABC):
|
|
|
305
313
|
Reserved for internal shutdown logic.
|
|
306
314
|
"""
|
|
307
315
|
for hook in self._shutdown_hooks:
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
traceback.print_exc()
|
|
316
|
+
try:
|
|
317
|
+
await hook(self)
|
|
318
|
+
except Exception as e:
|
|
319
|
+
logger.error(f"Error in shutdown hook '{hook.__name__}': {e}")
|
|
320
|
+
traceback.print_exc()
|
|
314
321
|
|
|
315
322
|
for task in self._tasks:
|
|
316
323
|
task.cancel()
|
|
@@ -442,6 +449,66 @@ class Client(t.Generic[AppT], abc.ABC):
|
|
|
442
449
|
|
|
443
450
|
return await command._on_autocomplete(interaction)
|
|
444
451
|
|
|
452
|
+
@t.overload
|
|
453
|
+
def find_command(
|
|
454
|
+
self, command_type: t.Literal[hikari.CommandType.USER], full_name: str
|
|
455
|
+
) -> UserCommand[te.Self] | None: ...
|
|
456
|
+
|
|
457
|
+
@t.overload
|
|
458
|
+
def find_command(
|
|
459
|
+
self, command_type: t.Literal[hikari.CommandType.MESSAGE], full_name: str
|
|
460
|
+
) -> MessageCommand[te.Self] | None: ...
|
|
461
|
+
|
|
462
|
+
@t.overload
|
|
463
|
+
def find_command(
|
|
464
|
+
self, command_type: t.Literal[hikari.CommandType.SLASH], full_name: str
|
|
465
|
+
) -> SlashCommand[te.Self] | SlashSubCommand[te.Self] | SlashGroup[te.Self] | SlashSubGroup[te.Self] | None: ...
|
|
466
|
+
|
|
467
|
+
def find_command(self, command_type: hikari.CommandType, full_name: str) -> t.Any | None:
|
|
468
|
+
"""Find a given command by it's fully qualified name.
|
|
469
|
+
|
|
470
|
+
For instance, to locate a slash subcommand with the name `foo` in a group `bar`, you would pass `bar foo`.
|
|
471
|
+
|
|
472
|
+
Parameters
|
|
473
|
+
----------
|
|
474
|
+
command_type : hikari.CommandType
|
|
475
|
+
The type of command to search for.
|
|
476
|
+
full_name : str
|
|
477
|
+
The fully qualified name of the command.
|
|
478
|
+
|
|
479
|
+
Returns
|
|
480
|
+
-------
|
|
481
|
+
t.Any | None
|
|
482
|
+
The command if found, otherwise None.
|
|
483
|
+
"""
|
|
484
|
+
if command_type is hikari.CommandType.MESSAGE:
|
|
485
|
+
return self._message_commands.get(full_name)
|
|
486
|
+
if command_type is hikari.CommandType.USER:
|
|
487
|
+
return self._user_commands.get(full_name)
|
|
488
|
+
|
|
489
|
+
if command_type is not hikari.CommandType.SLASH:
|
|
490
|
+
return None
|
|
491
|
+
|
|
492
|
+
command_parts = full_name.split(" ")
|
|
493
|
+
|
|
494
|
+
if len(command_parts) == 1:
|
|
495
|
+
return self._slash_commands.get(command_parts[0])
|
|
496
|
+
|
|
497
|
+
base_cmd = self._slash_commands.get(command_parts[0])
|
|
498
|
+
|
|
499
|
+
if not isinstance(base_cmd, SlashGroup):
|
|
500
|
+
return None
|
|
501
|
+
|
|
502
|
+
subcmd = base_cmd.children.get(command_parts[1])
|
|
503
|
+
|
|
504
|
+
if len(command_parts) == 2:
|
|
505
|
+
return subcmd
|
|
506
|
+
|
|
507
|
+
if not isinstance(subcmd, SlashSubGroup):
|
|
508
|
+
return None
|
|
509
|
+
|
|
510
|
+
return subcmd.children.get(command_parts[2])
|
|
511
|
+
|
|
445
512
|
@t.overload
|
|
446
513
|
def walk_commands(
|
|
447
514
|
self, command_type: t.Literal[hikari.CommandType.USER], *, callable_only: bool = False
|
|
@@ -461,7 +528,7 @@ class Client(t.Generic[AppT], abc.ABC):
|
|
|
461
528
|
|
|
462
529
|
@t.overload
|
|
463
530
|
def walk_commands(
|
|
464
|
-
self, command_type: t.Literal[hikari.CommandType.SLASH], *, callable_only: t.Literal[True]
|
|
531
|
+
self, command_type: t.Literal[hikari.CommandType.SLASH], *, callable_only: t.Literal[True]
|
|
465
532
|
) -> t.Iterator[SlashCommand[te.Self] | SlashSubCommand[te.Self]]: ...
|
|
466
533
|
|
|
467
534
|
def walk_commands( # noqa: C901
|
|
@@ -599,7 +666,8 @@ class Client(t.Generic[AppT], abc.ABC):
|
|
|
599
666
|
*,
|
|
600
667
|
guilds: t.Sequence[hikari.Snowflakeish | hikari.PartialGuild] | hikari.UndefinedType = hikari.UNDEFINED,
|
|
601
668
|
autodefer: bool | AutodeferMode | hikari.UndefinedType = hikari.UNDEFINED,
|
|
602
|
-
|
|
669
|
+
invocation_contexts: t.Sequence[hikari.ApplicationContextType] | hikari.UndefinedType = hikari.UNDEFINED,
|
|
670
|
+
integration_types: t.Sequence[hikari.ApplicationIntegrationType] | hikari.UndefinedType = hikari.UNDEFINED,
|
|
603
671
|
default_permissions: hikari.Permissions | hikari.UndefinedType = hikari.UNDEFINED,
|
|
604
672
|
name_localizations: t.Mapping[hikari.Locale, str] | None = None,
|
|
605
673
|
description_localizations: t.Mapping[hikari.Locale, str] | None = None,
|
|
@@ -618,8 +686,10 @@ class Client(t.Generic[AppT], abc.ABC):
|
|
|
618
686
|
autodefer : bool | AutodeferMode
|
|
619
687
|
If True, all commands in this group will automatically defer if it is taking longer than 2 seconds to respond.
|
|
620
688
|
This can be overridden on a per-subcommand basis.
|
|
621
|
-
|
|
622
|
-
|
|
689
|
+
integration_types : t.Sequence[hikari.ApplicationIntegrationType] | hikari.UndefinedType
|
|
690
|
+
The integration types this group supports the installation of
|
|
691
|
+
invocation_contexts : t.Sequence[hikari.ApplicationContextType] | hikari.UndefinedType
|
|
692
|
+
The context types this group can be invoked in
|
|
623
693
|
default_permissions : hikari.Permissions | hikari.UndefinedType
|
|
624
694
|
The default permissions for the slash command group
|
|
625
695
|
name_localizations : dict[hikari.Locale, str]
|
|
@@ -655,7 +725,8 @@ class Client(t.Generic[AppT], abc.ABC):
|
|
|
655
725
|
description=description,
|
|
656
726
|
guilds=guild_ids,
|
|
657
727
|
autodefer=AutodeferMode(autodefer) if isinstance(autodefer, bool) else autodefer,
|
|
658
|
-
|
|
728
|
+
invocation_contexts=invocation_contexts,
|
|
729
|
+
integration_types=integration_types,
|
|
659
730
|
default_permissions=default_permissions,
|
|
660
731
|
name_localizations=name_localizations or {},
|
|
661
732
|
description_localizations=description_localizations or {},
|
|
@@ -1013,110 +1084,6 @@ class Client(t.Generic[AppT], abc.ABC):
|
|
|
1013
1084
|
|
|
1014
1085
|
return decorator
|
|
1015
1086
|
|
|
1016
|
-
@t.overload
|
|
1017
|
-
def set_startup_hook(self, hook: LifeCycleHookT[te.Self]) -> te.Self: ...
|
|
1018
|
-
|
|
1019
|
-
@t.overload
|
|
1020
|
-
def set_startup_hook(self) -> t.Callable[[LifeCycleHookT[te.Self]], te.Self]: ...
|
|
1021
|
-
|
|
1022
|
-
def set_startup_hook(
|
|
1023
|
-
self, hook: LifeCycleHookT[te.Self] | None = None
|
|
1024
|
-
) -> te.Self | t.Callable[[LifeCycleHookT[te.Self]], te.Self]:
|
|
1025
|
-
"""Decorator to set the startup hook for this client.
|
|
1026
|
-
|
|
1027
|
-
This will be called when the client starts up.
|
|
1028
|
-
|
|
1029
|
-
!!! warning "Deprecation Notice"
|
|
1030
|
-
This method is deprecated and will be removed in version `2.0.0`.
|
|
1031
|
-
Use [`Client.add_startup_hook`][arc.client.Client.add_startup_hook] instead.
|
|
1032
|
-
|
|
1033
|
-
Parameters
|
|
1034
|
-
----------
|
|
1035
|
-
hook : LifeCycleHookT[te.Self]
|
|
1036
|
-
The startup hook to set.
|
|
1037
|
-
|
|
1038
|
-
Returns
|
|
1039
|
-
-------
|
|
1040
|
-
te.Self
|
|
1041
|
-
The client for chaining calls.
|
|
1042
|
-
|
|
1043
|
-
Example
|
|
1044
|
-
--------
|
|
1045
|
-
```py
|
|
1046
|
-
@client.set_startup_hook
|
|
1047
|
-
async def startup_hook(client: arc.GatewayClient) -> None:
|
|
1048
|
-
print("Client started up!")
|
|
1049
|
-
```
|
|
1050
|
-
|
|
1051
|
-
Or, as a function:
|
|
1052
|
-
|
|
1053
|
-
```py
|
|
1054
|
-
client.set_startup_hook(startup_hook)
|
|
1055
|
-
```
|
|
1056
|
-
"""
|
|
1057
|
-
warn_deprecate(what="set_startup_hook", when=Version(2, 0, 0), use_instead="add_startup_hook")
|
|
1058
|
-
|
|
1059
|
-
def decorator(handler: LifeCycleHookT[te.Self]) -> te.Self:
|
|
1060
|
-
self._startup_hooks[0] = handler
|
|
1061
|
-
return self
|
|
1062
|
-
|
|
1063
|
-
if hook is not None:
|
|
1064
|
-
return decorator(hook)
|
|
1065
|
-
|
|
1066
|
-
return decorator
|
|
1067
|
-
|
|
1068
|
-
@t.overload
|
|
1069
|
-
def set_shutdown_hook(self, hook: LifeCycleHookT[te.Self]) -> te.Self: ...
|
|
1070
|
-
|
|
1071
|
-
@t.overload
|
|
1072
|
-
def set_shutdown_hook(self) -> t.Callable[[LifeCycleHookT[te.Self]], te.Self]: ...
|
|
1073
|
-
|
|
1074
|
-
def set_shutdown_hook(
|
|
1075
|
-
self, hook: LifeCycleHookT[te.Self] | None = None
|
|
1076
|
-
) -> te.Self | t.Callable[[LifeCycleHookT[te.Self]], te.Self]:
|
|
1077
|
-
"""Decorator to set the shutdown hook for this client.
|
|
1078
|
-
|
|
1079
|
-
This will be called when the client shuts down.
|
|
1080
|
-
|
|
1081
|
-
!!! warning "Deprecation Notice"
|
|
1082
|
-
This method is deprecated and will be removed in version `2.0.0`.
|
|
1083
|
-
Use [`Client.add_shutdown_hook`][arc.client.Client.add_shutdown_hook] instead.
|
|
1084
|
-
|
|
1085
|
-
Parameters
|
|
1086
|
-
----------
|
|
1087
|
-
hook : LifeCycleHookT[te.Self]
|
|
1088
|
-
The shutdown hook to set.
|
|
1089
|
-
|
|
1090
|
-
Returns
|
|
1091
|
-
-------
|
|
1092
|
-
te.Self
|
|
1093
|
-
The client for chaining calls.
|
|
1094
|
-
|
|
1095
|
-
Example
|
|
1096
|
-
--------
|
|
1097
|
-
```py
|
|
1098
|
-
@client.set_shutdown_hook
|
|
1099
|
-
async def shutdown_hook(client: arc.GatewayClient) -> None:
|
|
1100
|
-
print("Client shut down!")
|
|
1101
|
-
```
|
|
1102
|
-
|
|
1103
|
-
Or, as a function:
|
|
1104
|
-
|
|
1105
|
-
```py
|
|
1106
|
-
client.set_shutdown_hook(shutdown_hook)
|
|
1107
|
-
```
|
|
1108
|
-
"""
|
|
1109
|
-
warn_deprecate(what="set_shutdown_hook", when=Version(2, 0, 0), use_instead="add_shutdown_hook")
|
|
1110
|
-
|
|
1111
|
-
def decorator(handler: LifeCycleHookT[te.Self]) -> te.Self:
|
|
1112
|
-
self._shutdown_hooks[0] = handler
|
|
1113
|
-
return self
|
|
1114
|
-
|
|
1115
|
-
if hook is not None:
|
|
1116
|
-
return decorator(hook)
|
|
1117
|
-
|
|
1118
|
-
return decorator
|
|
1119
|
-
|
|
1120
1087
|
@t.overload
|
|
1121
1088
|
def set_command_locale_provider(self, provider: CommandLocaleRequestT) -> te.Self: ...
|
|
1122
1089
|
|