hikari-arc 0.4.0__py3-none-any.whl → 0.6.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 +55 -5
- arc/abc/__init__.py +32 -1
- arc/abc/client.py +207 -67
- arc/abc/command.py +245 -34
- arc/abc/error_handler.py +33 -2
- arc/abc/hookable.py +24 -0
- arc/abc/limiter.py +61 -0
- arc/abc/option.py +73 -5
- arc/abc/plugin.py +185 -29
- arc/client.py +103 -33
- arc/command/message.py +21 -18
- arc/command/option/attachment.py +9 -5
- arc/command/option/bool.py +9 -6
- arc/command/option/channel.py +9 -5
- arc/command/option/float.py +11 -7
- arc/command/option/int.py +11 -7
- arc/command/option/mentionable.py +9 -5
- arc/command/option/role.py +9 -5
- arc/command/option/str.py +11 -7
- arc/command/option/user.py +9 -5
- arc/command/slash.py +222 -197
- arc/command/user.py +20 -17
- arc/context/autocomplete.py +1 -0
- arc/context/base.py +216 -105
- arc/errors.py +52 -10
- arc/events.py +5 -1
- arc/extension.py +23 -0
- arc/internal/about.py +1 -1
- arc/internal/deprecation.py +3 -4
- arc/internal/options.py +106 -0
- arc/internal/sigparse.py +19 -1
- arc/internal/sync.py +13 -10
- arc/internal/types.py +34 -15
- arc/locale.py +28 -0
- arc/plugin.py +56 -5
- arc/utils/__init__.py +53 -2
- arc/utils/hooks/__init__.py +25 -0
- arc/utils/{hooks.py → hooks/basic.py} +28 -1
- arc/utils/hooks/limiters.py +217 -0
- arc/utils/ratelimiter.py +243 -0
- {hikari_arc-0.4.0.dist-info → hikari_arc-0.6.0.dist-info}/METADATA +13 -8
- hikari_arc-0.6.0.dist-info/RECORD +52 -0
- hikari_arc-0.4.0.dist-info/RECORD +0 -47
- {hikari_arc-0.4.0.dist-info → hikari_arc-0.6.0.dist-info}/LICENSE +0 -0
- {hikari_arc-0.4.0.dist-info → hikari_arc-0.6.0.dist-info}/WHEEL +0 -0
- {hikari_arc-0.4.0.dist-info → hikari_arc-0.6.0.dist-info}/top_level.txt +0 -0
arc/command/message.py
CHANGED
|
@@ -8,12 +8,12 @@ import hikari
|
|
|
8
8
|
from arc.abc.command import CallableCommandBase
|
|
9
9
|
from arc.context import AutodeferMode, Context
|
|
10
10
|
from arc.errors import CommandInvokeError
|
|
11
|
-
from arc.internal.types import ClientT,
|
|
11
|
+
from arc.internal.types import ClientT, MessageCommandCallbackT, ResponseBuilderT
|
|
12
12
|
|
|
13
13
|
if t.TYPE_CHECKING:
|
|
14
14
|
import asyncio
|
|
15
15
|
|
|
16
|
-
from
|
|
16
|
+
from arc.abc import CallableCommandProto
|
|
17
17
|
|
|
18
18
|
__all__ = ("MessageCommand", "message_command")
|
|
19
19
|
|
|
@@ -63,33 +63,36 @@ class MessageCommand(CallableCommandBase[ClientT, hikari.api.ContextMenuCommandB
|
|
|
63
63
|
def message_command(
|
|
64
64
|
name: str,
|
|
65
65
|
*,
|
|
66
|
-
guilds: t.Sequence[hikari.
|
|
67
|
-
is_dm_enabled: bool =
|
|
68
|
-
is_nsfw: bool =
|
|
69
|
-
autodefer: bool | AutodeferMode =
|
|
70
|
-
default_permissions: hikari.
|
|
66
|
+
guilds: t.Sequence[hikari.PartialGuild | hikari.Snowflakeish] | hikari.UndefinedType = hikari.UNDEFINED,
|
|
67
|
+
is_dm_enabled: bool | hikari.UndefinedType = hikari.UNDEFINED,
|
|
68
|
+
is_nsfw: bool | hikari.UndefinedType = hikari.UNDEFINED,
|
|
69
|
+
autodefer: bool | AutodeferMode | hikari.UndefinedType = hikari.UNDEFINED,
|
|
70
|
+
default_permissions: hikari.Permissions | hikari.UndefinedType = hikari.UNDEFINED,
|
|
71
71
|
name_localizations: t.Mapping[hikari.Locale, str] | None = None,
|
|
72
|
-
) -> t.Callable[[
|
|
72
|
+
) -> t.Callable[[MessageCommandCallbackT[ClientT]], MessageCommand[ClientT]]:
|
|
73
73
|
"""A decorator that creates a context-menu command on a message.
|
|
74
74
|
|
|
75
75
|
Parameters
|
|
76
76
|
----------
|
|
77
77
|
name : str
|
|
78
78
|
The name of the command.
|
|
79
|
-
guilds : t.Sequence[hikari.
|
|
80
|
-
The guilds this command
|
|
81
|
-
is_dm_enabled : bool
|
|
79
|
+
guilds : t.Sequence[hikari.PartialGuild | hikari.Snowflakeish] | hikari.UndefinedType
|
|
80
|
+
The guilds this command should be enabled in, if left as undefined, the command is global
|
|
81
|
+
is_dm_enabled : bool | hikari.UndefinedType
|
|
82
82
|
Whether this command is enabled in DMs.
|
|
83
|
-
is_nsfw : bool
|
|
83
|
+
is_nsfw : bool | hikari.UndefinedType
|
|
84
84
|
Whether this command is NSFW.
|
|
85
|
-
autodefer : bool | AutodeferMode
|
|
86
|
-
If True, this command will be automatically deferred if it takes longer than 2 seconds to respond
|
|
87
|
-
default_permissions : hikari.
|
|
85
|
+
autodefer : bool | AutodeferMode | hikari.UndefinedType
|
|
86
|
+
If True, this command will be automatically deferred if it takes longer than 2 seconds to respond
|
|
87
|
+
default_permissions : hikari.Permissions | hikari.UndefinedType
|
|
88
88
|
The default permissions for this command.
|
|
89
89
|
Keep in mind that guild administrators can change this, it should only be used to provide safe defaults.
|
|
90
90
|
name_localizations : t.Mapping[hikari.Locale, str] | None
|
|
91
91
|
The localizations for this command's name.
|
|
92
92
|
|
|
93
|
+
!!! note
|
|
94
|
+
Parameters left as `hikari.UNDEFINED` will be inherited from the parent plugin or client.
|
|
95
|
+
|
|
93
96
|
Usage
|
|
94
97
|
-----
|
|
95
98
|
```py
|
|
@@ -102,13 +105,13 @@ def message_command(
|
|
|
102
105
|
```
|
|
103
106
|
"""
|
|
104
107
|
|
|
105
|
-
def decorator(callback:
|
|
106
|
-
guild_ids =
|
|
108
|
+
def decorator(callback: MessageCommandCallbackT[ClientT]) -> MessageCommand[ClientT]:
|
|
109
|
+
guild_ids = tuple(hikari.Snowflake(i) for i in guilds) if guilds is not hikari.UNDEFINED else hikari.UNDEFINED
|
|
107
110
|
|
|
108
111
|
return MessageCommand(
|
|
109
112
|
callback=callback,
|
|
110
113
|
name=name,
|
|
111
|
-
autodefer=AutodeferMode(autodefer),
|
|
114
|
+
autodefer=AutodeferMode(autodefer) if isinstance(autodefer, bool) else autodefer,
|
|
112
115
|
guilds=guild_ids,
|
|
113
116
|
is_dm_enabled=is_dm_enabled,
|
|
114
117
|
is_nsfw=is_nsfw,
|
arc/command/option/attachment.py
CHANGED
|
@@ -5,7 +5,7 @@ import typing as t
|
|
|
5
5
|
import attr
|
|
6
6
|
import hikari
|
|
7
7
|
|
|
8
|
-
from arc.abc.option import CommandOptionBase, OptionParams
|
|
8
|
+
from arc.abc.option import CommandOptionBase, OptionParams, OptionType
|
|
9
9
|
from arc.internal.types import ClientT
|
|
10
10
|
|
|
11
11
|
if t.TYPE_CHECKING:
|
|
@@ -14,15 +14,19 @@ if t.TYPE_CHECKING:
|
|
|
14
14
|
__all__ = ("AttachmentOption", "AttachmentParams")
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
@t.final
|
|
17
18
|
class AttachmentParams(OptionParams[hikari.Attachment]):
|
|
18
19
|
"""The parameters for an attachment option.
|
|
19
20
|
|
|
20
21
|
Parameters
|
|
21
22
|
----------
|
|
22
|
-
name : str
|
|
23
|
-
The name of the option
|
|
24
23
|
description : str
|
|
25
24
|
The description of the option
|
|
25
|
+
|
|
26
|
+
Other Parameters
|
|
27
|
+
----------------
|
|
28
|
+
name : str
|
|
29
|
+
The name of the option. If not provided, the name of the parameter will be used.
|
|
26
30
|
name_localizations : Mapping[hikari.Locale, str] | None
|
|
27
31
|
The name of the option in different locales
|
|
28
32
|
description_localizations : Mapping[hikari.Locale, str] | None
|
|
@@ -42,8 +46,8 @@ class AttachmentOption(CommandOptionBase[hikari.Attachment, ClientT, AttachmentP
|
|
|
42
46
|
"""
|
|
43
47
|
|
|
44
48
|
@property
|
|
45
|
-
def option_type(self) ->
|
|
46
|
-
return
|
|
49
|
+
def option_type(self) -> OptionType:
|
|
50
|
+
return OptionType.ATTACHMENT
|
|
47
51
|
|
|
48
52
|
@classmethod
|
|
49
53
|
def _from_params(cls, *, name: str, is_required: bool, params: AttachmentParams, **kwargs: t.Any) -> te.Self:
|
arc/command/option/bool.py
CHANGED
|
@@ -3,9 +3,8 @@ from __future__ import annotations
|
|
|
3
3
|
import typing as t
|
|
4
4
|
|
|
5
5
|
import attr
|
|
6
|
-
import hikari
|
|
7
6
|
|
|
8
|
-
from arc.abc.option import CommandOptionBase, OptionParams
|
|
7
|
+
from arc.abc.option import CommandOptionBase, OptionParams, OptionType
|
|
9
8
|
from arc.internal.types import ClientT
|
|
10
9
|
|
|
11
10
|
if t.TYPE_CHECKING:
|
|
@@ -14,15 +13,19 @@ if t.TYPE_CHECKING:
|
|
|
14
13
|
__all__ = ("BoolOption", "BoolParams")
|
|
15
14
|
|
|
16
15
|
|
|
16
|
+
@t.final
|
|
17
17
|
class BoolParams(OptionParams[bool]):
|
|
18
18
|
"""The parameters for a bool option.
|
|
19
19
|
|
|
20
20
|
Parameters
|
|
21
21
|
----------
|
|
22
|
-
name : str
|
|
23
|
-
The name of the option. If not provided, the name of the parameter will be used.
|
|
24
22
|
description : str
|
|
25
23
|
The description of the option
|
|
24
|
+
|
|
25
|
+
Other Parameters
|
|
26
|
+
----------------
|
|
27
|
+
name : str
|
|
28
|
+
The name of the option. If not provided, the name of the parameter will be used.
|
|
26
29
|
name_localizations : t.Optional[t.Mapping[str, str]]
|
|
27
30
|
The localizations for the name of the option
|
|
28
31
|
description_localizations : t.Optional[t.Mapping[str, str]]
|
|
@@ -42,8 +45,8 @@ class BoolOption(CommandOptionBase[bool, ClientT, BoolParams]):
|
|
|
42
45
|
"""
|
|
43
46
|
|
|
44
47
|
@property
|
|
45
|
-
def option_type(self) ->
|
|
46
|
-
return
|
|
48
|
+
def option_type(self) -> OptionType:
|
|
49
|
+
return OptionType.BOOLEAN
|
|
47
50
|
|
|
48
51
|
@classmethod
|
|
49
52
|
def _from_params(cls, *, name: str, is_required: bool, params: BoolParams, **kwargs: t.Any) -> te.Self:
|
arc/command/option/channel.py
CHANGED
|
@@ -5,7 +5,7 @@ import typing as t
|
|
|
5
5
|
import attr
|
|
6
6
|
import hikari
|
|
7
7
|
|
|
8
|
-
from arc.abc.option import CommandOptionBase, OptionParams
|
|
8
|
+
from arc.abc.option import CommandOptionBase, OptionParams, OptionType
|
|
9
9
|
from arc.internal.types import ClientT
|
|
10
10
|
|
|
11
11
|
if t.TYPE_CHECKING:
|
|
@@ -14,6 +14,7 @@ if t.TYPE_CHECKING:
|
|
|
14
14
|
__all__ = ("ChannelOption", "ChannelParams")
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
@t.final
|
|
17
18
|
class ChannelParams(OptionParams[hikari.PartialChannel]):
|
|
18
19
|
"""The parameters for a channel option.
|
|
19
20
|
The channel types are inferred from the type hint.
|
|
@@ -25,10 +26,13 @@ class ChannelParams(OptionParams[hikari.PartialChannel]):
|
|
|
25
26
|
|
|
26
27
|
Parameters
|
|
27
28
|
----------
|
|
28
|
-
name : str
|
|
29
|
-
The name of the option
|
|
30
29
|
description : str
|
|
31
30
|
The description of the option
|
|
31
|
+
|
|
32
|
+
Other Parameters
|
|
33
|
+
----------------
|
|
34
|
+
name : str
|
|
35
|
+
The name of the option. If not provided, the name of the parameter will be used.
|
|
32
36
|
name_localizations : Mapping[hikari.Locale, str]
|
|
33
37
|
The name of the option in different locales
|
|
34
38
|
description_localizations : Mapping[hikari.Locale, str]
|
|
@@ -53,8 +57,8 @@ class ChannelOption(CommandOptionBase[hikari.PartialChannel, ClientT, ChannelPar
|
|
|
53
57
|
"""The channel types that the option can be."""
|
|
54
58
|
|
|
55
59
|
@property
|
|
56
|
-
def option_type(self) ->
|
|
57
|
-
return
|
|
60
|
+
def option_type(self) -> OptionType:
|
|
61
|
+
return OptionType.CHANNEL
|
|
58
62
|
|
|
59
63
|
@classmethod
|
|
60
64
|
def _from_params(cls, *, name: str, is_required: bool, params: ChannelParams, **kwargs: t.Any) -> te.Self:
|
arc/command/option/float.py
CHANGED
|
@@ -3,12 +3,12 @@ from __future__ import annotations
|
|
|
3
3
|
import typing as t
|
|
4
4
|
|
|
5
5
|
import attr
|
|
6
|
-
import hikari
|
|
7
6
|
|
|
8
|
-
from arc.abc.option import OptionWithChoices, OptionWithChoicesParams
|
|
7
|
+
from arc.abc.option import OptionType, OptionWithChoices, OptionWithChoicesParams
|
|
9
8
|
from arc.internal.types import ClientT
|
|
10
9
|
|
|
11
10
|
if t.TYPE_CHECKING:
|
|
11
|
+
import hikari
|
|
12
12
|
import typing_extensions as te
|
|
13
13
|
|
|
14
14
|
from ...internal.types import AutocompleteCallbackT
|
|
@@ -16,15 +16,19 @@ if t.TYPE_CHECKING:
|
|
|
16
16
|
__all__ = ("FloatOption", "FloatParams")
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
@t.final
|
|
19
20
|
class FloatParams(OptionWithChoicesParams[float, ClientT]):
|
|
20
21
|
"""The parameters for a float option.
|
|
21
22
|
|
|
22
23
|
Parameters
|
|
23
24
|
----------
|
|
24
|
-
name : str
|
|
25
|
-
The name of the option
|
|
26
25
|
description : str
|
|
27
26
|
The description of the option
|
|
27
|
+
|
|
28
|
+
Other Parameters
|
|
29
|
+
----------------
|
|
30
|
+
name : str
|
|
31
|
+
The name of the option. If not provided, the name of the parameter will be used.
|
|
28
32
|
name_localizations : Mapping[hikari.Locale, str] | None
|
|
29
33
|
The name of the option in different locales
|
|
30
34
|
description_localizations : Mapping[hikari.Locale, str] | None
|
|
@@ -44,9 +48,9 @@ class FloatParams(OptionWithChoicesParams[float, ClientT]):
|
|
|
44
48
|
|
|
45
49
|
def __init__(
|
|
46
50
|
self,
|
|
47
|
-
name: str | None = None,
|
|
48
51
|
description: str = "No description provided.",
|
|
49
52
|
*,
|
|
53
|
+
name: str | None = None,
|
|
50
54
|
name_localizations: t.Mapping[hikari.Locale, str] = {},
|
|
51
55
|
description_localizations: t.Mapping[hikari.Locale, str] = {},
|
|
52
56
|
min: float | None = None,
|
|
@@ -93,8 +97,8 @@ class FloatOption(OptionWithChoices[float, ClientT, FloatParams[ClientT]]):
|
|
|
93
97
|
"""The maximum value of the option."""
|
|
94
98
|
|
|
95
99
|
@property
|
|
96
|
-
def option_type(self) ->
|
|
97
|
-
return
|
|
100
|
+
def option_type(self) -> OptionType:
|
|
101
|
+
return OptionType.FLOAT
|
|
98
102
|
|
|
99
103
|
@classmethod
|
|
100
104
|
def _from_params(cls, *, name: str, is_required: bool, params: FloatParams[ClientT], **kwargs: t.Any) -> te.Self:
|
arc/command/option/int.py
CHANGED
|
@@ -3,12 +3,12 @@ from __future__ import annotations
|
|
|
3
3
|
import typing as t
|
|
4
4
|
|
|
5
5
|
import attr
|
|
6
|
-
import hikari
|
|
7
6
|
|
|
8
|
-
from arc.abc.option import OptionWithChoices, OptionWithChoicesParams
|
|
7
|
+
from arc.abc.option import OptionType, OptionWithChoices, OptionWithChoicesParams
|
|
9
8
|
from arc.internal.types import ClientT
|
|
10
9
|
|
|
11
10
|
if t.TYPE_CHECKING:
|
|
11
|
+
import hikari
|
|
12
12
|
import typing_extensions as te
|
|
13
13
|
|
|
14
14
|
from ...internal.types import AutocompleteCallbackT
|
|
@@ -16,15 +16,19 @@ if t.TYPE_CHECKING:
|
|
|
16
16
|
__all__ = ("IntOption", "IntParams")
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
@t.final
|
|
19
20
|
class IntParams(OptionWithChoicesParams[int, ClientT]):
|
|
20
21
|
"""The parameters for an int option.
|
|
21
22
|
|
|
22
23
|
Parameters
|
|
23
24
|
----------
|
|
24
|
-
name : str
|
|
25
|
-
The name of the option
|
|
26
25
|
description : str
|
|
27
26
|
The description of the option
|
|
27
|
+
|
|
28
|
+
Other Parameters
|
|
29
|
+
----------------
|
|
30
|
+
name : str
|
|
31
|
+
The name of the option. If not provided, the name of the parameter will be used.
|
|
28
32
|
name_localizations : Mapping[hikari.Locale, str] | None
|
|
29
33
|
The name of the option in different locales
|
|
30
34
|
description_localizations : Mapping[hikari.Locale, str] | None
|
|
@@ -44,9 +48,9 @@ class IntParams(OptionWithChoicesParams[int, ClientT]):
|
|
|
44
48
|
|
|
45
49
|
def __init__(
|
|
46
50
|
self,
|
|
47
|
-
name: str | None = None,
|
|
48
51
|
description: str = "No description provided.",
|
|
49
52
|
*,
|
|
53
|
+
name: str | None = None,
|
|
50
54
|
name_localizations: t.Mapping[hikari.Locale, str] | None = None,
|
|
51
55
|
description_localizations: t.Mapping[hikari.Locale, str] | None = None,
|
|
52
56
|
min: int | None = None,
|
|
@@ -93,8 +97,8 @@ class IntOption(OptionWithChoices[int, ClientT, IntParams[ClientT]]):
|
|
|
93
97
|
"""The maximum value of the option."""
|
|
94
98
|
|
|
95
99
|
@property
|
|
96
|
-
def option_type(self) ->
|
|
97
|
-
return
|
|
100
|
+
def option_type(self) -> OptionType:
|
|
101
|
+
return OptionType.INTEGER
|
|
98
102
|
|
|
99
103
|
@classmethod
|
|
100
104
|
def _from_params(cls, *, name: str, is_required: bool, params: IntParams[ClientT], **kwargs: t.Any) -> te.Self:
|
|
@@ -5,7 +5,7 @@ import typing as t
|
|
|
5
5
|
import attr
|
|
6
6
|
import hikari
|
|
7
7
|
|
|
8
|
-
from arc.abc.option import CommandOptionBase, OptionParams
|
|
8
|
+
from arc.abc.option import CommandOptionBase, OptionParams, OptionType
|
|
9
9
|
from arc.internal.types import ClientT
|
|
10
10
|
|
|
11
11
|
if t.TYPE_CHECKING:
|
|
@@ -14,16 +14,20 @@ if t.TYPE_CHECKING:
|
|
|
14
14
|
__all__ = ("MentionableOption", "MentionableParams")
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
@t.final
|
|
17
18
|
class MentionableParams(OptionParams[hikari.Role | hikari.User]):
|
|
18
19
|
"""The parameters for a mentionable option.
|
|
19
20
|
This is an option of type `hikari.Role | hikari.User`.
|
|
20
21
|
|
|
21
22
|
Parameters
|
|
22
23
|
----------
|
|
23
|
-
name : str
|
|
24
|
-
The name of the option
|
|
25
24
|
description : str
|
|
26
25
|
The description of the option
|
|
26
|
+
|
|
27
|
+
Other Parameters
|
|
28
|
+
----------------
|
|
29
|
+
name : str
|
|
30
|
+
The name of the option. If not provided, the name of the parameter will be used.
|
|
27
31
|
name_localizations : Mapping[hikari.Locale, str] | None
|
|
28
32
|
The name of the option in different locales
|
|
29
33
|
description_localizations : Mapping[hikari.Locale, str] | None
|
|
@@ -43,8 +47,8 @@ class MentionableOption(CommandOptionBase[hikari.Role | hikari.User, ClientT, Me
|
|
|
43
47
|
"""
|
|
44
48
|
|
|
45
49
|
@property
|
|
46
|
-
def option_type(self) ->
|
|
47
|
-
return
|
|
50
|
+
def option_type(self) -> OptionType:
|
|
51
|
+
return OptionType.MENTIONABLE
|
|
48
52
|
|
|
49
53
|
@classmethod
|
|
50
54
|
def _from_params(cls, *, name: str, is_required: bool, params: MentionableParams, **kwargs: t.Any) -> te.Self:
|
arc/command/option/role.py
CHANGED
|
@@ -5,7 +5,7 @@ import typing as t
|
|
|
5
5
|
import attr
|
|
6
6
|
import hikari
|
|
7
7
|
|
|
8
|
-
from arc.abc.option import CommandOptionBase, OptionParams
|
|
8
|
+
from arc.abc.option import CommandOptionBase, OptionParams, OptionType
|
|
9
9
|
from arc.internal.types import ClientT
|
|
10
10
|
|
|
11
11
|
if t.TYPE_CHECKING:
|
|
@@ -14,15 +14,19 @@ if t.TYPE_CHECKING:
|
|
|
14
14
|
__all__ = ("RoleOption", "RoleParams")
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
@t.final
|
|
17
18
|
class RoleParams(OptionParams[hikari.Role]):
|
|
18
19
|
"""The parameters for a user option.
|
|
19
20
|
|
|
20
21
|
Parameters
|
|
21
22
|
----------
|
|
22
|
-
name : str
|
|
23
|
-
The name of the option. If not provided, the name of the parameter will be used.
|
|
24
23
|
description : str
|
|
25
24
|
The description of the option
|
|
25
|
+
|
|
26
|
+
Other Parameters
|
|
27
|
+
----------------
|
|
28
|
+
name : str
|
|
29
|
+
The name of the option. If not provided, the name of the parameter will be used.
|
|
26
30
|
name_localizations : t.Optional[t.Mapping[str, str]]
|
|
27
31
|
The localizations for the name of the option
|
|
28
32
|
description_localizations : t.Optional[t.Mapping[str, str]]
|
|
@@ -42,8 +46,8 @@ class RoleOption(CommandOptionBase[hikari.Role, ClientT, RoleParams]):
|
|
|
42
46
|
"""
|
|
43
47
|
|
|
44
48
|
@property
|
|
45
|
-
def option_type(self) ->
|
|
46
|
-
return
|
|
49
|
+
def option_type(self) -> OptionType:
|
|
50
|
+
return OptionType.ROLE
|
|
47
51
|
|
|
48
52
|
@classmethod
|
|
49
53
|
def _from_params(cls, *, name: str, is_required: bool, params: RoleParams, **kwargs: t.Any) -> te.Self:
|
arc/command/option/str.py
CHANGED
|
@@ -3,12 +3,12 @@ from __future__ import annotations
|
|
|
3
3
|
import typing as t
|
|
4
4
|
|
|
5
5
|
import attr
|
|
6
|
-
import hikari
|
|
7
6
|
|
|
8
|
-
from arc.abc.option import OptionWithChoices, OptionWithChoicesParams
|
|
7
|
+
from arc.abc.option import OptionType, OptionWithChoices, OptionWithChoicesParams
|
|
9
8
|
from arc.internal.types import ClientT
|
|
10
9
|
|
|
11
10
|
if t.TYPE_CHECKING:
|
|
11
|
+
import hikari
|
|
12
12
|
import typing_extensions as te
|
|
13
13
|
|
|
14
14
|
from arc.internal.types import AutocompleteCallbackT
|
|
@@ -17,15 +17,19 @@ if t.TYPE_CHECKING:
|
|
|
17
17
|
__all__ = ("StrOption", "StrParams")
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
@t.final
|
|
20
21
|
class StrParams(OptionWithChoicesParams[str, ClientT]):
|
|
21
22
|
"""The parameters for a string option.
|
|
22
23
|
|
|
23
24
|
Parameters
|
|
24
25
|
----------
|
|
25
|
-
name : str
|
|
26
|
-
The name of the option
|
|
27
26
|
description : str
|
|
28
27
|
The description of the option
|
|
28
|
+
|
|
29
|
+
Other Parameters
|
|
30
|
+
----------------
|
|
31
|
+
name : str
|
|
32
|
+
The name of the option. If not provided, the name of the parameter will be used.
|
|
29
33
|
name_localizations : Mapping[hikari.Locale, str]
|
|
30
34
|
The name of the option in different locales
|
|
31
35
|
description_localizations : Mapping[hikari.Locale, str]
|
|
@@ -45,9 +49,9 @@ class StrParams(OptionWithChoicesParams[str, ClientT]):
|
|
|
45
49
|
|
|
46
50
|
def __init__(
|
|
47
51
|
self,
|
|
48
|
-
name: str | None = None,
|
|
49
52
|
description: str = "No description provided.",
|
|
50
53
|
*,
|
|
54
|
+
name: str | None = None,
|
|
51
55
|
name_localizations: t.Mapping[hikari.Locale, str] | None = None,
|
|
52
56
|
description_localizations: t.Mapping[hikari.Locale, str] | None = None,
|
|
53
57
|
min_length: int | None = None,
|
|
@@ -94,8 +98,8 @@ class StrOption(OptionWithChoices[str, ClientT, StrParams[ClientT]]):
|
|
|
94
98
|
"""The maximum length of the option."""
|
|
95
99
|
|
|
96
100
|
@property
|
|
97
|
-
def option_type(self) ->
|
|
98
|
-
return
|
|
101
|
+
def option_type(self) -> OptionType:
|
|
102
|
+
return OptionType.STRING
|
|
99
103
|
|
|
100
104
|
@classmethod
|
|
101
105
|
def _from_params(cls, *, name: str, is_required: bool, params: StrParams[ClientT], **kwargs: t.Any) -> te.Self:
|
arc/command/option/user.py
CHANGED
|
@@ -5,7 +5,7 @@ import typing as t
|
|
|
5
5
|
import attr
|
|
6
6
|
import hikari
|
|
7
7
|
|
|
8
|
-
from arc.abc.option import CommandOptionBase, OptionParams
|
|
8
|
+
from arc.abc.option import CommandOptionBase, OptionParams, OptionType
|
|
9
9
|
from arc.internal.types import ClientT
|
|
10
10
|
|
|
11
11
|
if t.TYPE_CHECKING:
|
|
@@ -15,15 +15,19 @@ if t.TYPE_CHECKING:
|
|
|
15
15
|
__all__ = ("UserOption", "UserParams")
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
@t.final
|
|
18
19
|
class UserParams(OptionParams[hikari.User]):
|
|
19
20
|
"""The parameters for a user option.
|
|
20
21
|
|
|
21
22
|
Parameters
|
|
22
23
|
----------
|
|
23
|
-
name : str
|
|
24
|
-
The name of the option. If not provided, the name of the parameter will be used.
|
|
25
24
|
description : str
|
|
26
25
|
The description of the option
|
|
26
|
+
|
|
27
|
+
Other Parameters
|
|
28
|
+
----------------
|
|
29
|
+
name : str
|
|
30
|
+
The name of the option. If not provided, the name of the parameter will be used.
|
|
27
31
|
name_localizations : Mapping[hikari.Locale, str] | None
|
|
28
32
|
The name of the option in different locales
|
|
29
33
|
description_localizations : Mapping[hikari.Locale, str] | None
|
|
@@ -43,8 +47,8 @@ class UserOption(CommandOptionBase[hikari.User, ClientT, UserParams]):
|
|
|
43
47
|
"""
|
|
44
48
|
|
|
45
49
|
@property
|
|
46
|
-
def option_type(self) ->
|
|
47
|
-
return
|
|
50
|
+
def option_type(self) -> OptionType:
|
|
51
|
+
return OptionType.USER
|
|
48
52
|
|
|
49
53
|
@classmethod
|
|
50
54
|
def _from_params(cls, *, name: str, is_required: bool, params: UserParams, **kwargs: t.Any) -> te.Self:
|