Browse Source

Add missing data to Argument model

pull/8156/head
Soheab 3 years ago
committed by GitHub
parent
commit
e73a805bd7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      discord/app_commands/models.py

20
discord/app_commands/models.py

@ -745,6 +745,14 @@ class Argument:
A list of choices for the command to choose from for this argument. A list of choices for the command to choose from for this argument.
parent: Union[:class:`AppCommand`, :class:`AppCommandGroup`] parent: Union[:class:`AppCommand`, :class:`AppCommandGroup`]
The parent application command that has this argument. The parent application command that has this argument.
channel_types: List[:class:`~discord.ChannelType`]
The channel types that are allowed for this parameter.
min_value: Optional[Union[:class:`int`, :class:`float`]]
The minimum supported value for this parameter.
max_value: Optional[Union[:class:`int`, :class:`float`]]
The maximum supported value for this parameter.
autocomplete: :class:`bool`
Whether the argument has autocomplete.
""" """
__slots__ = ( __slots__ = (
@ -753,6 +761,10 @@ class Argument:
'description', 'description',
'required', 'required',
'choices', 'choices',
'channel_types',
'min_value',
'max_value',
'autocomplete',
'parent', 'parent',
'_state', '_state',
) )
@ -772,6 +784,10 @@ class Argument:
self.name: str = data['name'] self.name: str = data['name']
self.description: str = data['description'] self.description: str = data['description']
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.max_value: Optional[Union[int, float]] = data.get('max_value')
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]]] = [ self.choices: List[Choice[Union[int, float, str]]] = [
Choice(name=d['name'], value=d['value']) for d in data.get('choices', []) Choice(name=d['name'], value=d['value']) for d in data.get('choices', [])
] ]
@ -783,6 +799,10 @@ class Argument:
'description': self.description, 'description': self.description,
'required': self.required, 'required': self.required,
'choices': [choice.to_dict() for choice in self.choices], 'choices': [choice.to_dict() for choice in self.choices],
'channel_types': [channel_type.value for channel_type in self.channel_types],
'min_value': self.min_value,
'max_value': self.max_value,
'autocomplete': self.autocomplete,
'options': [], 'options': [],
} # type: ignore # Type checker does not understand this literal. } # type: ignore # Type checker does not understand this literal.

Loading…
Cancel
Save