scurrypy 0.4.2__py3-none-any.whl → 0.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of scurrypy might be problematic. Click here for more details.
- discord/__init__.py +219 -66
- discord/dispatch/command_dispatcher.py +10 -2
- discord/events/channel_events.py +1 -1
- discord/events/interaction_events.py +19 -7
- discord/http.py +1 -1
- discord/models/emoji.py +1 -1
- discord/models/interaction.py +5 -0
- discord/parts/channel.py +24 -2
- discord/parts/command.py +45 -57
- discord/parts/components.py +224 -0
- discord/parts/components_v2.py +77 -286
- discord/parts/embed.py +38 -109
- discord/parts/message.py +46 -103
- discord/parts/modal.py +9 -14
- discord/parts/role.py +1 -13
- discord/resources/channel.py +4 -4
- discord/resources/guild.py +0 -1
- discord/resources/interaction.py +20 -19
- discord/resources/message.py +10 -10
- {scurrypy-0.4.2.dist-info → scurrypy-0.5.dist-info}/METADATA +6 -13
- {scurrypy-0.4.2.dist-info → scurrypy-0.5.dist-info}/RECORD +24 -24
- discord/parts/action_row.py +0 -208
- {scurrypy-0.4.2.dist-info → scurrypy-0.5.dist-info}/WHEEL +0 -0
- {scurrypy-0.4.2.dist-info → scurrypy-0.5.dist-info}/licenses/LICENSE +0 -0
- {scurrypy-0.4.2.dist-info → scurrypy-0.5.dist-info}/top_level.txt +0 -0
discord/parts/action_row.py
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass, field
|
|
2
|
-
from typing import Literal, Optional
|
|
3
|
-
from ..model import DataModel
|
|
4
|
-
|
|
5
|
-
from .component_types import *
|
|
6
|
-
|
|
7
|
-
from ..models.emoji import EmojiModel
|
|
8
|
-
|
|
9
|
-
class _ButtonStyles:
|
|
10
|
-
"""Represents button styles for a Button component."""
|
|
11
|
-
PRIMARY = 1
|
|
12
|
-
SECONDARY = 2
|
|
13
|
-
SUCCESS = 3
|
|
14
|
-
DANGER = 4
|
|
15
|
-
LINK = 5
|
|
16
|
-
|
|
17
|
-
@dataclass
|
|
18
|
-
class _Button(DataModel, ActionRowChild, SectionAccessory):
|
|
19
|
-
"""Represents the Button component."""
|
|
20
|
-
style: int
|
|
21
|
-
custom_id: str
|
|
22
|
-
label: Optional[str] = None
|
|
23
|
-
emoji: EmojiModel = None
|
|
24
|
-
url: Optional[str] = None
|
|
25
|
-
disabled: Optional[bool] = False
|
|
26
|
-
type: Literal[2] = field(init=False, default=2)
|
|
27
|
-
|
|
28
|
-
@dataclass
|
|
29
|
-
class _SelectOption(DataModel):
|
|
30
|
-
"""Represents the Select Option component"""
|
|
31
|
-
label: str
|
|
32
|
-
value: str
|
|
33
|
-
description: Optional[str] = None # appears below the label
|
|
34
|
-
emoji: Optional[EmojiModel] = None
|
|
35
|
-
default: Optional[bool] = False
|
|
36
|
-
|
|
37
|
-
@dataclass
|
|
38
|
-
class StringSelect(DataModel, ActionRowChild, LabelChild):
|
|
39
|
-
"""Represents the String Select component."""
|
|
40
|
-
custom_id: str
|
|
41
|
-
options: list[_SelectOption] = field(default_factory=list)
|
|
42
|
-
placeholder: Optional[str] = None
|
|
43
|
-
min_values: Optional[int] = 0
|
|
44
|
-
max_values: Optional[int] = 1
|
|
45
|
-
required: Optional[bool] = False
|
|
46
|
-
disabled: Optional[bool] = False # does not work on Modals!
|
|
47
|
-
type: Literal[3] = field(init=False, default=3)
|
|
48
|
-
|
|
49
|
-
def add_option(self,
|
|
50
|
-
*,
|
|
51
|
-
label: str,
|
|
52
|
-
value: str,
|
|
53
|
-
description: str = None,
|
|
54
|
-
emoji: str | EmojiModel = None,
|
|
55
|
-
default: bool = False
|
|
56
|
-
):
|
|
57
|
-
"""Add an option to this string select component.
|
|
58
|
-
|
|
59
|
-
Args:
|
|
60
|
-
label (str): option text
|
|
61
|
-
value (str): analogous to button's custom ID
|
|
62
|
-
description (str, optional): option subtext
|
|
63
|
-
emoji (str | EmojiModel, optional): string if unicode emoji, EmojiModel if custom
|
|
64
|
-
default (bool, optional): if this option should be the default option. Defaults to False.
|
|
65
|
-
|
|
66
|
-
Returns:
|
|
67
|
-
(StringSelect): self
|
|
68
|
-
"""
|
|
69
|
-
if isinstance(emoji, str):
|
|
70
|
-
emoji = EmojiModel(name=emoji)
|
|
71
|
-
|
|
72
|
-
self.options.append(
|
|
73
|
-
_SelectOption(
|
|
74
|
-
label=label,
|
|
75
|
-
value=value,
|
|
76
|
-
description=description,
|
|
77
|
-
emoji=emoji,
|
|
78
|
-
default=default
|
|
79
|
-
)
|
|
80
|
-
)
|
|
81
|
-
return self
|
|
82
|
-
|
|
83
|
-
@dataclass
|
|
84
|
-
class _DefaultValue(DataModel):
|
|
85
|
-
"""Represents the Default Value for Select components."""
|
|
86
|
-
id: int # ID of role, user, or channel
|
|
87
|
-
type: Literal["role", "user", "channel"]
|
|
88
|
-
|
|
89
|
-
@dataclass
|
|
90
|
-
class UserSelect(DataModel, ActionRowChild, LabelChild):
|
|
91
|
-
"""Represents the User Select component."""
|
|
92
|
-
custom_id: str
|
|
93
|
-
placeholder: Optional[str] = None
|
|
94
|
-
default_values: list[_DefaultValue] = field(default_factory=list)
|
|
95
|
-
min_values: Optional[int] = 0
|
|
96
|
-
max_values: Optional[int] = 1
|
|
97
|
-
disabled: Optional[bool] = False
|
|
98
|
-
type: Literal[5] = field(init=False, default=5)
|
|
99
|
-
|
|
100
|
-
def add_default_value(self, user_id: int):
|
|
101
|
-
self.default_values.append(_DefaultValue(user_id, 'user'))
|
|
102
|
-
return self
|
|
103
|
-
|
|
104
|
-
@dataclass
|
|
105
|
-
class RoleSelect(DataModel, ActionRowChild, LabelChild):
|
|
106
|
-
"""Represents the Role Select component."""
|
|
107
|
-
custom_id: str
|
|
108
|
-
placeholder: Optional[str] = None
|
|
109
|
-
default_values: list[_DefaultValue] = field(default_factory=list)
|
|
110
|
-
min_values: Optional[int] = 0
|
|
111
|
-
max_values: Optional[int] = 1
|
|
112
|
-
disabled: Optional[bool] = False
|
|
113
|
-
type: Literal[6] = field(init=False, default=6)
|
|
114
|
-
|
|
115
|
-
def add_default_value(self, role_id: int):
|
|
116
|
-
self.default_values.append(_DefaultValue(role_id, 'role'))
|
|
117
|
-
return self
|
|
118
|
-
|
|
119
|
-
@dataclass
|
|
120
|
-
class MentionableSelect(DataModel, ActionRowChild, LabelChild):
|
|
121
|
-
"""Represents the Mentionable Select component."""
|
|
122
|
-
custom_id: str
|
|
123
|
-
placeholder: Optional[str] = None
|
|
124
|
-
default_values: list[_DefaultValue] = field(default_factory=list)
|
|
125
|
-
min_values: Optional[int] = 0
|
|
126
|
-
max_values: Optional[int] = 1
|
|
127
|
-
disabled: Optional[bool] = False
|
|
128
|
-
type: Literal[7] = field(init=False, default=7)
|
|
129
|
-
|
|
130
|
-
def add_default_value(self, role_or_user_id: int, role_or_user: Literal['user', 'role']):
|
|
131
|
-
self.default_values.append(_DefaultValue(role_or_user_id, role_or_user))
|
|
132
|
-
return self
|
|
133
|
-
|
|
134
|
-
@dataclass
|
|
135
|
-
class ChannelSelect(DataModel, ActionRowChild, LabelChild):
|
|
136
|
-
"""Represents the Channel Select component."""
|
|
137
|
-
custom_id: str
|
|
138
|
-
placeholder: Optional[str] = None
|
|
139
|
-
default_values: list[_DefaultValue] = field(default_factory=list)
|
|
140
|
-
min_values: Optional[int] = 0
|
|
141
|
-
max_values: Optional[int] = 1
|
|
142
|
-
disabled: Optional[bool] = False
|
|
143
|
-
type: Literal[8] = field(init=False, default=8)
|
|
144
|
-
|
|
145
|
-
def add_default_value(self, channel_id: int):
|
|
146
|
-
self.default_values.append(_DefaultValue(channel_id, 'channel'))
|
|
147
|
-
return self
|
|
148
|
-
|
|
149
|
-
@dataclass
|
|
150
|
-
class ActionRow(DataModel, ContainerChild):
|
|
151
|
-
"""Represents a container of interactable components."""
|
|
152
|
-
type: Literal[1] = field(init=False, default=1)
|
|
153
|
-
components: list[ActionRowChild] = field(default_factory=list)
|
|
154
|
-
|
|
155
|
-
def add_button(self,
|
|
156
|
-
*,
|
|
157
|
-
style: Literal['Primary', 'Secondary', 'Success', 'Danger', 'Link'],
|
|
158
|
-
label: str,
|
|
159
|
-
custom_id: str,
|
|
160
|
-
emoji: str | EmojiModel = None,
|
|
161
|
-
disable: bool = False
|
|
162
|
-
):
|
|
163
|
-
"""Add a button to this action row. (5 per row)
|
|
164
|
-
|
|
165
|
-
Args:
|
|
166
|
-
style (Literal['Primary', 'Secondary', 'Success', 'Danger', 'Link']):
|
|
167
|
-
button style as a string
|
|
168
|
-
label (str): button text
|
|
169
|
-
custom_id (str): developer-defined button ID
|
|
170
|
-
emoji (str | EmojiModel, Optional): str if unicode emoji, EmojiModal if custom
|
|
171
|
-
disable (bool, Optional): if this button should be pressable. Defaults to False.
|
|
172
|
-
|
|
173
|
-
Returns:
|
|
174
|
-
(ActionRow): self
|
|
175
|
-
"""
|
|
176
|
-
_styles = {
|
|
177
|
-
'PRIMARY': _ButtonStyles.PRIMARY,
|
|
178
|
-
'SECONDARY': _ButtonStyles.SECONDARY,
|
|
179
|
-
'SUCCESS': _ButtonStyles.SUCCESS,
|
|
180
|
-
'DANGER': _ButtonStyles.DANGER,
|
|
181
|
-
'LINK': _ButtonStyles.LINK
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if isinstance(emoji, str):
|
|
185
|
-
emoji = EmojiModel(name=emoji)
|
|
186
|
-
|
|
187
|
-
self.components.append(
|
|
188
|
-
_Button(
|
|
189
|
-
style=_styles.get(style.upper()),
|
|
190
|
-
label=label,
|
|
191
|
-
custom_id=custom_id,
|
|
192
|
-
emoji=emoji,
|
|
193
|
-
disabled=disable
|
|
194
|
-
)
|
|
195
|
-
)
|
|
196
|
-
return self
|
|
197
|
-
|
|
198
|
-
def set_select_menu(self, select: StringSelect | UserSelect | RoleSelect | ChannelSelect | MentionableSelect):
|
|
199
|
-
"""Add a select menu component to this action row. (1 per row)
|
|
200
|
-
|
|
201
|
-
Args:
|
|
202
|
-
select (StringSelect | UserSelect | RoleSelect | ChannelSelect | MentionableSelect): the select menu component
|
|
203
|
-
|
|
204
|
-
Returns:
|
|
205
|
-
(ActionRow): self
|
|
206
|
-
"""
|
|
207
|
-
self.components.append(select)
|
|
208
|
-
return self
|
|
File without changes
|
|
File without changes
|
|
File without changes
|