mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-06 11:57:17 +00:00
Remove private legacy cruft from AppCommand models
- Document `options` for AppCommand - Remove `choices` and `required` from AppCommandGroup - Rename `arguments` to `options` since it can include `AppCommand` and `AppCommandGroup`.
This commit is contained in:
parent
b0cb458f9f
commit
3cb90199c9
@ -145,6 +145,8 @@ class AppCommand(Hashable):
|
|||||||
The application command's name.
|
The application command's name.
|
||||||
description: :class:`str`
|
description: :class:`str`
|
||||||
The application command's description.
|
The application command's description.
|
||||||
|
options: List[Union[:class:`AppCommand`, :class:`AppCommandGroup`]]
|
||||||
|
A list of options.
|
||||||
default_member_permissions: Optional[:class:`~discord.Permissions`]
|
default_member_permissions: Optional[:class:`~discord.Permissions`]
|
||||||
The default member permissions that can run this command.
|
The default member permissions that can run this command.
|
||||||
dm_permission: :class:`bool`
|
dm_permission: :class:`bool`
|
||||||
@ -798,12 +800,8 @@ class AppCommandGroup:
|
|||||||
The name of the subcommand.
|
The name of the subcommand.
|
||||||
description: :class:`str`
|
description: :class:`str`
|
||||||
The description of the subcommand.
|
The description of the subcommand.
|
||||||
required: :class:`bool`
|
options: List[Union[:class:`AppCommand`, :class:`AppCommandGroup`]]
|
||||||
Whether the subcommand is required.
|
A list of options.
|
||||||
choices: List[:class:`Choice`]
|
|
||||||
A list of choices for the command to choose from for this subcommand.
|
|
||||||
arguments: List[:class:`Argument`]
|
|
||||||
A list of arguments.
|
|
||||||
parent: Union[:class:`AppCommand`, :class:`AppCommandGroup`]
|
parent: Union[:class:`AppCommand`, :class:`AppCommandGroup`]
|
||||||
The parent application command.
|
The parent application command.
|
||||||
"""
|
"""
|
||||||
@ -812,9 +810,7 @@ class AppCommandGroup:
|
|||||||
'type',
|
'type',
|
||||||
'name',
|
'name',
|
||||||
'description',
|
'description',
|
||||||
'required',
|
'options',
|
||||||
'choices',
|
|
||||||
'arguments',
|
|
||||||
'parent',
|
'parent',
|
||||||
'_state',
|
'_state',
|
||||||
)
|
)
|
||||||
@ -827,20 +823,14 @@ class AppCommandGroup:
|
|||||||
self._from_data(data)
|
self._from_data(data)
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f'<{self.__class__.__name__} name={self.name!r} type={self.type!r} required={self.required}>'
|
return f'<{self.__class__.__name__} name={self.name!r} type={self.type!r}>'
|
||||||
|
|
||||||
def _from_data(self, data: ApplicationCommandOption) -> None:
|
def _from_data(self, data: ApplicationCommandOption) -> None:
|
||||||
self.type: AppCommandOptionType = try_enum(AppCommandOptionType, data['type'])
|
self.type: AppCommandOptionType = try_enum(AppCommandOptionType, data['type'])
|
||||||
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.options: List[Union[Argument, AppCommandGroup]] = [
|
||||||
self.choices: List[Choice[Union[int, float, str]]] = [
|
app_command_option_factory(data=d, parent=self, state=self._state) for d in data.get('options', [])
|
||||||
Choice(name=d['name'], value=d['value']) for d in data.get('choices', [])
|
|
||||||
]
|
|
||||||
self.arguments: List[Argument] = [
|
|
||||||
Argument(parent=self, state=self._state, data=d)
|
|
||||||
for d in data.get('options', [])
|
|
||||||
if is_app_command_argument_type(d['type'])
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def to_dict(self) -> 'ApplicationCommandOption':
|
def to_dict(self) -> 'ApplicationCommandOption':
|
||||||
@ -848,9 +838,7 @@ class AppCommandGroup:
|
|||||||
'name': self.name,
|
'name': self.name,
|
||||||
'type': self.type.value,
|
'type': self.type.value,
|
||||||
'description': self.description,
|
'description': self.description,
|
||||||
'required': self.required,
|
'options': [arg.to_dict() for arg in self.options],
|
||||||
'choices': [choice.to_dict() for choice in self.choices],
|
|
||||||
'options': [arg.to_dict() for arg in self.arguments],
|
|
||||||
} # type: ignore # Type checker does not understand this literal.
|
} # type: ignore # Type checker does not understand this literal.
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user