mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-20 16:00:29 +00:00
Add min/max_length to Argument
Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com>
This commit is contained in:
parent
f5b0717661
commit
6e3c359373
@ -756,6 +756,10 @@ class Argument:
|
||||
The minimum supported value for this parameter.
|
||||
max_value: Optional[Union[:class:`int`, :class:`float`]]
|
||||
The maximum supported value for this parameter.
|
||||
min_length: Optional[:class:`int`]
|
||||
The minimum allowed length for this parameter.
|
||||
max_length: Optional[:class:`int`]
|
||||
The maximum allowed length for this parameter.
|
||||
autocomplete: :class:`bool`
|
||||
Whether the argument has autocomplete.
|
||||
"""
|
||||
@ -769,6 +773,8 @@ class Argument:
|
||||
'channel_types',
|
||||
'min_value',
|
||||
'max_value',
|
||||
'min_length',
|
||||
'max_length',
|
||||
'autocomplete',
|
||||
'parent',
|
||||
'_state',
|
||||
@ -791,6 +797,8 @@ class Argument:
|
||||
self.required: bool = data.get('required', False)
|
||||
self.min_value: Optional[Union[int, float]] = data.get('min_value')
|
||||
self.max_value: Optional[Union[int, float]] = data.get('max_value')
|
||||
self.min_length: Optional[int] = data.get('min_length')
|
||||
self.max_length: Optional[int] = data.get('max_length')
|
||||
self.autocomplete: bool = data.get('autocomplete', False)
|
||||
self.channel_types: List[ChannelType] = [try_enum(ChannelType, d) for d in data.get('channel_types', [])]
|
||||
self.choices: List[Choice[Union[int, float, str]]] = [
|
||||
@ -807,6 +815,8 @@ class Argument:
|
||||
'channel_types': [channel_type.value for channel_type in self.channel_types],
|
||||
'min_value': self.min_value,
|
||||
'max_value': self.max_value,
|
||||
'min_length': self.min_length,
|
||||
'max_length': self.max_length,
|
||||
'autocomplete': self.autocomplete,
|
||||
'options': [],
|
||||
} # type: ignore # Type checker does not understand this literal.
|
||||
|
@ -61,6 +61,8 @@ class _StringApplicationCommandOptionChoice(TypedDict):
|
||||
class _StringApplicationCommandOption(_BaseApplicationCommandOption):
|
||||
type: Literal[3]
|
||||
choices: NotRequired[List[_StringApplicationCommandOptionChoice]]
|
||||
min_length: NotRequired[int]
|
||||
max_length: NotRequired[int]
|
||||
autocomplete: NotRequired[bool]
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user