scurrypy 0.4.2__py3-none-any.whl → 0.5.3__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.

Files changed (65) hide show
  1. scurrypy/__init__.py +376 -0
  2. {discord → scurrypy}/client_like.py +1 -1
  3. {discord → scurrypy}/dispatch/command_dispatcher.py +13 -5
  4. {discord → scurrypy}/dispatch/event_dispatcher.py +15 -15
  5. {discord → scurrypy}/events/channel_events.py +1 -1
  6. {discord → scurrypy}/events/interaction_events.py +21 -9
  7. {discord → scurrypy}/events/message_events.py +4 -4
  8. {discord → scurrypy}/http.py +1 -1
  9. {discord → scurrypy}/intents.py +1 -1
  10. scurrypy/model.py +71 -0
  11. {discord → scurrypy}/models/emoji.py +17 -1
  12. {discord → scurrypy}/models/interaction.py +5 -0
  13. scurrypy/parts/channel.py +42 -0
  14. scurrypy/parts/command.py +90 -0
  15. scurrypy/parts/components.py +224 -0
  16. scurrypy/parts/components_v2.py +144 -0
  17. scurrypy/parts/embed.py +83 -0
  18. scurrypy/parts/message.py +137 -0
  19. scurrypy/parts/modal.py +16 -0
  20. {discord → scurrypy}/parts/role.py +1 -13
  21. {discord → scurrypy}/resources/channel.py +6 -6
  22. {discord → scurrypy}/resources/guild.py +3 -4
  23. {discord → scurrypy}/resources/interaction.py +23 -22
  24. {discord → scurrypy}/resources/message.py +13 -13
  25. {scurrypy-0.4.2.dist-info → scurrypy-0.5.3.dist-info}/METADATA +19 -25
  26. scurrypy-0.5.3.dist-info/RECORD +54 -0
  27. scurrypy-0.5.3.dist-info/top_level.txt +1 -0
  28. discord/__init__.py +0 -223
  29. discord/model.py +0 -90
  30. discord/parts/action_row.py +0 -208
  31. discord/parts/channel.py +0 -20
  32. discord/parts/command.py +0 -102
  33. discord/parts/components_v2.py +0 -353
  34. discord/parts/embed.py +0 -154
  35. discord/parts/message.py +0 -194
  36. discord/parts/modal.py +0 -21
  37. scurrypy-0.4.2.dist-info/RECORD +0 -54
  38. scurrypy-0.4.2.dist-info/top_level.txt +0 -1
  39. {discord → scurrypy}/client.py +0 -0
  40. {discord → scurrypy}/config.py +0 -0
  41. {discord → scurrypy}/dispatch/__init__.py +0 -0
  42. {discord → scurrypy}/dispatch/prefix_dispatcher.py +0 -0
  43. {discord → scurrypy}/error.py +0 -0
  44. {discord → scurrypy}/events/__init__.py +0 -0
  45. {discord → scurrypy}/events/guild_events.py +0 -0
  46. {discord → scurrypy}/events/hello_event.py +0 -0
  47. {discord → scurrypy}/events/reaction_events.py +0 -0
  48. {discord → scurrypy}/events/ready_event.py +0 -0
  49. {discord → scurrypy}/gateway.py +0 -0
  50. {discord → scurrypy}/logger.py +0 -0
  51. {discord → scurrypy}/models/__init__.py +0 -0
  52. {discord → scurrypy}/models/application.py +0 -0
  53. {discord → scurrypy}/models/guild.py +0 -0
  54. {discord → scurrypy}/models/integration.py +0 -0
  55. {discord → scurrypy}/models/member.py +0 -0
  56. {discord → scurrypy}/models/role.py +0 -0
  57. {discord → scurrypy}/models/user.py +0 -0
  58. {discord → scurrypy}/parts/__init__.py +0 -0
  59. {discord → scurrypy}/parts/component_types.py +0 -0
  60. {discord → scurrypy}/resources/__init__.py +0 -0
  61. {discord → scurrypy}/resources/application.py +0 -0
  62. {discord → scurrypy}/resources/bot_emojis.py +0 -0
  63. {discord → scurrypy}/resources/user.py +0 -0
  64. {scurrypy-0.4.2.dist-info → scurrypy-0.5.3.dist-info}/WHEEL +0 -0
  65. {scurrypy-0.4.2.dist-info → scurrypy-0.5.3.dist-info}/licenses/LICENSE +0 -0
discord/parts/command.py DELETED
@@ -1,102 +0,0 @@
1
- from dataclasses import dataclass, field
2
- from typing import Literal
3
-
4
- from ..model import DataModel
5
-
6
- class CommandOptionTypes:
7
- """Slash command option input types."""
8
-
9
- STRING = 3
10
- """string (text)"""
11
-
12
- INTEGER = 4
13
- """integer (whole)"""
14
-
15
- BOOLEAN = 5
16
- """boolean (true/false)"""
17
-
18
- USER = 6
19
- """user pangination"""
20
-
21
- CHANNEL = 7
22
- """channel pangination"""
23
-
24
- ROLE = 8
25
- """role pangination"""
26
-
27
- MENTIONABLE = 9
28
- """any pangination (role, channel, user)"""
29
-
30
- NUMBER = 10
31
- """number (float, integer)"""
32
-
33
- ATTACHMENT = 11
34
- """file upload"""
35
-
36
- @dataclass
37
- class MessageCommand(DataModel):
38
- """Represents the message command object."""
39
- type: Literal[3] = field(init=False, default=3) # MESSAGE
40
- name: str
41
-
42
- @dataclass
43
- class UserCommand(DataModel):
44
- """Represents the user command object"""
45
- type: Literal[2] = field(init=False, default=2) # USER
46
- name: str
47
-
48
- @dataclass
49
- class _CommandOption(DataModel):
50
- """Option for a slash command."""
51
- type: int # refer to CommandOptionTypes
52
- name: str
53
- description: str
54
- required: bool = True
55
-
56
- @dataclass
57
- class SlashCommand(DataModel):
58
- type: Literal[1] = field(init=False, default=1) # CHAT_INPUT
59
- name: str
60
- description: str
61
- options: list[_CommandOption] = field(default_factory=list)
62
-
63
- def add_option(
64
- self,
65
- command_type: Literal['String', 'Integer', 'Boolean', 'User', 'Channel', 'Role', 'Mentionable', 'Number', 'Attachment'],
66
- name: str,
67
- description: str,
68
- required: bool = False
69
- ):
70
- """Add an option to this slash command.
71
-
72
- Args:
73
- command_type (Literal['String', 'Integer', 'Boolean', 'User', 'Channel', 'Role', 'Mentionable', 'Number', 'Attachment']):
74
- input type for the option
75
- name (str): name of the option
76
- description (str): description for the option
77
- required (bool, optional): if the option is required. Defaults to False.
78
-
79
- Returns:
80
- (SlashCommand): self
81
- """
82
- _command_types = {
83
- 'STRING': CommandOptionTypes.STRING,
84
- 'INTEGER': CommandOptionTypes.INTEGER,
85
- 'BOOLEAN': CommandOptionTypes.BOOLEAN,
86
- 'USER': CommandOptionTypes.BOOLEAN,
87
- 'CHANNEL': CommandOptionTypes.CHANNEL,
88
- 'ROLE': CommandOptionTypes.ROLE,
89
- 'MENTIONABLE': CommandOptionTypes.MENTIONABLE,
90
- 'NUMBER': CommandOptionTypes.NUMBER,
91
- 'ATTACHMENT': CommandOptionTypes.ATTACHMENT
92
- }
93
-
94
- self.options.append(
95
- _CommandOption(
96
- type=_command_types.get(command_type.upper()),
97
- name=name,
98
- description=description,
99
- required=required
100
- )
101
- )
102
- return self
@@ -1,353 +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
- from ..models.emoji import EmojiModel
7
-
8
- from .action_row import (
9
- StringSelect,
10
- ActionRow,
11
- ChannelSelect,
12
- MentionableSelect,
13
- RoleSelect,
14
- UserSelect,
15
- _Button,
16
- _ButtonStyles
17
- )
18
-
19
- class _TextInputStyles:
20
- """Represents the types of Text Inputs."""
21
- SHORT = 1 # one line
22
- PARAGRAPH = 2 # multiple lines
23
-
24
- @dataclass
25
- class _TextInput(DataModel, LabelChild):
26
- """Represents the Text Input component."""
27
- type: Literal[4] = field(init=False, default=4)
28
- style: _TextInputStyles = _TextInputStyles.SHORT # refer to _TextInputStyles for details
29
- custom_id: str = None
30
- required: Optional[bool] = False
31
- min_length: Optional[int] = None
32
- max_length: Optional[int] = None
33
- value: Optional[str] = None
34
- placeholder: Optional[str] = None
35
-
36
- @dataclass
37
- class Section(DataModel, ContainerChild):
38
- """Represents the Section component."""
39
- type: Literal[9] = field(init=False, default=9)
40
-
41
- accessory: Optional[SectionAccessory] = None
42
- """A component that is contextually associated to the content of the section."""
43
-
44
- components: list[SectionChild] = field(default_factory=list)
45
- """Component(s) representing the content of the section that is contextually associated to the accessory"""
46
-
47
- def set_thumbnail(self, media: str, description: str = None, has_spoiler: bool = False):
48
- """Set the thumbnail for this section.
49
-
50
- Args:
51
- media (str): Image data. http or attachment://<filename> scheme.
52
- description (str, optional): Alt text for the media
53
- has_spoiler (bool, optional): If the media should be blurred out. Defaults to False.
54
-
55
- Returns:
56
- (Section): self
57
- """
58
- self.accessory = _Thumbnail(media, description, has_spoiler)
59
- return self
60
-
61
- def add_text_display(self, content: str):
62
- """Add a text display to this section.
63
-
64
- Args:
65
- content (str): the content to display
66
-
67
- Returns:
68
- (Section): self
69
- """
70
- self.components.append(_TextDisplay(content))
71
- return self
72
-
73
- def set_button(self,
74
- *,
75
- style: Literal['Primary', 'Secondary', 'Success', 'Danger', 'Link'],
76
- label: str,
77
- custom_id: str,
78
- emoji: str | EmojiModel = None,
79
- disable: bool = False
80
- ):
81
- """Set this section's accessory as a button.
82
-
83
- Args:
84
- style (Literal['Primary', 'Secondary', 'Success', 'Danger', 'Link']):
85
- button style as a string
86
- label (str): button text
87
- custom_id (str): developer-defined button ID
88
- emoji (str | EmojiModel, Optional): str if unicode emoji, EmojiModal if custom
89
- disable (bool, Optional): if this button should be pressable. Defaults to False.
90
-
91
- Returns:
92
- (Section): self
93
- """
94
- _styles = {
95
- 'PRIMARY': _ButtonStyles.PRIMARY,
96
- 'SECONDARY': _ButtonStyles.SECONDARY,
97
- 'SUCCESS': _ButtonStyles.SUCCESS,
98
- 'DANGER': _ButtonStyles.DANGER,
99
- 'LINK': _ButtonStyles.LINK
100
- }
101
-
102
- if isinstance(emoji, str):
103
- emoji = EmojiModel(name=emoji)
104
-
105
- self.accessory = _Button(
106
- style=_styles.get(style.upper()),
107
- label=label,
108
- custom_id=custom_id,
109
- emoji=emoji,
110
- disabled=disable
111
- )
112
- return self
113
-
114
- @dataclass
115
- class _TextDisplay(DataModel, ContainerChild, SectionChild):
116
- """Represents the Text Display component."""
117
- type: Literal[10] = field(init=False, default=10)
118
- content: str
119
-
120
-
121
- @dataclass
122
- class _Thumbnail(DataModel, SectionAccessory):
123
- """Represents the _Thumbnail component."""
124
- type: Literal[11] = field(init=False, default=11)
125
- media: str # http or attachment://<filename>
126
- description: Optional[str] = None
127
- spoiler: Optional[bool] = False
128
-
129
-
130
- @dataclass
131
- class MediaGalleryItem(DataModel):
132
- """Represents the Media Gallery Item component."""
133
-
134
- media: str
135
- """Image data. http or attachment://<filename> scheme."""
136
-
137
- description: Optional[str] = None
138
- """Alt text for the media."""
139
-
140
- spoiler: Optional[bool] = False
141
- """If the media should be blurred out."""
142
-
143
- @dataclass
144
- class _MediaGallery(DataModel, ContainerChild):
145
- """Represents the Media Gallery component."""
146
- type: Literal[12] = field(init=False, default=12)
147
- items: list[MediaGalleryItem] = field(default_factory=list)
148
-
149
-
150
- @dataclass
151
- class _File(DataModel, ContainerChild):
152
- """Represents the File component."""
153
- type: Literal[13] = field(init=False, default=13)
154
- file: str # http or attachment://<filename>
155
- spoiler: Optional[bool] = False
156
-
157
- class _SeparatorTypes:
158
- """Represents separator types constants."""
159
- SMALL_PADDING = 1
160
- LARGE_PADDING = 2
161
-
162
- @dataclass
163
- class _Separator(DataModel, ContainerChild):
164
- """Represents the Separator component."""
165
- type: Literal[14] = field(init=False, default=14)
166
- divider: bool = True
167
- spacing: Optional[int] = _SeparatorTypes.SMALL_PADDING # refer to _SeparatorTypes
168
-
169
- @dataclass
170
- class Label(DataModel):
171
- """Represents the Discord Label component."""
172
-
173
- label: str
174
- """Label text."""
175
-
176
- component: LabelChild = None
177
- """A component within the label."""
178
-
179
- description: Optional[str] = None
180
- """An optional description text for the label."""
181
-
182
- type: Literal[18] = field(init=False, default=18)
183
-
184
- def set_select_menu(self, select: StringSelect | UserSelect | RoleSelect | ChannelSelect | MentionableSelect):
185
- """Set this label to be a select menu component.
186
-
187
- Args:
188
- select (StringSelect | UserSelect | RoleSelect | ChannelSelect | MentionableSelect): the select menu component
189
-
190
- Returns:
191
- (Label): self
192
- """
193
- self.component = select
194
- return self
195
-
196
- def set_text_input(self,
197
- *,
198
- custom_id: str,
199
- min_length: int,
200
- max_length: int,
201
- value: str = None,
202
- style: Literal['Short', 'Paragraph'] = 'Short',
203
- placeholder: str = None,
204
- require: bool = False
205
- ):
206
- """Set this label to be a text input component.
207
-
208
- Args:
209
- custom_id (str): developer-defined component ID
210
- min_length (int): minimum number of characters required
211
- max_length (int): maximum number of characters required
212
- value (str, optional): component value
213
- style (Literal['Short', 'Paragraph'], optional):
214
- text format. Defaults to 'Short'.
215
- placeholder (str, optional): custom placeholder text if empty
216
- require (bool, optional): if input is required. Defaults to False.
217
-
218
- Returns:
219
- (Label): self
220
- """
221
- _styles = {
222
- 'SHORT': _TextInputStyles.SHORT,
223
- 'PARAGRAPH': _TextInputStyles.PARAGRAPH
224
- }
225
-
226
- self.component = _TextInput(
227
- style = _styles.get(style.upper()),
228
- placeholder=placeholder,
229
- custom_id=custom_id,
230
- min_length=min_length,
231
- max_length=max_length,
232
- value=value,
233
- required=require
234
- )
235
- return self
236
-
237
- @dataclass
238
- class Container(DataModel):
239
- """Represents a container of display and interactable components."""
240
- type: Literal[17] = field(init=False, default=17)
241
-
242
- components: list[ContainerChild] = field(default_factory=list)
243
- """Child components that are encapsulated within the Container."""
244
-
245
- accent_color: Optional[int] = None
246
- """Color for the accent as an integer."""
247
-
248
- spoiler: Optional[bool] = False
249
- """If the container should be blurred out."""
250
-
251
- def set_color(self, hex: str):
252
- """Set this container's color with a hex. (format: #FFFFFF)
253
-
254
- Args:
255
- hex (str): color as a hex code
256
-
257
- Returns:
258
- (Container): self
259
- """
260
- self.accent_color = int(hex.strip('#'), 16)
261
- return self
262
-
263
- def add_row(self, row: ActionRow):
264
- """Add an action row to this container.
265
-
266
- Args:
267
- row (ActionRow): the ActionRow object
268
-
269
- Returns:
270
- (Container): self
271
- """
272
- self.components.append(row)
273
- return self
274
-
275
- def add_section(self, section: Section):
276
- """Add a section to this container.
277
-
278
- Args:
279
- section (Section): the Section object
280
-
281
- Returns:
282
- (Container): self
283
- """
284
- self.components.append(section)
285
- return self
286
-
287
- def add_text_display(self, content: str):
288
- """Add a text display to this container.
289
-
290
- Args:
291
- content (str): the content to display
292
-
293
- Returns:
294
- (Container): self
295
- """
296
- self.components.append(_TextDisplay(content))
297
- return self
298
-
299
- def set_thumbnail(self, media: str, description: str = None, has_spoiler: bool = False):
300
- """Set the thumbnail for this container
301
-
302
- Args:
303
- media (str): Image data. http or attachment://<filename> scheme.
304
- description (str, optional): Alt text for the media
305
- has_spoiler (bool, optional): If the media should be blurred out. Defaults to False.
306
-
307
- Returns:
308
- (Container): self
309
- """
310
- self.components.append(_Thumbnail(media, description, has_spoiler))
311
- return self
312
-
313
- def set_media_gallery(self, items: list[MediaGalleryItem]):
314
- """Add a media gallery to this container.
315
-
316
- Args:
317
- items (list[MediaGalleryItem]): list of media gallery images
318
-
319
- Returns:
320
- (Container): self
321
- """
322
- self.components.append(_MediaGallery(items))
323
- return self
324
-
325
- def add_attachment(self, file: str, has_spoiler: bool = False):
326
- """Add a single attachment to this container.
327
-
328
- Args:
329
- file (str): Image data. http or attachment://<filename> scheme
330
- has_spoiler (bool, optional): If the media should be blurred out. Defaults to False.
331
-
332
- Returns:
333
- (Container): self
334
- """
335
- self.components.append(_File(file, has_spoiler))
336
- return self
337
-
338
- def add_separator(self, spacing: Literal['Small', 'Large'] = 'Small', has_divider: bool = True):
339
- """Add a separator to this container. Positionally accurate.
340
-
341
- Args:
342
- spacing (Literal['Small', 'Large'], optional): size of separator padding. Defaults to 'Small'.
343
- has_divider (bool, optional): if a visual divider should be shown. Defaults to True.
344
-
345
- Returns:
346
- (Container): self
347
- """
348
- _spacing_types = {
349
- 'SMALL': _SeparatorTypes.SMALL_PADDING,
350
- 'LARGE': _SeparatorTypes.LARGE_PADDING
351
- }
352
- self.components.append(_Separator(divider=has_divider, spacing=_spacing_types.get(spacing.upper())))
353
- return self
discord/parts/embed.py DELETED
@@ -1,154 +0,0 @@
1
- from dataclasses import dataclass
2
- from typing import Optional
3
- from discord.model import DataModel
4
- from datetime import datetime, timezone
5
- from ..models.user import UserModel
6
-
7
- @dataclass
8
- class _EmbedAuthor(DataModel):
9
- """Embed author parameters."""
10
- name: str
11
- url: Optional[str] = None
12
- icon_url: Optional[str] = None
13
-
14
- @dataclass
15
- class _EmbedThumbnail(DataModel):
16
- """Embed thumbnail."""
17
- url: str
18
-
19
- @dataclass
20
- class _EmbedImage(DataModel):
21
- """Embed image."""
22
- url: str
23
-
24
- @dataclass
25
- class _EmbedFooter(DataModel):
26
- """Embed footer."""
27
- text: str
28
- url: Optional[str] = None
29
- icon_url: Optional[str] = None
30
-
31
- @dataclass
32
- class _EmbedField(DataModel):
33
- """Embed field."""
34
- name: str
35
- value: str
36
- inline: Optional[bool] = None
37
-
38
- @dataclass
39
- class EmbedBuilder(DataModel):
40
- """Represents the Embed portion of a message."""
41
-
42
- title: Optional[str] = None
43
- """This embed's title."""
44
-
45
- description: Optional[str] = None
46
- """This embed's description."""
47
-
48
- timestamp: Optional[str] = None
49
- """Timestamp of when the embed was sent."""
50
-
51
- color: Optional[int] = None
52
- """Embed's accent color."""
53
-
54
- author: Optional[_EmbedAuthor] = None
55
- """Embed's author."""
56
-
57
- thumbnail: Optional[_EmbedThumbnail] = None
58
- """Embed's thumbnail attachment."""
59
-
60
- image: Optional[_EmbedImage] = None
61
- """Embed's image attachment."""
62
-
63
- fields: Optional[list[_EmbedField]] = None
64
- """List of embed's fields."""
65
-
66
- footer: Optional[_EmbedFooter] = None
67
- """Embed's footer."""
68
-
69
- def set_color(self, hex: str):
70
- """Set this embed's color with a hex.
71
-
72
- Args:
73
- hex (str): color as a hex code (format: #FFFFFF)
74
-
75
- Returns:
76
- (EmbedBuilder): self
77
- """
78
- self.color=int(hex.strip('#'), 16)
79
- return self
80
-
81
- def set_user_author(self, user: UserModel):
82
- """Set this embed's author.
83
-
84
- Args:
85
- user (UserModel): the user model
86
-
87
- Returns:
88
- (EmbedBuilder): self
89
- """
90
- self.author = _EmbedAuthor(
91
- name=user.username,
92
- icon_url=f"https://cdn.discordapp.com/avatars/{user.id}/{user.avatar}.png"
93
- )
94
- return self
95
-
96
- def set_image(self, url: str):
97
- """Set this embed's image.
98
-
99
- Args:
100
- url (str): attachment://<file> scheme or http(s) URL
101
-
102
- Returns:
103
- (EmbedBuilder): self
104
- """
105
- self.image = _EmbedImage(url=url)
106
- return self
107
-
108
- def set_thumbnail(self, url: str):
109
- """Set this embed's thumbnail.
110
-
111
- Args:
112
- url (str): attachment://<file> scheme or http(s) URL
113
-
114
- Returns:
115
- (EmbedBuilder): self
116
- """
117
- self.thumbnail = _EmbedThumbnail(url=url)
118
- return self
119
-
120
- def set_footer(self, text: str, icon_url: str = None):
121
- """Set this embed's footer.
122
-
123
- Args:
124
- text (str): footer's text
125
- icon_url (str, optional): attachment://<file> scheme or http(s) URL.
126
-
127
- Returns:
128
- (EmbedBuilder): self
129
- """
130
- self.footer = _EmbedFooter(text=text, icon_url=icon_url)
131
- return self
132
-
133
- def add_field(self, name: str, value: str, is_inline: bool = False):
134
- """Add a field to this embed.
135
-
136
- Args:
137
- name (str): field's title
138
- value (str): field's text
139
- is_inline (bool): if this field should be inlined
140
-
141
- Returns:
142
- (EmbedBuilder): self
143
- """
144
- self.fields.append(_EmbedField(name=name, value=value, inline=is_inline))
145
- return self
146
-
147
- def set_timestamp(self):
148
- """Set this embed's timestamp.
149
-
150
- Returns:
151
- (EmbedBuilder): self
152
- """
153
- self.timestamp = datetime.now(timezone.utc).isoformat()
154
- return self