modifyself 0.2.2__tar.gz → 0.2.3__tar.gz
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.
- {modifyself-0.2.2 → modifyself-0.2.3}/PKG-INFO +1 -1
- modifyself-0.2.3/modifyself/components.py +286 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself.egg-info/PKG-INFO +1 -1
- {modifyself-0.2.2 → modifyself-0.2.3}/pyproject.toml +33 -33
- modifyself-0.2.2/modifyself/components.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/LICENSE +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/README.md +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/__init__.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/activity.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/client.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/commands/__init__.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/commands/checks.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/commands/cog.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/commands/context.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/commands/converters.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/commands/core.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/core/bitfield.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/core/enums.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/core/mixins.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/core/snowflake.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/errors.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/gateway/__init__.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/gateway/dispatcher.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/gateway/heartbeat.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/gateway/websocket.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/headers.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/http/__init__.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/http/client.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/http/ratelimit.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/http/route.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/interactions.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/models/__init__.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/models/base.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/models/billing.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/models/channel.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/models/guild.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/models/member.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/models/message.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/models/relationship.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/models/settings.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/models/user.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/models/webhook.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/state.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/types.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/utils.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself/voice.py +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself.egg-info/SOURCES.txt +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself.egg-info/dependency_links.txt +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself.egg-info/requires.txt +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/modifyself.egg-info/top_level.txt +0 -0
- {modifyself-0.2.2 → modifyself-0.2.3}/setup.cfg +0 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Discord components (buttons, selects, modals).
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Optional, List, Dict, Any, Union, Callable, Awaitable
|
|
6
|
+
from enum import IntEnum
|
|
7
|
+
import json
|
|
8
|
+
|
|
9
|
+
class ComponentType(IntEnum):
|
|
10
|
+
ACTION_ROW = 1
|
|
11
|
+
BUTTON = 2
|
|
12
|
+
SELECT_MENU = 3
|
|
13
|
+
TEXT_INPUT = 4
|
|
14
|
+
CHANNEL_SELECT = 5
|
|
15
|
+
ROLE_SELECT = 6
|
|
16
|
+
MENTIONABLE_SELECT = 7
|
|
17
|
+
USER_SELECT = 8
|
|
18
|
+
|
|
19
|
+
class ButtonStyle(IntEnum):
|
|
20
|
+
PRIMARY = 1
|
|
21
|
+
SECONDARY = 2
|
|
22
|
+
SUCCESS = 3
|
|
23
|
+
DANGER = 4
|
|
24
|
+
LINK = 5
|
|
25
|
+
|
|
26
|
+
class TextInputStyle(IntEnum):
|
|
27
|
+
SHORT = 1
|
|
28
|
+
PARAGRAPH = 2
|
|
29
|
+
|
|
30
|
+
class Component:
|
|
31
|
+
def __init__(self, data: dict):
|
|
32
|
+
self.type = data.get("type")
|
|
33
|
+
self._data = data
|
|
34
|
+
|
|
35
|
+
def to_dict(self) -> dict:
|
|
36
|
+
return self._data
|
|
37
|
+
|
|
38
|
+
class Button(Component):
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
style: Union[ButtonStyle, int] = ButtonStyle.PRIMARY,
|
|
42
|
+
label: Optional[str] = None,
|
|
43
|
+
custom_id: Optional[str] = None,
|
|
44
|
+
url: Optional[str] = None,
|
|
45
|
+
emoji: Optional[Dict[str, Any]] = None,
|
|
46
|
+
disabled: bool = False,
|
|
47
|
+
):
|
|
48
|
+
data = {
|
|
49
|
+
"type": ComponentType.BUTTON,
|
|
50
|
+
"style": int(style),
|
|
51
|
+
"disabled": disabled,
|
|
52
|
+
}
|
|
53
|
+
if label:
|
|
54
|
+
data["label"] = label
|
|
55
|
+
if custom_id:
|
|
56
|
+
data["custom_id"] = custom_id
|
|
57
|
+
if url:
|
|
58
|
+
data["url"] = url
|
|
59
|
+
if emoji:
|
|
60
|
+
data["emoji"] = emoji
|
|
61
|
+
super().__init__(data)
|
|
62
|
+
self.style = style
|
|
63
|
+
self.label = label
|
|
64
|
+
self.custom_id = custom_id
|
|
65
|
+
self.url = url
|
|
66
|
+
self.emoji = emoji
|
|
67
|
+
self.disabled = disabled
|
|
68
|
+
|
|
69
|
+
@classmethod
|
|
70
|
+
def primary(cls, label: str, custom_id: str, emoji: Optional[Dict[str, Any]] = None) -> "Button":
|
|
71
|
+
return cls(style=ButtonStyle.PRIMARY, label=label, custom_id=custom_id, emoji=emoji)
|
|
72
|
+
|
|
73
|
+
@classmethod
|
|
74
|
+
def secondary(cls, label: str, custom_id: str, emoji: Optional[Dict[str, Any]] = None) -> "Button":
|
|
75
|
+
return cls(style=ButtonStyle.SECONDARY, label=label, custom_id=custom_id, emoji=emoji)
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
def success(cls, label: str, custom_id: str, emoji: Optional[Dict[str, Any]] = None) -> "Button":
|
|
79
|
+
return cls(style=ButtonStyle.SUCCESS, label=label, custom_id=custom_id, emoji=emoji)
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def danger(cls, label: str, custom_id: str, emoji: Optional[Dict[str, Any]] = None) -> "Button":
|
|
83
|
+
return cls(style=ButtonStyle.DANGER, label=label, custom_id=custom_id, emoji=emoji)
|
|
84
|
+
|
|
85
|
+
@classmethod
|
|
86
|
+
def link(cls, label: str, url: str, emoji: Optional[Dict[str, Any]] = None) -> "Button":
|
|
87
|
+
return cls(style=ButtonStyle.LINK, label=label, url=url, emoji=emoji)
|
|
88
|
+
|
|
89
|
+
class SelectOption:
|
|
90
|
+
def __init__(
|
|
91
|
+
self,
|
|
92
|
+
label: str,
|
|
93
|
+
value: str,
|
|
94
|
+
description: Optional[str] = None,
|
|
95
|
+
emoji: Optional[Dict[str, Any]] = None,
|
|
96
|
+
default: bool = False,
|
|
97
|
+
):
|
|
98
|
+
self.label = label
|
|
99
|
+
self.value = value
|
|
100
|
+
self.description = description
|
|
101
|
+
self.emoji = emoji
|
|
102
|
+
self.default = default
|
|
103
|
+
|
|
104
|
+
def to_dict(self) -> dict:
|
|
105
|
+
data = {"label": self.label, "value": self.value}
|
|
106
|
+
if self.description:
|
|
107
|
+
data["description"] = self.description
|
|
108
|
+
if self.emoji:
|
|
109
|
+
data["emoji"] = self.emoji
|
|
110
|
+
if self.default:
|
|
111
|
+
data["default"] = True
|
|
112
|
+
return data
|
|
113
|
+
|
|
114
|
+
class SelectMenu(Component):
|
|
115
|
+
def __init__(
|
|
116
|
+
self,
|
|
117
|
+
custom_id: str,
|
|
118
|
+
options: List[SelectOption],
|
|
119
|
+
placeholder: Optional[str] = None,
|
|
120
|
+
min_values: int = 1,
|
|
121
|
+
max_values: int = 1,
|
|
122
|
+
disabled: bool = False,
|
|
123
|
+
):
|
|
124
|
+
data = {
|
|
125
|
+
"type": ComponentType.SELECT_MENU,
|
|
126
|
+
"custom_id": custom_id,
|
|
127
|
+
"options": [opt.to_dict() for opt in options],
|
|
128
|
+
"min_values": min_values,
|
|
129
|
+
"max_values": max_values,
|
|
130
|
+
"disabled": disabled,
|
|
131
|
+
}
|
|
132
|
+
if placeholder:
|
|
133
|
+
data["placeholder"] = placeholder
|
|
134
|
+
super().__init__(data)
|
|
135
|
+
self.custom_id = custom_id
|
|
136
|
+
self.options = options
|
|
137
|
+
self.placeholder = placeholder
|
|
138
|
+
self.min_values = min_values
|
|
139
|
+
self.max_values = max_values
|
|
140
|
+
self.disabled = disabled
|
|
141
|
+
|
|
142
|
+
class ChannelSelect(Component):
|
|
143
|
+
def __init__(
|
|
144
|
+
self,
|
|
145
|
+
custom_id: str,
|
|
146
|
+
placeholder: Optional[str] = None,
|
|
147
|
+
min_values: int = 1,
|
|
148
|
+
max_values: int = 1,
|
|
149
|
+
disabled: bool = False,
|
|
150
|
+
channel_types: Optional[List[int]] = None,
|
|
151
|
+
):
|
|
152
|
+
data = {
|
|
153
|
+
"type": ComponentType.CHANNEL_SELECT,
|
|
154
|
+
"custom_id": custom_id,
|
|
155
|
+
"min_values": min_values,
|
|
156
|
+
"max_values": max_values,
|
|
157
|
+
"disabled": disabled,
|
|
158
|
+
}
|
|
159
|
+
if placeholder:
|
|
160
|
+
data["placeholder"] = placeholder
|
|
161
|
+
if channel_types:
|
|
162
|
+
data["channel_types"] = channel_types
|
|
163
|
+
super().__init__(data)
|
|
164
|
+
|
|
165
|
+
class RoleSelect(Component):
|
|
166
|
+
def __init__(
|
|
167
|
+
self,
|
|
168
|
+
custom_id: str,
|
|
169
|
+
placeholder: Optional[str] = None,
|
|
170
|
+
min_values: int = 1,
|
|
171
|
+
max_values: int = 1,
|
|
172
|
+
disabled: bool = False,
|
|
173
|
+
):
|
|
174
|
+
data = {
|
|
175
|
+
"type": ComponentType.ROLE_SELECT,
|
|
176
|
+
"custom_id": custom_id,
|
|
177
|
+
"min_values": min_values,
|
|
178
|
+
"max_values": max_values,
|
|
179
|
+
"disabled": disabled,
|
|
180
|
+
}
|
|
181
|
+
if placeholder:
|
|
182
|
+
data["placeholder"] = placeholder
|
|
183
|
+
super().__init__(data)
|
|
184
|
+
|
|
185
|
+
class MentionableSelect(Component):
|
|
186
|
+
def __init__(
|
|
187
|
+
self,
|
|
188
|
+
custom_id: str,
|
|
189
|
+
placeholder: Optional[str] = None,
|
|
190
|
+
min_values: int = 1,
|
|
191
|
+
max_values: int = 1,
|
|
192
|
+
disabled: bool = False,
|
|
193
|
+
):
|
|
194
|
+
data = {
|
|
195
|
+
"type": ComponentType.MENTIONABLE_SELECT,
|
|
196
|
+
"custom_id": custom_id,
|
|
197
|
+
"min_values": min_values,
|
|
198
|
+
"max_values": max_values,
|
|
199
|
+
"disabled": disabled,
|
|
200
|
+
}
|
|
201
|
+
if placeholder:
|
|
202
|
+
data["placeholder"] = placeholder
|
|
203
|
+
super().__init__(data)
|
|
204
|
+
|
|
205
|
+
class UserSelect(Component):
|
|
206
|
+
def __init__(
|
|
207
|
+
self,
|
|
208
|
+
custom_id: str,
|
|
209
|
+
placeholder: Optional[str] = None,
|
|
210
|
+
min_values: int = 1,
|
|
211
|
+
max_values: int = 1,
|
|
212
|
+
disabled: bool = False,
|
|
213
|
+
):
|
|
214
|
+
data = {
|
|
215
|
+
"type": ComponentType.USER_SELECT,
|
|
216
|
+
"custom_id": custom_id,
|
|
217
|
+
"min_values": min_values,
|
|
218
|
+
"max_values": max_values,
|
|
219
|
+
"disabled": disabled,
|
|
220
|
+
}
|
|
221
|
+
if placeholder:
|
|
222
|
+
data["placeholder"] = placeholder
|
|
223
|
+
super().__init__(data)
|
|
224
|
+
|
|
225
|
+
class TextInput(Component):
|
|
226
|
+
def __init__(
|
|
227
|
+
self,
|
|
228
|
+
custom_id: str,
|
|
229
|
+
label: str,
|
|
230
|
+
style: Union[TextInputStyle, int] = TextInputStyle.SHORT,
|
|
231
|
+
placeholder: Optional[str] = None,
|
|
232
|
+
value: Optional[str] = None,
|
|
233
|
+
min_length: Optional[int] = None,
|
|
234
|
+
max_length: Optional[int] = None,
|
|
235
|
+
required: bool = True,
|
|
236
|
+
):
|
|
237
|
+
data = {
|
|
238
|
+
"type": ComponentType.TEXT_INPUT,
|
|
239
|
+
"custom_id": custom_id,
|
|
240
|
+
"label": label,
|
|
241
|
+
"style": int(style),
|
|
242
|
+
"required": required,
|
|
243
|
+
}
|
|
244
|
+
if placeholder:
|
|
245
|
+
data["placeholder"] = placeholder
|
|
246
|
+
if value:
|
|
247
|
+
data["value"] = value
|
|
248
|
+
if min_length:
|
|
249
|
+
data["min_length"] = min_length
|
|
250
|
+
if max_length:
|
|
251
|
+
data["max_length"] = max_length
|
|
252
|
+
super().__init__(data)
|
|
253
|
+
|
|
254
|
+
class ActionRow:
|
|
255
|
+
def __init__(self, *components: Component):
|
|
256
|
+
self.components = list(components)
|
|
257
|
+
|
|
258
|
+
def add_component(self, component: Component):
|
|
259
|
+
self.components.append(component)
|
|
260
|
+
|
|
261
|
+
def to_dict(self) -> dict:
|
|
262
|
+
return {
|
|
263
|
+
"type": ComponentType.ACTION_ROW,
|
|
264
|
+
"components": [c.to_dict() for c in self.components],
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
class Modal:
|
|
268
|
+
def __init__(
|
|
269
|
+
self,
|
|
270
|
+
custom_id: str,
|
|
271
|
+
title: str,
|
|
272
|
+
components: Optional[List[Component]] = None,
|
|
273
|
+
):
|
|
274
|
+
self.custom_id = custom_id
|
|
275
|
+
self.title = title
|
|
276
|
+
self.components = components or []
|
|
277
|
+
|
|
278
|
+
def add_component(self, component: Component):
|
|
279
|
+
self.components.append(component)
|
|
280
|
+
|
|
281
|
+
def to_dict(self) -> dict:
|
|
282
|
+
return {
|
|
283
|
+
"custom_id": self.custom_id,
|
|
284
|
+
"title": self.title,
|
|
285
|
+
"components": [ActionRow(c).to_dict() for c in self.components],
|
|
286
|
+
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "modifyself"
|
|
7
|
-
version = "0.2.
|
|
8
|
-
description = "A clean, pythonic Discord self-bot library"
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
license = "MIT"
|
|
11
|
-
authors = [
|
|
12
|
-
{name = "modifyself", email = "modifyself@example.com"}
|
|
13
|
-
]
|
|
14
|
-
requires-python = ">=3.9"
|
|
15
|
-
dependencies = [
|
|
16
|
-
"websockets>=10.0",
|
|
17
|
-
"wreq>=0.1.0",
|
|
18
|
-
"aiohttp>=3.8.0",
|
|
19
|
-
"plyer>=0.9",
|
|
20
|
-
"pillow>=10.0",
|
|
21
|
-
"requests>=2.28",
|
|
22
|
-
"PyNaCl>=1.5.0",
|
|
23
|
-
"opuslib>=3.0.0",
|
|
24
|
-
]
|
|
25
|
-
|
|
26
|
-
[project.urls]
|
|
27
|
-
Homepage = "https://github.com/clashings/modifyself"
|
|
28
|
-
Bug-Reports = "https://github.com/clashings/modifyself/issues"
|
|
29
|
-
Source = "https://github.com/clashings/modifyself"
|
|
30
|
-
|
|
31
|
-
[tool.setuptools.packages.find]
|
|
32
|
-
where = ["."]
|
|
33
|
-
include = ["modifyself*"]
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "modifyself"
|
|
7
|
+
version = "0.2.3"
|
|
8
|
+
description = "A clean, pythonic Discord self-bot library"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "modifyself", email = "modifyself@example.com"}
|
|
13
|
+
]
|
|
14
|
+
requires-python = ">=3.9"
|
|
15
|
+
dependencies = [
|
|
16
|
+
"websockets>=10.0",
|
|
17
|
+
"wreq>=0.1.0",
|
|
18
|
+
"aiohttp>=3.8.0",
|
|
19
|
+
"plyer>=0.9",
|
|
20
|
+
"pillow>=10.0",
|
|
21
|
+
"requests>=2.28",
|
|
22
|
+
"PyNaCl>=1.5.0",
|
|
23
|
+
"opuslib>=3.0.0",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://github.com/clashings/modifyself"
|
|
28
|
+
Bug-Reports = "https://github.com/clashings/modifyself/issues"
|
|
29
|
+
Source = "https://github.com/clashings/modifyself"
|
|
30
|
+
|
|
31
|
+
[tool.setuptools.packages.find]
|
|
32
|
+
where = ["."]
|
|
33
|
+
include = ["modifyself*"]
|
|
34
34
|
exclude = ["tests*", "examples*", "docs*"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|