mirror of
https://github.com/MelisaDev/melisa.git
synced 2024-09-22 19:22:01 +03:00
feat(interactions): add [ApplicationCommandOptionChoice, ApplicationCommandOptionTypes]
This commit is contained in:
parent
7830dd6165
commit
e25f095c5b
1 changed files with 95 additions and 0 deletions
|
@ -4,6 +4,9 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
|
from typing import Optional, Dict, Union, Any
|
||||||
|
|
||||||
|
from ...utils.api_model import APIModelBase
|
||||||
|
|
||||||
|
|
||||||
class ApplicationCommandTypes(IntEnum):
|
class ApplicationCommandTypes(IntEnum):
|
||||||
|
@ -25,3 +28,95 @@ class ApplicationCommandTypes(IntEnum):
|
||||||
|
|
||||||
def __int__(self):
|
def __int__(self):
|
||||||
return self.value
|
return self.value
|
||||||
|
|
||||||
|
|
||||||
|
class ApplicationCommandOptionTypes(IntEnum):
|
||||||
|
"""Application Command Option Types
|
||||||
|
|
||||||
|
Attributes
|
||||||
|
----------
|
||||||
|
SUB_COMMAND:
|
||||||
|
Sub command
|
||||||
|
SUB_COMMAND_GROUP:
|
||||||
|
Sub command group
|
||||||
|
STRING:
|
||||||
|
:class:`str`
|
||||||
|
INTEGER:
|
||||||
|
:class:`int` between -2^53 and 2^53
|
||||||
|
BOOLEAN:
|
||||||
|
:class:`bool`
|
||||||
|
USER:
|
||||||
|
user
|
||||||
|
CHANNEL:
|
||||||
|
includes all channel types + categories
|
||||||
|
ROLE:
|
||||||
|
role
|
||||||
|
MENTIONABLE:
|
||||||
|
Includes users and roles
|
||||||
|
NUMBER:
|
||||||
|
Any :class:`float` between -2^53 and 2^53
|
||||||
|
ATTACHMENT:
|
||||||
|
Attachment object
|
||||||
|
"""
|
||||||
|
|
||||||
|
SUB_COMMAND = 1
|
||||||
|
SUB_COMMAND_GROUP = 2
|
||||||
|
STRING = 3
|
||||||
|
INTEGER = 4
|
||||||
|
BOOLEAN = 5
|
||||||
|
USER = 6
|
||||||
|
CHANNEL = 7
|
||||||
|
ROLE = 8
|
||||||
|
MENTIONABLE = 9
|
||||||
|
NUMBER = 10
|
||||||
|
ATTACHMENT = 11
|
||||||
|
|
||||||
|
def __int__(self):
|
||||||
|
return self.value
|
||||||
|
|
||||||
|
|
||||||
|
class ApplicationCommandOptionChoice(APIModelBase):
|
||||||
|
"""Application Command Option Choice
|
||||||
|
|
||||||
|
If you specify ``choices`` for an option,
|
||||||
|
they are the only valid values for a user to pick
|
||||||
|
|
||||||
|
Attributes
|
||||||
|
----------
|
||||||
|
name: :class:`str`
|
||||||
|
1-100 character choice name
|
||||||
|
name_localizations: Optional[Dict[:class:`str`, :class:`str`]]
|
||||||
|
Dictionary with keys in
|
||||||
|
`avaliable locales <https://discord.com/developers/docs/reference#locales>`_
|
||||||
|
|
||||||
|
Localization dictionary for the name field.
|
||||||
|
Values follow the same restrictions as name
|
||||||
|
|
||||||
|
value: Union[:class:`str`, :class:`int`, :class:`float`]
|
||||||
|
Value for the choice, up to 100 characters if string
|
||||||
|
"""
|
||||||
|
|
||||||
|
name: str
|
||||||
|
name_localizations: Optional[Dict[str, str]]
|
||||||
|
value: Union[str, int, float]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_dict(cls, data: Dict[str, Any]):
|
||||||
|
"""Generate a ApplicationCommandOptionChoice from the given data.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
data: :class:`dict`
|
||||||
|
The dictionary to convert into a ApplicationCommandOptionChoice.
|
||||||
|
"""
|
||||||
|
self: ApplicationCommandOptionChoice = super().__new__(cls)
|
||||||
|
|
||||||
|
self.name = data.get("name")
|
||||||
|
self.name_localizations = data.get("name_localizations")
|
||||||
|
self.value = data.get("value")
|
||||||
|
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue