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/abc/command.py
CHANGED
|
@@ -186,7 +186,8 @@ class _CommandSettings:
|
|
|
186
186
|
autodefer: AutodeferMode | hikari.UndefinedType
|
|
187
187
|
default_permissions: hikari.Permissions | hikari.UndefinedType
|
|
188
188
|
is_nsfw: bool | hikari.UndefinedType
|
|
189
|
-
|
|
189
|
+
integration_types: t.Sequence[hikari.ApplicationIntegrationType] | hikari.UndefinedType
|
|
190
|
+
invocation_contexts: t.Sequence[hikari.ApplicationContextType] | hikari.UndefinedType
|
|
190
191
|
|
|
191
192
|
def apply(self, other: te.Self) -> te.Self:
|
|
192
193
|
"""Apply 'other' to this, copying all the non-undefined settings to it."""
|
|
@@ -196,13 +197,28 @@ class _CommandSettings:
|
|
|
196
197
|
if other.default_permissions is not hikari.UNDEFINED
|
|
197
198
|
else self.default_permissions,
|
|
198
199
|
is_nsfw=other.is_nsfw if other.is_nsfw is not hikari.UNDEFINED else self.is_nsfw,
|
|
199
|
-
|
|
200
|
+
integration_types=other.integration_types
|
|
201
|
+
if other.integration_types is not hikari.UNDEFINED
|
|
202
|
+
else self.integration_types,
|
|
203
|
+
invocation_contexts=other.invocation_contexts
|
|
204
|
+
if other.invocation_contexts is not hikari.UNDEFINED
|
|
205
|
+
else self.invocation_contexts,
|
|
200
206
|
)
|
|
201
207
|
|
|
202
208
|
@classmethod
|
|
203
209
|
def default(cls) -> te.Self:
|
|
204
210
|
"""Get the default command settings."""
|
|
205
|
-
return cls(
|
|
211
|
+
return cls(
|
|
212
|
+
autodefer=AutodeferMode.ON,
|
|
213
|
+
default_permissions=hikari.UNDEFINED,
|
|
214
|
+
is_nsfw=False,
|
|
215
|
+
integration_types=[hikari.ApplicationIntegrationType.GUILD_INSTALL],
|
|
216
|
+
invocation_contexts=[
|
|
217
|
+
hikari.ApplicationContextType.GUILD,
|
|
218
|
+
hikari.ApplicationContextType.BOT_DM,
|
|
219
|
+
hikari.ApplicationContextType.PRIVATE_CHANNEL,
|
|
220
|
+
],
|
|
221
|
+
)
|
|
206
222
|
|
|
207
223
|
|
|
208
224
|
@attr.define(slots=True, kw_only=True)
|
|
@@ -223,8 +239,15 @@ class CommandBase(
|
|
|
223
239
|
_autodefer: AutodeferMode | hikari.UndefinedType = attr.field(default=hikari.UNDEFINED, alias="autodefer")
|
|
224
240
|
"""If ON, this command will be automatically deferred if it takes longer than 2 seconds to respond."""
|
|
225
241
|
|
|
226
|
-
|
|
227
|
-
|
|
242
|
+
_integration_types: t.Sequence[hikari.ApplicationIntegrationType] | hikari.UndefinedType = attr.field(
|
|
243
|
+
default=hikari.UNDEFINED, alias="integration_types"
|
|
244
|
+
)
|
|
245
|
+
"""A list of integration types where the command can be installed in."""
|
|
246
|
+
|
|
247
|
+
_invocation_contexts: t.Sequence[hikari.ApplicationContextType] | hikari.UndefinedType = attr.field(
|
|
248
|
+
default=hikari.UNDEFINED, alias="invocation_contexts"
|
|
249
|
+
)
|
|
250
|
+
"""A list of context types where the command can be used in."""
|
|
228
251
|
|
|
229
252
|
_default_permissions: hikari.Permissions | hikari.UndefinedType = attr.field(
|
|
230
253
|
default=hikari.UNDEFINED, alias="default_permissions"
|
|
@@ -320,10 +343,28 @@ class CommandBase(
|
|
|
320
343
|
return settings.autodefer if settings.autodefer is not hikari.UNDEFINED else AutodeferMode.ON
|
|
321
344
|
|
|
322
345
|
@property
|
|
323
|
-
def
|
|
324
|
-
"""
|
|
346
|
+
def integration_types(self) -> t.Sequence[hikari.ApplicationIntegrationType]:
|
|
347
|
+
"""A list of integration types where the command can be installed in."""
|
|
325
348
|
settings = self._resolve_settings()
|
|
326
|
-
return
|
|
349
|
+
return (
|
|
350
|
+
settings.integration_types
|
|
351
|
+
if settings.integration_types is not hikari.UNDEFINED
|
|
352
|
+
else [hikari.ApplicationIntegrationType.GUILD_INSTALL]
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
@property
|
|
356
|
+
def invocation_contexts(self) -> t.Sequence[hikari.ApplicationContextType]:
|
|
357
|
+
"""A list of context types where the command can be used in."""
|
|
358
|
+
settings = self._resolve_settings()
|
|
359
|
+
return (
|
|
360
|
+
settings.invocation_contexts
|
|
361
|
+
if settings.invocation_contexts is not hikari.UNDEFINED
|
|
362
|
+
else [
|
|
363
|
+
hikari.ApplicationContextType.GUILD,
|
|
364
|
+
hikari.ApplicationContextType.BOT_DM,
|
|
365
|
+
hikari.ApplicationContextType.PRIVATE_CHANNEL,
|
|
366
|
+
]
|
|
367
|
+
)
|
|
327
368
|
|
|
328
369
|
@property
|
|
329
370
|
def default_permissions(self) -> hikari.Permissions | hikari.UndefinedType:
|
|
@@ -383,7 +424,8 @@ class CommandBase(
|
|
|
383
424
|
autodefer=self._autodefer,
|
|
384
425
|
default_permissions=self._default_permissions,
|
|
385
426
|
is_nsfw=self._is_nsfw,
|
|
386
|
-
|
|
427
|
+
integration_types=self._integration_types,
|
|
428
|
+
invocation_contexts=self._invocation_contexts,
|
|
387
429
|
)
|
|
388
430
|
)
|
|
389
431
|
|
|
@@ -488,7 +530,8 @@ class CommandBase(
|
|
|
488
530
|
"nsfw": self.is_nsfw,
|
|
489
531
|
"default_member_permissions": self.default_permissions,
|
|
490
532
|
"name_localizations": self.name_localizations,
|
|
491
|
-
"
|
|
533
|
+
"integration_types": self.integration_types,
|
|
534
|
+
"invocation_contexts": self.invocation_contexts,
|
|
492
535
|
}
|
|
493
536
|
|
|
494
537
|
@abc.abstractmethod
|
|
@@ -550,7 +593,7 @@ class CommandBase(
|
|
|
550
593
|
for hook in hooks:
|
|
551
594
|
res = await ctx._injection_ctx.call_with_async_di(hook, ctx)
|
|
552
595
|
|
|
553
|
-
res = t.cast(HookResult | None, res)
|
|
596
|
+
res = t.cast("HookResult | None", res)
|
|
554
597
|
|
|
555
598
|
if res and res._abort:
|
|
556
599
|
aborted = True
|
arc/abc/option.py
CHANGED
|
@@ -17,14 +17,14 @@ if t.TYPE_CHECKING:
|
|
|
17
17
|
from arc.abc.command import CommandProto
|
|
18
18
|
|
|
19
19
|
__all__ = (
|
|
20
|
+
"CommandOptionBase",
|
|
21
|
+
"ConverterOption",
|
|
20
22
|
"Option",
|
|
23
|
+
"OptionBase",
|
|
21
24
|
"OptionParams",
|
|
25
|
+
"OptionType",
|
|
22
26
|
"OptionWithChoices",
|
|
23
27
|
"OptionWithChoicesParams",
|
|
24
|
-
"OptionBase",
|
|
25
|
-
"CommandOptionBase",
|
|
26
|
-
"ConverterOption",
|
|
27
|
-
"OptionType",
|
|
28
28
|
)
|
|
29
29
|
|
|
30
30
|
T = t.TypeVar("T")
|
|
@@ -102,6 +102,9 @@ class OptionType(enum.IntEnum):
|
|
|
102
102
|
COLOR = 10002
|
|
103
103
|
"""Denotes a command option where the value will be a color."""
|
|
104
104
|
|
|
105
|
+
EMOJI = 10003
|
|
106
|
+
"""Denotes a command option where the value will be an emoji."""
|
|
107
|
+
|
|
105
108
|
@classmethod
|
|
106
109
|
def from_hikari(cls, option_type: hikari.OptionType) -> OptionType:
|
|
107
110
|
"""Convert a hikari.OptionType to an OptionType."""
|
|
@@ -133,7 +136,7 @@ class OptionParams(t.Generic[T]):
|
|
|
133
136
|
The description of the option in different locales
|
|
134
137
|
"""
|
|
135
138
|
|
|
136
|
-
__slots__: t.Sequence[str] = ("
|
|
139
|
+
__slots__: t.Sequence[str] = ("_description", "_description_localizations", "_name", "_name_localizations")
|
|
137
140
|
|
|
138
141
|
def __init__(
|
|
139
142
|
self,
|
|
@@ -191,7 +194,7 @@ class OptionWithChoicesParams(OptionParams[ChoiceT], t.Generic[ChoiceT, ClientT]
|
|
|
191
194
|
The callback for autocompleting the option.
|
|
192
195
|
"""
|
|
193
196
|
|
|
194
|
-
__slots__: t.Sequence[str] = ("
|
|
197
|
+
__slots__: t.Sequence[str] = ("_autocomplete_with", "_choices")
|
|
195
198
|
|
|
196
199
|
def __init__(
|
|
197
200
|
self,
|
|
@@ -248,8 +251,8 @@ class OptionBase(abc.ABC, t.Generic[T]):
|
|
|
248
251
|
"name": self.name,
|
|
249
252
|
"description": self.description,
|
|
250
253
|
"autocomplete": False,
|
|
251
|
-
"name_localizations": self.name_localizations,
|
|
252
|
-
"description_localizations": self.description_localizations,
|
|
254
|
+
"name_localizations": {str(key): value for key, value in self.name_localizations.items()},
|
|
255
|
+
"description_localizations": {str(key): value for key, value in self.description_localizations.items()},
|
|
253
256
|
}
|
|
254
257
|
|
|
255
258
|
def to_command_option(self) -> hikari.CommandOption:
|
arc/abc/plugin.py
CHANGED
|
@@ -41,8 +41,11 @@ class PluginBase(HasErrorHandler[ClientT], Hookable[ClientT], HasConcurrencyLimi
|
|
|
41
41
|
autodefer : bool | AutodeferMode
|
|
42
42
|
If True, all commands in this plugin will automatically defer if it is taking longer than 2 seconds to respond.
|
|
43
43
|
This can be overridden on a per-command basis.
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
integration_types : t.Sequence[hikari.ApplicationIntegrationType] | hikari.UndefinedType
|
|
45
|
+
The integration types that commands will support the installation of
|
|
46
|
+
This can be overridden on a per-command basis.
|
|
47
|
+
invocation_contexts : t.Sequence[hikari.ApplicationContextType] | hikari.UndefinedType
|
|
48
|
+
The context types that commands can be invoked in
|
|
46
49
|
This can be overridden on a per-command basis.
|
|
47
50
|
default_permissions : hikari.Permissions | hikari.UndefinedType
|
|
48
51
|
The default permissions for this plugin
|
|
@@ -53,16 +56,16 @@ class PluginBase(HasErrorHandler[ClientT], Hookable[ClientT], HasConcurrencyLimi
|
|
|
53
56
|
|
|
54
57
|
__slots__: t.Sequence[str] = (
|
|
55
58
|
"_client",
|
|
56
|
-
"_name",
|
|
57
|
-
"_default_enabled_guilds",
|
|
58
59
|
"_cmd_settings",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"_message_commands",
|
|
60
|
+
"_concurrency_limiter",
|
|
61
|
+
"_default_enabled_guilds",
|
|
62
62
|
"_error_handler",
|
|
63
63
|
"_hooks",
|
|
64
|
+
"_message_commands",
|
|
65
|
+
"_name",
|
|
64
66
|
"_post_hooks",
|
|
65
|
-
"
|
|
67
|
+
"_slash_commands",
|
|
68
|
+
"_user_commands",
|
|
66
69
|
)
|
|
67
70
|
|
|
68
71
|
def __init__(
|
|
@@ -72,7 +75,8 @@ class PluginBase(HasErrorHandler[ClientT], Hookable[ClientT], HasConcurrencyLimi
|
|
|
72
75
|
default_enabled_guilds: t.Sequence[hikari.Snowflakeish | hikari.PartialGuild]
|
|
73
76
|
| hikari.UndefinedType = hikari.UNDEFINED,
|
|
74
77
|
autodefer: bool | AutodeferMode | hikari.UndefinedType = hikari.UNDEFINED,
|
|
75
|
-
|
|
78
|
+
integration_types: t.Sequence[hikari.ApplicationIntegrationType] | hikari.UndefinedType = hikari.UNDEFINED,
|
|
79
|
+
invocation_contexts: t.Sequence[hikari.ApplicationContextType] | hikari.UndefinedType = hikari.UNDEFINED,
|
|
76
80
|
default_permissions: hikari.Permissions | hikari.UndefinedType = hikari.UNDEFINED,
|
|
77
81
|
is_nsfw: bool | hikari.UndefinedType = hikari.UNDEFINED,
|
|
78
82
|
) -> None:
|
|
@@ -83,10 +87,12 @@ class PluginBase(HasErrorHandler[ClientT], Hookable[ClientT], HasConcurrencyLimi
|
|
|
83
87
|
if default_enabled_guilds is not hikari.UNDEFINED
|
|
84
88
|
else hikari.UNDEFINED
|
|
85
89
|
)
|
|
90
|
+
|
|
86
91
|
self._cmd_settings = _CommandSettings(
|
|
87
92
|
autodefer=AutodeferMode(autodefer) if isinstance(autodefer, bool) else autodefer,
|
|
88
|
-
is_dm_enabled=is_dm_enabled,
|
|
89
93
|
default_permissions=default_permissions,
|
|
94
|
+
integration_types=integration_types,
|
|
95
|
+
invocation_contexts=invocation_contexts,
|
|
90
96
|
is_nsfw=is_nsfw,
|
|
91
97
|
)
|
|
92
98
|
|
|
@@ -257,7 +263,8 @@ class PluginBase(HasErrorHandler[ClientT], Hookable[ClientT], HasConcurrencyLimi
|
|
|
257
263
|
*,
|
|
258
264
|
guilds: t.Sequence[hikari.Snowflakeish | hikari.PartialGuild] | hikari.UndefinedType = hikari.UNDEFINED,
|
|
259
265
|
autodefer: bool | AutodeferMode | hikari.UndefinedType = hikari.UNDEFINED,
|
|
260
|
-
|
|
266
|
+
integration_types: t.Sequence[hikari.ApplicationIntegrationType] | hikari.UndefinedType = hikari.UNDEFINED,
|
|
267
|
+
invocation_contexts: t.Sequence[hikari.ApplicationContextType] | hikari.UndefinedType = hikari.UNDEFINED,
|
|
261
268
|
is_nsfw: bool | hikari.UndefinedType = hikari.UNDEFINED,
|
|
262
269
|
default_permissions: hikari.Permissions | hikari.UndefinedType = hikari.UNDEFINED,
|
|
263
270
|
name_localizations: t.Mapping[hikari.Locale, str] | None = None,
|
|
@@ -276,8 +283,10 @@ class PluginBase(HasErrorHandler[ClientT], Hookable[ClientT], HasConcurrencyLimi
|
|
|
276
283
|
autodefer : bool | AutodeferMode
|
|
277
284
|
If True, all commands in this group will automatically defer if it is taking longer than 2 seconds to respond.
|
|
278
285
|
This can be overridden on a per-subcommand basis.
|
|
279
|
-
|
|
280
|
-
|
|
286
|
+
invocation_contexts : t.Sequence[hikari.ApplicationContextType]
|
|
287
|
+
The context types to enable the slash command group in
|
|
288
|
+
integration_types : t.Sequence[hikari.ApplicationIntegrationType]
|
|
289
|
+
The integration types to enable the slash command group in
|
|
281
290
|
default_permissions : hikari.Permissions | hikari.UndefinedType
|
|
282
291
|
The default permissions for the slash command group
|
|
283
292
|
name_localizations : dict[hikari.Locale, str]
|
|
@@ -313,7 +322,8 @@ class PluginBase(HasErrorHandler[ClientT], Hookable[ClientT], HasConcurrencyLimi
|
|
|
313
322
|
description=description,
|
|
314
323
|
guilds=guild_ids,
|
|
315
324
|
autodefer=AutodeferMode(autodefer) if isinstance(autodefer, bool) else autodefer,
|
|
316
|
-
|
|
325
|
+
invocation_contexts=invocation_contexts,
|
|
326
|
+
integration_types=integration_types,
|
|
317
327
|
default_permissions=default_permissions,
|
|
318
328
|
name_localizations=name_localizations or {},
|
|
319
329
|
description_localizations=description_localizations or {},
|
|
@@ -399,6 +409,66 @@ class PluginBase(HasErrorHandler[ClientT], Hookable[ClientT], HasConcurrencyLimi
|
|
|
399
409
|
|
|
400
410
|
return decorator
|
|
401
411
|
|
|
412
|
+
@t.overload
|
|
413
|
+
def find_command(
|
|
414
|
+
self, command_type: t.Literal[hikari.CommandType.USER], full_name: str
|
|
415
|
+
) -> UserCommand[ClientT] | None: ...
|
|
416
|
+
|
|
417
|
+
@t.overload
|
|
418
|
+
def find_command(
|
|
419
|
+
self, command_type: t.Literal[hikari.CommandType.MESSAGE], full_name: str
|
|
420
|
+
) -> MessageCommand[ClientT] | None: ...
|
|
421
|
+
|
|
422
|
+
@t.overload
|
|
423
|
+
def find_command(
|
|
424
|
+
self, command_type: t.Literal[hikari.CommandType.SLASH], full_name: str
|
|
425
|
+
) -> SlashCommand[ClientT] | SlashSubCommand[ClientT] | SlashGroup[ClientT] | SlashSubGroup[ClientT] | None: ...
|
|
426
|
+
|
|
427
|
+
def find_command(self, command_type: hikari.CommandType, full_name: str) -> t.Any | None:
|
|
428
|
+
"""Find a given command by it's fully qualified name.
|
|
429
|
+
|
|
430
|
+
For instance, to locate a slash subcommand with the name `foo` in a group `bar`, you would pass `bar foo`.
|
|
431
|
+
|
|
432
|
+
Parameters
|
|
433
|
+
----------
|
|
434
|
+
command_type : hikari.CommandType
|
|
435
|
+
The type of command to search for.
|
|
436
|
+
full_name : str
|
|
437
|
+
The fully qualified name of the command.
|
|
438
|
+
|
|
439
|
+
Returns
|
|
440
|
+
-------
|
|
441
|
+
t.Any | None
|
|
442
|
+
The command if found, otherwise None.
|
|
443
|
+
"""
|
|
444
|
+
if command_type is hikari.CommandType.MESSAGE:
|
|
445
|
+
return self._message_commands.get(full_name)
|
|
446
|
+
if command_type is hikari.CommandType.USER:
|
|
447
|
+
return self._user_commands.get(full_name)
|
|
448
|
+
|
|
449
|
+
if command_type is not hikari.CommandType.SLASH:
|
|
450
|
+
return None
|
|
451
|
+
|
|
452
|
+
command_parts = full_name.split(" ")
|
|
453
|
+
|
|
454
|
+
if len(command_parts) == 1:
|
|
455
|
+
return self._slash_commands.get(command_parts[0])
|
|
456
|
+
|
|
457
|
+
base_cmd = self._slash_commands.get(command_parts[0])
|
|
458
|
+
|
|
459
|
+
if not isinstance(base_cmd, SlashGroup):
|
|
460
|
+
return None
|
|
461
|
+
|
|
462
|
+
subcmd = base_cmd.children.get(command_parts[1])
|
|
463
|
+
|
|
464
|
+
if len(command_parts) == 2:
|
|
465
|
+
return subcmd
|
|
466
|
+
|
|
467
|
+
if not isinstance(subcmd, SlashSubGroup):
|
|
468
|
+
return None
|
|
469
|
+
|
|
470
|
+
return subcmd.children.get(command_parts[2])
|
|
471
|
+
|
|
402
472
|
@t.overload
|
|
403
473
|
def walk_commands(
|
|
404
474
|
self, command_type: t.Literal[hikari.CommandType.USER], *, callable_only: bool = False
|
arc/client.py
CHANGED
|
@@ -21,14 +21,14 @@ if t.TYPE_CHECKING:
|
|
|
21
21
|
from arc.internal.types import EventCallbackT, EventT, ResponseBuilderT
|
|
22
22
|
|
|
23
23
|
__all__ = (
|
|
24
|
-
"GatewayClientBase",
|
|
25
|
-
"RESTClientBase",
|
|
26
24
|
"GatewayClient",
|
|
27
|
-
"
|
|
25
|
+
"GatewayClientBase",
|
|
28
26
|
"GatewayContext",
|
|
27
|
+
"GatewayPlugin",
|
|
28
|
+
"RESTClient",
|
|
29
|
+
"RESTClientBase",
|
|
29
30
|
"RESTContext",
|
|
30
31
|
"RESTPlugin",
|
|
31
|
-
"GatewayPlugin",
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
|
|
@@ -61,9 +61,12 @@ class GatewayClientBase(Client[GatewayBotT]):
|
|
|
61
61
|
is_nsfw : bool
|
|
62
62
|
Whether commands are NSFW
|
|
63
63
|
This applies to all commands, and can be overridden on a per-command basis.
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
integration_types : t.Sequence[hikari.ApplicationIntegrationType]
|
|
65
|
+
The integration types that commands will support the installation of
|
|
66
66
|
This applies to all commands, and can be overridden on a per-command basis.
|
|
67
|
+
invocation_contexts : t.Sequence[hikari.ApplicationContextType]
|
|
68
|
+
The context types that commands can be invoked in
|
|
69
|
+
This applies to all commands, and can be overridden on a per-command basis
|
|
67
70
|
provided_locales : t.Sequence[hikari.Locale] | None
|
|
68
71
|
The locales that will be provided to the client by locale provider callbacks
|
|
69
72
|
injector : alluka.Client | None
|
|
@@ -83,7 +86,14 @@ class GatewayClientBase(Client[GatewayBotT]):
|
|
|
83
86
|
autodefer: bool | AutodeferMode = True,
|
|
84
87
|
default_permissions: hikari.Permissions | hikari.UndefinedType = hikari.UNDEFINED,
|
|
85
88
|
is_nsfw: bool = False,
|
|
86
|
-
|
|
89
|
+
integration_types: t.Sequence[hikari.ApplicationIntegrationType] = [
|
|
90
|
+
hikari.ApplicationIntegrationType.GUILD_INSTALL
|
|
91
|
+
],
|
|
92
|
+
invocation_contexts: t.Sequence[hikari.ApplicationContextType] = [
|
|
93
|
+
hikari.ApplicationContextType.GUILD,
|
|
94
|
+
hikari.ApplicationContextType.PRIVATE_CHANNEL,
|
|
95
|
+
hikari.ApplicationContextType.BOT_DM,
|
|
96
|
+
],
|
|
87
97
|
provided_locales: t.Sequence[hikari.Locale] | None = None,
|
|
88
98
|
injector: alluka.abc.Client | None = None,
|
|
89
99
|
) -> None:
|
|
@@ -94,7 +104,8 @@ class GatewayClientBase(Client[GatewayBotT]):
|
|
|
94
104
|
autodefer=autodefer,
|
|
95
105
|
default_permissions=default_permissions,
|
|
96
106
|
is_nsfw=is_nsfw,
|
|
97
|
-
|
|
107
|
+
integration_types=integration_types,
|
|
108
|
+
invocation_contexts=invocation_contexts,
|
|
98
109
|
provided_locales=provided_locales,
|
|
99
110
|
injector=injector,
|
|
100
111
|
)
|
|
@@ -216,9 +227,12 @@ class RESTClientBase(Client[RESTBotT]):
|
|
|
216
227
|
is_nsfw : bool
|
|
217
228
|
Whether commands are NSFW
|
|
218
229
|
This applies to all commands, and can be overridden on a per-command basis.
|
|
219
|
-
|
|
220
|
-
|
|
230
|
+
integration_types : t.Sequence[hikari.ApplicationIntegrationType]
|
|
231
|
+
The integration types that commands will support the installation of
|
|
221
232
|
This applies to all commands, and can be overridden on a per-command basis.
|
|
233
|
+
invocation_contexts : t.Sequence[hikari.ApplicationContextType]
|
|
234
|
+
The context types that commands can be invoked in
|
|
235
|
+
This applies to all commands, and can be overridden on a per-command basis
|
|
222
236
|
provided_locales : t.Sequence[hikari.Locale] | None
|
|
223
237
|
The locales that will be provided to the client by locale provider callbacks
|
|
224
238
|
injector : alluka.abc.Client | None
|
|
@@ -237,8 +251,15 @@ class RESTClientBase(Client[RESTBotT]):
|
|
|
237
251
|
autosync: bool = True,
|
|
238
252
|
autodefer: bool | AutodeferMode = True,
|
|
239
253
|
default_permissions: hikari.Permissions | hikari.UndefinedType = hikari.UNDEFINED,
|
|
254
|
+
integration_types: t.Sequence[hikari.ApplicationIntegrationType] = [
|
|
255
|
+
hikari.ApplicationIntegrationType.GUILD_INSTALL
|
|
256
|
+
],
|
|
257
|
+
invocation_contexts: t.Sequence[hikari.ApplicationContextType] = [
|
|
258
|
+
hikari.ApplicationContextType.GUILD,
|
|
259
|
+
hikari.ApplicationContextType.PRIVATE_CHANNEL,
|
|
260
|
+
hikari.ApplicationContextType.BOT_DM,
|
|
261
|
+
],
|
|
240
262
|
is_nsfw: bool = False,
|
|
241
|
-
is_dm_enabled: bool = True,
|
|
242
263
|
provided_locales: t.Sequence[hikari.Locale] | None = None,
|
|
243
264
|
injector: alluka.abc.Client | None = None,
|
|
244
265
|
) -> None:
|
|
@@ -249,7 +270,8 @@ class RESTClientBase(Client[RESTBotT]):
|
|
|
249
270
|
autodefer=autodefer,
|
|
250
271
|
default_permissions=default_permissions,
|
|
251
272
|
is_nsfw=is_nsfw,
|
|
252
|
-
|
|
273
|
+
integration_types=integration_types,
|
|
274
|
+
invocation_contexts=invocation_contexts,
|
|
253
275
|
provided_locales=provided_locales,
|
|
254
276
|
injector=injector,
|
|
255
277
|
)
|
|
@@ -335,12 +357,15 @@ class GatewayClient(GatewayClientBase[hikari.GatewayBotAware]):
|
|
|
335
357
|
is_nsfw : bool
|
|
336
358
|
Whether commands are NSFW
|
|
337
359
|
This applies to all commands, and can be overridden on a per-command basis.
|
|
338
|
-
|
|
339
|
-
|
|
360
|
+
integration_types : t.Sequence[hikari.ApplicationIntegrationType]
|
|
361
|
+
The integration types that commands will support the installation of
|
|
340
362
|
This applies to all commands, and can be overridden on a per-command basis.
|
|
363
|
+
invocation_contexts : t.Sequence[hikari.ApplicationContextType]
|
|
364
|
+
The context types that commands can be invoked in
|
|
365
|
+
This applies to all commands, and can be overridden on a per-command basis
|
|
341
366
|
provided_locales : t.Sequence[hikari.Locale] | None
|
|
342
367
|
The locales that will be provided to the client by locale provider callbacks
|
|
343
|
-
injector : alluka.
|
|
368
|
+
injector : alluka.Client | None
|
|
344
369
|
If you already have an injector instance, you may pass it here.
|
|
345
370
|
Otherwise, a new one will be created by default.
|
|
346
371
|
|
|
@@ -380,9 +405,12 @@ class RESTClient(RESTClientBase[hikari.RESTBotAware]):
|
|
|
380
405
|
is_nsfw : bool
|
|
381
406
|
Whether commands are NSFW
|
|
382
407
|
This applies to all commands, and can be overridden on a per-command basis.
|
|
383
|
-
|
|
384
|
-
|
|
408
|
+
integration_types : t.Sequence[hikari.ApplicationIntegrationType]
|
|
409
|
+
The integration types that commands will support the installation of
|
|
385
410
|
This applies to all commands, and can be overridden on a per-command basis.
|
|
411
|
+
invocation_contexts : t.Sequence[hikari.ApplicationContextType]
|
|
412
|
+
The context types that commands can be invoked in
|
|
413
|
+
This applies to all commands, and can be overridden on a per-command basis
|
|
386
414
|
provided_locales : t.Sequence[hikari.Locale] | None
|
|
387
415
|
The locales that will be provided to the client by locale provider callbacks
|
|
388
416
|
injector : alluka.abc.Client | None
|
arc/command/__init__.py
CHANGED
|
@@ -10,6 +10,8 @@ from .option import (
|
|
|
10
10
|
ColorParams,
|
|
11
11
|
ColourOption,
|
|
12
12
|
ColourParams,
|
|
13
|
+
EmojiOption,
|
|
14
|
+
EmojiParams,
|
|
13
15
|
FloatOption,
|
|
14
16
|
FloatParams,
|
|
15
17
|
IntOption,
|
|
@@ -37,41 +39,43 @@ from .slash import (
|
|
|
37
39
|
from .user import UserCommand, user_command
|
|
38
40
|
|
|
39
41
|
__all__ = (
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"SlashGroup",
|
|
43
|
-
"SlashSubCommand",
|
|
44
|
-
"SlashSubGroup",
|
|
45
|
-
"slash_command",
|
|
46
|
-
"slash_subcommand",
|
|
42
|
+
"AttachmentOption",
|
|
43
|
+
"AttachmentParams",
|
|
47
44
|
"BoolOption",
|
|
48
45
|
"BoolParams",
|
|
49
|
-
"IntOption",
|
|
50
|
-
"StrOption",
|
|
51
|
-
"IntParams",
|
|
52
|
-
"StrParams",
|
|
53
|
-
"FloatOption",
|
|
54
|
-
"FloatParams",
|
|
55
|
-
"UserOption",
|
|
56
|
-
"UserParams",
|
|
57
46
|
"ChannelOption",
|
|
58
47
|
"ChannelParams",
|
|
59
|
-
"RoleOption",
|
|
60
|
-
"RoleParams",
|
|
61
|
-
"MentionableOption",
|
|
62
|
-
"MentionableParams",
|
|
63
|
-
"AttachmentOption",
|
|
64
|
-
"AttachmentParams",
|
|
65
|
-
"MemberOption",
|
|
66
|
-
"MemberParams",
|
|
67
48
|
"ColorOption",
|
|
68
49
|
"ColorParams",
|
|
69
50
|
"ColourOption",
|
|
70
51
|
"ColourParams",
|
|
71
|
-
"
|
|
72
|
-
"
|
|
52
|
+
"EmojiOption",
|
|
53
|
+
"EmojiParams",
|
|
54
|
+
"FloatOption",
|
|
55
|
+
"FloatParams",
|
|
56
|
+
"IntOption",
|
|
57
|
+
"IntParams",
|
|
58
|
+
"MemberOption",
|
|
59
|
+
"MemberParams",
|
|
60
|
+
"MentionableOption",
|
|
61
|
+
"MentionableParams",
|
|
73
62
|
"MessageCommand",
|
|
63
|
+
"RoleOption",
|
|
64
|
+
"RoleParams",
|
|
65
|
+
"SlashCommand",
|
|
66
|
+
"SlashCommandLike",
|
|
67
|
+
"SlashGroup",
|
|
68
|
+
"SlashSubCommand",
|
|
69
|
+
"SlashSubGroup",
|
|
70
|
+
"StrOption",
|
|
71
|
+
"StrParams",
|
|
72
|
+
"UserCommand",
|
|
73
|
+
"UserOption",
|
|
74
|
+
"UserParams",
|
|
74
75
|
"message_command",
|
|
76
|
+
"slash_command",
|
|
77
|
+
"slash_subcommand",
|
|
78
|
+
"user_command",
|
|
75
79
|
)
|
|
76
80
|
|
|
77
81
|
# MIT License
|
arc/command/message.py
CHANGED
|
@@ -45,9 +45,10 @@ class MessageCommand(CallableCommandBase[ClientT, hikari.api.ContextMenuCommandB
|
|
|
45
45
|
id=id,
|
|
46
46
|
type=self.command_type,
|
|
47
47
|
default_member_permissions=self.default_permissions,
|
|
48
|
-
|
|
48
|
+
context_types=self.invocation_contexts,
|
|
49
|
+
integration_types=self.integration_types,
|
|
49
50
|
is_nsfw=self.is_nsfw,
|
|
50
|
-
name_localizations=self.name_localizations,
|
|
51
|
+
name_localizations={str(key): value for key, value in self.name_localizations.items()},
|
|
51
52
|
)
|
|
52
53
|
|
|
53
54
|
async def invoke(
|
|
@@ -67,7 +68,8 @@ def message_command(
|
|
|
67
68
|
name: str,
|
|
68
69
|
*,
|
|
69
70
|
guilds: t.Sequence[hikari.PartialGuild | hikari.Snowflakeish] | hikari.UndefinedType = hikari.UNDEFINED,
|
|
70
|
-
|
|
71
|
+
integration_types: t.Sequence[hikari.ApplicationIntegrationType] | hikari.UndefinedType = hikari.UNDEFINED,
|
|
72
|
+
invocation_contexts: t.Sequence[hikari.ApplicationContextType] | hikari.UndefinedType = hikari.UNDEFINED,
|
|
71
73
|
is_nsfw: bool | hikari.UndefinedType = hikari.UNDEFINED,
|
|
72
74
|
autodefer: bool | AutodeferMode | hikari.UndefinedType = hikari.UNDEFINED,
|
|
73
75
|
default_permissions: hikari.Permissions | hikari.UndefinedType = hikari.UNDEFINED,
|
|
@@ -84,8 +86,10 @@ def message_command(
|
|
|
84
86
|
The name of the command.
|
|
85
87
|
guilds : t.Sequence[hikari.PartialGuild | hikari.Snowflakeish] | hikari.UndefinedType
|
|
86
88
|
The guilds this command should be enabled in, if left as undefined, the command is global
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
integration_types : t.Sequence[hikari.ApplicationIntegrationType] | hikari.UndefinedType
|
|
90
|
+
The integration types this command supports the installation of
|
|
91
|
+
invocation_contexts : t.Sequence[hikari.ApplicationContextType] | hikari.UndefinedType
|
|
92
|
+
The context types this command can be invoked in
|
|
89
93
|
is_nsfw : bool | hikari.UndefinedType
|
|
90
94
|
Whether this command is NSFW.
|
|
91
95
|
autodefer : bool | AutodeferMode | hikari.UndefinedType
|
|
@@ -116,7 +120,8 @@ def message_command(
|
|
|
116
120
|
name=name,
|
|
117
121
|
autodefer=AutodeferMode(autodefer) if isinstance(autodefer, bool) else autodefer,
|
|
118
122
|
guilds=guild_ids,
|
|
119
|
-
|
|
123
|
+
integration_types=integration_types,
|
|
124
|
+
invocation_contexts=invocation_contexts,
|
|
120
125
|
is_nsfw=is_nsfw,
|
|
121
126
|
default_permissions=default_permissions,
|
|
122
127
|
name_localizations=name_localizations or {},
|
arc/command/option/__init__.py
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
from .attachment import AttachmentOption, AttachmentParams
|
|
2
2
|
from .bool import BoolOption, BoolParams
|
|
3
3
|
from .channel import ChannelOption, ChannelParams
|
|
4
|
-
from .custom import
|
|
4
|
+
from .custom import (
|
|
5
|
+
ColorOption,
|
|
6
|
+
ColorParams,
|
|
7
|
+
ColourOption,
|
|
8
|
+
ColourParams,
|
|
9
|
+
EmojiOption,
|
|
10
|
+
EmojiParams,
|
|
11
|
+
MemberOption,
|
|
12
|
+
MemberParams,
|
|
13
|
+
)
|
|
5
14
|
from .float import FloatOption, FloatParams
|
|
6
15
|
from .int import IntOption, IntParams
|
|
7
16
|
from .mentionable import MentionableOption, MentionableParams
|
|
@@ -10,30 +19,32 @@ from .str import StrOption, StrParams
|
|
|
10
19
|
from .user import UserOption, UserParams
|
|
11
20
|
|
|
12
21
|
__all__ = (
|
|
22
|
+
"AttachmentOption",
|
|
23
|
+
"AttachmentParams",
|
|
13
24
|
"BoolOption",
|
|
14
25
|
"BoolParams",
|
|
15
|
-
"IntOption",
|
|
16
|
-
"IntParams",
|
|
17
|
-
"StrOption",
|
|
18
|
-
"StrParams",
|
|
19
|
-
"FloatOption",
|
|
20
|
-
"FloatParams",
|
|
21
|
-
"UserOption",
|
|
22
|
-
"UserParams",
|
|
23
26
|
"ChannelOption",
|
|
24
27
|
"ChannelParams",
|
|
25
|
-
"RoleOption",
|
|
26
|
-
"RoleParams",
|
|
27
|
-
"MentionableOption",
|
|
28
|
-
"MentionableParams",
|
|
29
|
-
"AttachmentOption",
|
|
30
|
-
"AttachmentParams",
|
|
31
|
-
"MemberOption",
|
|
32
|
-
"MemberParams",
|
|
33
28
|
"ColorOption",
|
|
34
29
|
"ColorParams",
|
|
35
30
|
"ColourOption",
|
|
36
31
|
"ColourParams",
|
|
32
|
+
"EmojiOption",
|
|
33
|
+
"EmojiParams",
|
|
34
|
+
"FloatOption",
|
|
35
|
+
"FloatParams",
|
|
36
|
+
"IntOption",
|
|
37
|
+
"IntParams",
|
|
38
|
+
"MemberOption",
|
|
39
|
+
"MemberParams",
|
|
40
|
+
"MentionableOption",
|
|
41
|
+
"MentionableParams",
|
|
42
|
+
"RoleOption",
|
|
43
|
+
"RoleParams",
|
|
44
|
+
"StrOption",
|
|
45
|
+
"StrParams",
|
|
46
|
+
"UserOption",
|
|
47
|
+
"UserParams",
|
|
37
48
|
)
|
|
38
49
|
|
|
39
50
|
# MIT License
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
from .color import ColorOption, ColorParams, ColourOption, ColourParams
|
|
2
|
+
from .emoji import EmojiOption, EmojiParams
|
|
2
3
|
from .member import MemberOption, MemberParams
|
|
3
4
|
|
|
4
|
-
__all__ = (
|
|
5
|
+
__all__ = (
|
|
6
|
+
"ColorOption",
|
|
7
|
+
"ColorParams",
|
|
8
|
+
"ColourOption",
|
|
9
|
+
"ColourParams",
|
|
10
|
+
"EmojiOption",
|
|
11
|
+
"EmojiParams",
|
|
12
|
+
"MemberOption",
|
|
13
|
+
"MemberParams",
|
|
14
|
+
)
|