1
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
2
|
|
|
# MIT License |
3
|
|
|
# |
4
|
|
|
# Copyright (c) 2021 Pincer |
5
|
|
|
# |
6
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining |
7
|
|
|
# a copy of this software and associated documentation files |
8
|
|
|
# (the "Software"), to deal in the Software without restriction, |
9
|
|
|
# including without limitation the rights to use, copy, modify, merge, |
10
|
|
|
# publish, distribute, sublicense, and/or sell copies of the Software, |
11
|
|
|
# and to permit persons to whom the Software is furnished to do so, |
12
|
|
|
# subject to the following conditions: |
13
|
|
|
# |
14
|
|
|
# The above copyright notice and this permission notice shall be |
15
|
|
|
# included in all copies or substantial portions of the Software. |
16
|
|
|
# |
17
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
18
|
|
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
19
|
|
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
20
|
|
|
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
21
|
|
|
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
22
|
|
|
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
23
|
|
|
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
24
|
|
|
|
25
|
|
|
from dataclasses import dataclass |
26
|
|
|
from typing import List |
27
|
|
|
|
28
|
|
|
from pincer.objects.emoji import Emoji |
29
|
|
|
from pincer.utils.api_object import APIObject |
30
|
|
|
from pincer.utils.constants import MISSING, APINullable |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
@dataclass |
34
|
|
|
class SelectOption(APIObject): |
35
|
|
|
""" |
36
|
|
|
Represents a Discord Select Option object |
37
|
|
|
|
38
|
|
|
:param label: |
39
|
|
|
the user-facing name of the option, max 100 characters |
40
|
|
|
|
41
|
|
|
:param value: |
42
|
|
|
the def-defined value of the option, max 100 characters |
43
|
|
|
|
44
|
|
|
:param description: |
45
|
|
|
an additional description of the option, max 100 characters |
46
|
|
|
|
47
|
|
|
:param emoji: |
48
|
|
|
`id`, `name`, and `animated` |
49
|
|
|
|
50
|
|
|
:param default: |
51
|
|
|
will render this option as selected by default |
52
|
|
|
""" |
53
|
|
|
label: str |
54
|
|
|
value: str |
55
|
|
|
description: APINullable[str] = MISSING |
|
|
|
|
56
|
|
|
emoji: APINullable[Emoji] = MISSING |
|
|
|
|
57
|
|
|
default: APINullable[bool] = MISSING |
|
|
|
|
58
|
|
|
|
59
|
|
|
|
60
|
|
|
@dataclass |
61
|
|
|
class SelectMenu(APIObject): |
62
|
|
|
""" |
63
|
|
|
Represents a Discord Select Menu object |
64
|
|
|
|
65
|
|
|
:param type: |
66
|
|
|
`3` for a select menu |
67
|
|
|
|
68
|
|
|
:param custom_id: |
69
|
|
|
a developer-defined identifier for the button, |
70
|
|
|
max 100 characters |
71
|
|
|
|
72
|
|
|
:param options: |
73
|
|
|
the choices in the select, max 25 |
74
|
|
|
|
75
|
|
|
:param placeholder: |
76
|
|
|
custom placeholder text if nothing is selected, |
77
|
|
|
max 100 characters |
78
|
|
|
|
79
|
|
|
:param min_values: |
80
|
|
|
the minimum number of items that must be chosen; |
81
|
|
|
default 1, min 0, max 25 |
82
|
|
|
|
83
|
|
|
:param max_values: |
84
|
|
|
the maximum number of items that can be chosen; |
85
|
|
|
default 1, max 25 |
86
|
|
|
|
87
|
|
|
:param disabled: |
88
|
|
|
disable the select, default False |
89
|
|
|
""" |
90
|
|
|
type: int |
91
|
|
|
custom_id: str |
92
|
|
|
options: List[SelectOption] |
93
|
|
|
|
94
|
|
|
placeholder: APINullable[str] = MISSING |
|
|
|
|
95
|
|
|
min_values: APINullable[int] = 1 |
|
|
|
|
96
|
|
|
max_values: APINullable[int] = 1 |
|
|
|
|
97
|
|
|
disabled: APINullable[bool] = False |
|
|
|
|
98
|
|
|
|