hikari-arc 1.3.4__py3-none-any.whl → 2.0.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 +80 -83
- arc/abc/__init__.py +14 -14
- arc/abc/client.py +114 -147
- arc/abc/command.py +54 -11
- arc/abc/option.py +11 -8
- arc/abc/plugin.py +84 -14
- arc/client.py +45 -17
- arc/command/__init__.py +29 -25
- arc/command/message.py +11 -6
- arc/command/option/__init__.py +28 -17
- arc/command/option/custom/__init__.py +11 -1
- arc/command/option/custom/emoji.py +96 -0
- 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 +23 -15
- arc/command/user.py +11 -6
- arc/context/__init__.py +1 -1
- arc/context/autocomplete.py +19 -5
- arc/context/base.py +72 -15
- arc/internal/__init__.py +1 -10
- arc/internal/about.py +1 -6
- arc/internal/options.py +1 -0
- arc/internal/sigparse.py +4 -0
- 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 -1
- arc/utils/hooks/limiters.py +3 -3
- arc/utils/loops.py +2 -2
- arc/utils/ratelimiter.py +1 -1
- {hikari_arc-1.3.4.dist-info → hikari_arc-2.0.0.dist-info}/METADATA +32 -35
- hikari_arc-2.0.0.dist-info/RECORD +59 -0
- {hikari_arc-1.3.4.dist-info → hikari_arc-2.0.0.dist-info}/WHEEL +1 -2
- hikari_arc-1.3.4.dist-info/RECORD +0 -59
- hikari_arc-1.3.4.dist-info/top_level.txt +0 -1
- {hikari_arc-1.3.4.dist-info → hikari_arc-2.0.0.dist-info/licenses}/LICENSE +0 -0
arc/__init__.py
CHANGED
|
@@ -31,6 +31,7 @@ from .command import (
|
|
|
31
31
|
ChannelParams,
|
|
32
32
|
ColorParams,
|
|
33
33
|
ColourParams,
|
|
34
|
+
EmojiParams,
|
|
34
35
|
FloatParams,
|
|
35
36
|
IntParams,
|
|
36
37
|
MemberParams,
|
|
@@ -75,7 +76,7 @@ from .errors import (
|
|
|
75
76
|
)
|
|
76
77
|
from .events import ArcEvent, CommandErrorEvent, StartedEvent, StoppingEvent
|
|
77
78
|
from .extension import loader, unloader
|
|
78
|
-
from .internal.about import
|
|
79
|
+
from .internal.about import __version__
|
|
79
80
|
from .locale import (
|
|
80
81
|
CommandLocaleRequest,
|
|
81
82
|
CustomLocaleRequest,
|
|
@@ -106,112 +107,108 @@ from .utils import (
|
|
|
106
107
|
)
|
|
107
108
|
|
|
108
109
|
__all__ = (
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
"__license__",
|
|
113
|
-
"__url__",
|
|
114
|
-
"__maintainer__",
|
|
115
|
-
"AutodeferMode",
|
|
116
|
-
"inject",
|
|
117
|
-
"Injector",
|
|
110
|
+
"ArcError",
|
|
111
|
+
"ArcEvent",
|
|
112
|
+
"AttachmentParams",
|
|
118
113
|
"AutocompleteData",
|
|
119
|
-
"
|
|
120
|
-
"
|
|
121
|
-
"InjectorOverridingContext",
|
|
114
|
+
"AutocompleteError",
|
|
115
|
+
"AutodeferMode",
|
|
122
116
|
"BoolParams",
|
|
123
|
-
"
|
|
124
|
-
"StrParams",
|
|
125
|
-
"FloatParams",
|
|
126
|
-
"UserParams",
|
|
117
|
+
"BotMissingPermissionsError",
|
|
127
118
|
"ChannelParams",
|
|
128
|
-
"RoleParams",
|
|
129
|
-
"MentionableParams",
|
|
130
|
-
"AttachmentParams",
|
|
131
|
-
"MemberParams",
|
|
132
119
|
"ColorParams",
|
|
133
120
|
"ColourParams",
|
|
134
|
-
"
|
|
135
|
-
"SlashGroup",
|
|
136
|
-
"SlashSubCommand",
|
|
137
|
-
"SlashSubGroup",
|
|
138
|
-
"MessageCommand",
|
|
139
|
-
"UserCommand",
|
|
140
|
-
"message_command",
|
|
141
|
-
"user_command",
|
|
142
|
-
"slash_command",
|
|
143
|
-
"slash_subcommand",
|
|
144
|
-
"GatewayClientBase",
|
|
145
|
-
"RESTClientBase",
|
|
146
|
-
"GatewayClient",
|
|
147
|
-
"RESTClient",
|
|
148
|
-
"OptionType",
|
|
149
|
-
"ArcError",
|
|
150
|
-
"AutocompleteError",
|
|
151
|
-
"UnderCooldownError",
|
|
152
|
-
"InvokerMissingPermissionsError",
|
|
153
|
-
"GuildOnlyError",
|
|
154
|
-
"NotOwnerError",
|
|
155
|
-
"DMOnlyError",
|
|
121
|
+
"CommandErrorEvent",
|
|
156
122
|
"CommandInvokeError",
|
|
123
|
+
"CommandLocaleRequest",
|
|
157
124
|
"CommandPublishFailedError",
|
|
158
|
-
"
|
|
159
|
-
"
|
|
160
|
-
"
|
|
161
|
-
"
|
|
162
|
-
"NoResponseIssuedError",
|
|
163
|
-
"ResponseAlreadyIssuedError",
|
|
125
|
+
"Context",
|
|
126
|
+
"CustomLocaleRequest",
|
|
127
|
+
"DMOnlyError",
|
|
128
|
+
"EmojiParams",
|
|
164
129
|
"ExtensionError",
|
|
165
130
|
"ExtensionLoadError",
|
|
166
131
|
"ExtensionUnloadError",
|
|
167
|
-
"
|
|
168
|
-
"
|
|
169
|
-
"
|
|
170
|
-
"PluginBase",
|
|
171
|
-
"RESTPluginBase",
|
|
172
|
-
"GatewayPluginBase",
|
|
173
|
-
"loader",
|
|
174
|
-
"unloader",
|
|
175
|
-
"ArcEvent",
|
|
176
|
-
"CommandErrorEvent",
|
|
177
|
-
"StartedEvent",
|
|
178
|
-
"StoppingEvent",
|
|
179
|
-
"InteractionResponse",
|
|
132
|
+
"FloatParams",
|
|
133
|
+
"GatewayClient",
|
|
134
|
+
"GatewayClientBase",
|
|
180
135
|
"GatewayContext",
|
|
181
|
-
"RESTContext",
|
|
182
|
-
"RESTPlugin",
|
|
183
136
|
"GatewayPlugin",
|
|
137
|
+
"GatewayPluginBase",
|
|
138
|
+
"GlobalCommandPublishFailedError",
|
|
139
|
+
"GuildCommandPublishFailedError",
|
|
140
|
+
"GuildOnlyError",
|
|
141
|
+
"HookAbortError",
|
|
184
142
|
"HookResult",
|
|
143
|
+
"Injector",
|
|
144
|
+
"InjectorOverridingContext",
|
|
145
|
+
"IntParams",
|
|
146
|
+
"InteractionResponse",
|
|
147
|
+
"InteractionResponseError",
|
|
148
|
+
"InvokerMissingPermissionsError",
|
|
185
149
|
"LocaleRequest",
|
|
186
150
|
"LocaleRequestType",
|
|
187
151
|
"LocaleResponse",
|
|
188
|
-
"
|
|
189
|
-
"
|
|
152
|
+
"MaxConcurrencyReachedError",
|
|
153
|
+
"MemberParams",
|
|
154
|
+
"MentionableParams",
|
|
155
|
+
"MessageCommand",
|
|
156
|
+
"NoResponseIssuedError",
|
|
157
|
+
"NotOwnerError",
|
|
158
|
+
"Option",
|
|
159
|
+
"OptionConverterFailureError",
|
|
190
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__",
|
|
191
181
|
"abc",
|
|
192
|
-
"utils",
|
|
193
|
-
"command",
|
|
194
|
-
"ext",
|
|
195
|
-
"with_hook",
|
|
196
|
-
"with_post_hook",
|
|
197
182
|
"bot_has_permissions",
|
|
198
|
-
"
|
|
199
|
-
"guild_only",
|
|
200
|
-
"has_permissions",
|
|
201
|
-
"owner_only",
|
|
202
|
-
"global_limiter",
|
|
203
|
-
"guild_limiter",
|
|
204
|
-
"with_concurrency_limit",
|
|
183
|
+
"channel_concurrency",
|
|
205
184
|
"channel_limiter",
|
|
206
|
-
"
|
|
207
|
-
"
|
|
185
|
+
"command",
|
|
186
|
+
"custom_concurrency",
|
|
208
187
|
"custom_limiter",
|
|
188
|
+
"dm_only",
|
|
189
|
+
"ext",
|
|
209
190
|
"global_concurrency",
|
|
210
|
-
"
|
|
191
|
+
"global_limiter",
|
|
211
192
|
"guild_concurrency",
|
|
212
|
-
"
|
|
193
|
+
"guild_limiter",
|
|
194
|
+
"guild_only",
|
|
195
|
+
"has_permissions",
|
|
196
|
+
"inject",
|
|
197
|
+
"loader",
|
|
213
198
|
"member_concurrency",
|
|
214
|
-
"
|
|
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",
|
|
215
212
|
)
|
|
216
213
|
|
|
217
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
|
|
|
@@ -1354,7 +1321,7 @@ class Client(t.Generic[AppT], abc.ABC):
|
|
|
1354
1321
|
dir_path = pathlib.Path(dir_path)
|
|
1355
1322
|
|
|
1356
1323
|
try:
|
|
1357
|
-
dir_path.
|
|
1324
|
+
dir_path.absolute().relative_to(pathlib.Path.cwd())
|
|
1358
1325
|
except ValueError:
|
|
1359
1326
|
raise ExtensionLoadError("dir_path must be relative to the current working directory.")
|
|
1360
1327
|
|