Browse Source

Add min/max_length to Argument

Co-authored-by: Danny <[email protected]>
pull/8287/head
Soheab 3 years ago
committed by GitHub
parent
commit
6e3c359373
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      discord/app_commands/models.py
  2. 2
      discord/types/command.py

10
discord/app_commands/models.py

@ -756,6 +756,10 @@ class Argument:
The minimum supported value for this parameter. The minimum supported value for this parameter.
max_value: Optional[Union[:class:`int`, :class:`float`]] max_value: Optional[Union[:class:`int`, :class:`float`]]
The maximum supported value for this parameter. 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` autocomplete: :class:`bool`
Whether the argument has autocomplete. Whether the argument has autocomplete.
""" """
@ -769,6 +773,8 @@ class Argument:
'channel_types', 'channel_types',
'min_value', 'min_value',
'max_value', 'max_value',
'min_length',
'max_length',
'autocomplete', 'autocomplete',
'parent', 'parent',
'_state', '_state',
@ -791,6 +797,8 @@ class Argument:
self.required: bool = data.get('required', False) self.required: bool = data.get('required', False)
self.min_value: Optional[Union[int, float]] = data.get('min_value') self.min_value: Optional[Union[int, float]] = data.get('min_value')
self.max_value: Optional[Union[int, float]] = data.get('max_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.autocomplete: bool = data.get('autocomplete', False)
self.channel_types: List[ChannelType] = [try_enum(ChannelType, d) for d in data.get('channel_types', [])] self.channel_types: List[ChannelType] = [try_enum(ChannelType, d) for d in data.get('channel_types', [])]
self.choices: List[Choice[Union[int, float, str]]] = [ 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], 'channel_types': [channel_type.value for channel_type in self.channel_types],
'min_value': self.min_value, 'min_value': self.min_value,
'max_value': self.max_value, 'max_value': self.max_value,
'min_length': self.min_length,
'max_length': self.max_length,
'autocomplete': self.autocomplete, 'autocomplete': self.autocomplete,
'options': [], 'options': [],
} # type: ignore # Type checker does not understand this literal. } # type: ignore # Type checker does not understand this literal.

2
discord/types/command.py

@ -61,6 +61,8 @@ class _StringApplicationCommandOptionChoice(TypedDict):
class _StringApplicationCommandOption(_BaseApplicationCommandOption): class _StringApplicationCommandOption(_BaseApplicationCommandOption):
type: Literal[3] type: Literal[3]
choices: NotRequired[List[_StringApplicationCommandOptionChoice]] choices: NotRequired[List[_StringApplicationCommandOptionChoice]]
min_length: NotRequired[int]
max_length: NotRequired[int]
autocomplete: NotRequired[bool] autocomplete: NotRequired[bool]

Loading…
Cancel
Save