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 CHANGED
@@ -4,32 +4,36 @@ import importlib
4
4
  from typing import TYPE_CHECKING
5
5
 
6
6
  __all__ = [
7
- # top-level
8
7
  "Logger",
9
8
  "Client",
10
9
  "Intents",
11
10
  "set_intents",
12
11
  "BaseConfig",
13
12
 
14
- # events
13
+ "InteractionTypes",
14
+
15
15
  "ReadyEvent",
16
+
16
17
  "ReactionAddEvent",
17
18
  "ReactionRemoveEvent",
18
19
  "ReactionRemoveEmojiEvent",
19
20
  "ReactionRemoveAllEvent",
21
+
20
22
  "GuildCreateEvent",
21
23
  "GuildUpdateEvent",
22
24
  "GuildDeleteEvent",
25
+
23
26
  "MessageCreateEvent",
24
27
  "MessageUpdateEvent",
25
28
  "MessageDeleteEvent",
29
+
26
30
  "GuildChannelCreateEvent",
27
31
  "GuildChannelUpdateEvent",
28
32
  "GuildChannelDeleteEvent",
29
33
  "ChannelPinsUpdateEvent",
34
+
30
35
  "InteractionEvent",
31
36
 
32
- # models
33
37
  "ApplicationModel",
34
38
  "EmojiModel",
35
39
  "GuildModel",
@@ -37,34 +41,73 @@ __all__ = [
37
41
  "UserModel",
38
42
  "RoleModel",
39
43
 
40
- # parts
44
+ "ChannelTypes",
41
45
  "GuildChannel",
42
- "Role",
43
- "MessageBuilder",
44
- "ModalBuilder",
45
- "EmbedBuilder",
46
- "ActionRow",
47
- "StringSelect",
48
- "UserSelect",
49
- "RoleSelect",
50
- "ChannelSelect",
51
- "MentionableSelect",
46
+
47
+ "CommandTypes",
48
+ "CommandOptionTypes",
52
49
  "SlashCommand",
53
- "MessageCommand",
54
50
  "UserCommand",
55
- "Container",
56
- "Section",
51
+ "MessageCommand",
52
+
53
+ "ComponentV2Types",
54
+ "SectionPart",
55
+ "TextDisplay",
56
+ "Thumbnail",
57
57
  "MediaGalleryItem",
58
+ "MediaGallery",
59
+ "File",
60
+ "SeparatorTypes",
61
+ "Separator",
62
+ "ContainerPart",
58
63
  "Label",
59
64
 
60
- # resources
61
- "Guild",
65
+ "ComponentTypes",
66
+ "ActionRowPart",
67
+ "ButtonStyles",
68
+ "Button",
69
+ "SelectOption",
70
+ "StringSelect",
71
+ "TextInputStyles",
72
+ "TextInput",
73
+ "DefaultValue",
74
+ "UserSelect",
75
+ "RoleSelect",
76
+ "MentionableSelect",
77
+ "ChannelSelect",
78
+
79
+ "EmbedAuthor",
80
+ "EmbedThumbnail",
81
+ "EmbedField",
82
+ "EmbedImage",
83
+ "EmbedFooter",
84
+ "EmbedPart",
85
+
86
+ "MessageFlags",
87
+ "MessageReferenceTypes",
88
+ "MessageReference",
89
+ "Attachment",
90
+ "MessagePart",
91
+
92
+ "ModalPart",
93
+ "Role",
94
+
95
+ "ApplicationFlags",
96
+ "Application",
97
+
98
+ "BotEmojis",
99
+
100
+ "PinnedMessage",
62
101
  "Channel",
102
+
103
+ "Guild",
104
+
105
+ "InteractionCallbackTypes",
106
+ "Interaction",
107
+
63
108
  "Message",
64
- "BotEmojis",
109
+
65
110
  "User",
66
- "Interaction",
67
- "Application",
68
111
  ]
69
112
 
70
113
  # For editor support / autocomplete
@@ -74,6 +117,8 @@ if TYPE_CHECKING:
74
117
  from .intents import Intents, set_intents
75
118
  from .config import BaseConfig
76
119
 
120
+ from .dispatch.command_dispatcher import InteractionTypes
121
+
77
122
  # events
78
123
  from .events.ready_event import ReadyEvent
79
124
  from .events.reaction_events import (
@@ -109,41 +154,105 @@ if TYPE_CHECKING:
109
154
  from .models.role import RoleModel
110
155
 
111
156
  # parts
112
- from .parts.channel import GuildChannel
113
- from .parts.role import Role
114
- from .parts.message import MessageBuilder
115
- from .parts.modal import ModalBuilder
116
- from .parts.embed import EmbedBuilder
117
- from .parts.action_row import (
118
- ActionRow,
119
- StringSelect,
120
- UserSelect,
121
- RoleSelect,
122
- ChannelSelect,
123
- MentionableSelect
157
+ from .parts.channel import (
158
+ ChannelTypes,
159
+ GuildChannel
124
160
  )
125
161
 
126
162
  from .parts.command import (
163
+ CommandTypes,
164
+ CommandOptionTypes,
127
165
  SlashCommand,
128
- MessageCommand,
129
- UserCommand
166
+ UserCommand,
167
+ MessageCommand
130
168
  )
131
169
 
132
170
  from .parts.components_v2 import (
133
- Container,
134
- Section,
171
+ ComponentV2Types,
172
+ SectionPart,
173
+ TextDisplay,
174
+ Thumbnail,
135
175
  MediaGalleryItem,
176
+ MediaGallery,
177
+ File,
178
+ SeparatorTypes,
179
+ Separator,
180
+ ContainerPart,
136
181
  Label
137
182
  )
138
183
 
184
+ from .parts.components import (
185
+ ComponentTypes,
186
+ ActionRowPart,
187
+ ButtonStyles,
188
+ Button,
189
+ SelectOption,
190
+ StringSelect,
191
+ TextInputStyles,
192
+ TextInput,
193
+ DefaultValue,
194
+ # SelectMenu,
195
+ UserSelect,
196
+ RoleSelect,
197
+ MentionableSelect,
198
+ ChannelSelect
199
+ )
200
+
201
+ from .parts.embed import (
202
+ EmbedAuthor,
203
+ EmbedThumbnail,
204
+ EmbedField,
205
+ EmbedImage,
206
+ EmbedFooter,
207
+ EmbedPart
208
+ )
209
+
210
+ from .parts.message import (
211
+ MessageFlags,
212
+ # MessageFlagParams,
213
+ MessageReferenceTypes,
214
+ MessageReference,
215
+ Attachment,
216
+ MessagePart
217
+ )
218
+
219
+ from .parts.modal import ModalPart
220
+ from .parts.role import Role
221
+
139
222
  # resources
140
- from .resources.guild import Guild
141
- from .resources.channel import Channel
142
- from .resources.message import Message
223
+ from .resources.application import (
224
+ ApplicationFlags,
225
+ Application
226
+ )
227
+
143
228
  from .resources.bot_emojis import BotEmojis
144
- from .resources.user import User
145
- from .resources.interaction import Interaction
146
- from .resources.application import Application
229
+
230
+ from .resources.channel import (
231
+ # MessagesFetchParams,
232
+ # PinsFetchParams,
233
+ # ThreadFromMessageParams,
234
+ PinnedMessage,
235
+ Channel
236
+ )
237
+
238
+ from .resources.guild import (
239
+ # FetchGuildMembersParams,
240
+ # FetchGuildParams,
241
+ Guild
242
+ )
243
+
244
+ from .resources.interaction import (
245
+ # InteractionDataTypes,
246
+ InteractionCallbackTypes,
247
+ Interaction
248
+ )
249
+
250
+ from .resources.message import Message
251
+
252
+ from .resources.user import (
253
+ # FetchUserGuildsParams,
254
+ User
255
+ )
147
256
 
148
257
  # Lazy loader
149
258
  def __getattr__(name: str):
@@ -158,25 +267,30 @@ def __getattr__(name: str):
158
267
  "set_intents": "discord.intents",
159
268
  "BaseConfig": "discord.config",
160
269
 
161
- # events
270
+ 'InteractionTypes': "discord.dispatch.command_dispatcher",
271
+
162
272
  "ReadyEvent": "discord.events.ready_event",
273
+
163
274
  "ReactionAddEvent": "discord.events.reaction_events",
164
275
  "ReactionRemoveEvent": "discord.events.reaction_events",
165
276
  "ReactionRemoveEmojiEvent": "discord.events.reaction_events",
166
277
  "ReactionRemoveAllEvent": "discord.events.reaction_events",
278
+
167
279
  "GuildCreateEvent": "discord.events.guild_events",
168
280
  "GuildUpdateEvent": "discord.events.guild_events",
169
281
  "GuildDeleteEvent": "discord.events.guild_events",
282
+
170
283
  "MessageCreateEvent": "discord.events.message_events",
171
284
  "MessageUpdateEvent": "discord.events.message_events",
172
285
  "MessageDeleteEvent": "discord.events.message_events",
286
+
173
287
  "GuildChannelCreateEvent": "discord.events.channel_events",
174
288
  "GuildChannelUpdateEvent": "discord.events.channel_events",
175
289
  "GuildChannelDeleteEvent": "discord.events.channel_events",
176
290
  "ChannelPinsUpdateEvent": "discord.events.channel_events",
291
+
177
292
  "InteractionEvent": "discord.events.interaction_events",
178
293
 
179
- # models
180
294
  'ApplicationModel': "discord.models.application",
181
295
  'EmojiModel': "discord.models.emoji",
182
296
  'GuildModel': "discord.models.guild",
@@ -184,34 +298,73 @@ def __getattr__(name: str):
184
298
  'UserModel': "discord.models.user",
185
299
  'RoleModel': "discord.models.role",
186
300
 
187
- # parts
301
+ 'ChannelTypes': "discord.parts.channel",
188
302
  'GuildChannel': "discord.parts.channel",
189
- 'Role': "discord.parts.role",
190
- 'MessageBuilder': "discord.parts.message",
191
- 'ModalBuilder': "discord.parts.modal",
192
- 'EmbedBuilder': "discord.parts.embed",
193
- 'ActionRow': "discord.parts.action_row",
194
- 'StringSelect': "discord.parts.action_row",
195
- 'UserSelect': "discord.parts.action_row",
196
- 'RoleSelect': "discord.parts.action_row",
197
- 'ChannelSelect': "discord.parts.action_row",
198
- 'MentionableSelect': "discord.parts.action_row",
303
+
304
+ 'CommandTypes': "discord.parts.command",
305
+ 'CommandOptionTypes': "discord.parts.command",
199
306
  'SlashCommand': "discord.parts.command",
200
- 'MessageCommand': "discord.parts.command",
201
307
  'UserCommand': "discord.parts.command",
202
- 'Container': "discord.parts.components_v2",
203
- 'Section': "discord.parts.components_v2",
308
+ 'MessageCommand': "discord.parts.command",
309
+
310
+ 'ComponentV2Types': "discord.parts.components_v2",
311
+ 'SectionPart': "discord.parts.components_v2",
312
+ 'TextDisplay': "discord.parts.components_v2",
313
+ 'Thumbnail': "discord.parts.components_v2",
204
314
  'MediaGalleryItem': "discord.parts.components_v2",
315
+ 'MediaGallery': "discord.parts.components_v2",
316
+ 'File': "discord.parts.components_v2",
317
+ 'SeparatorTypes': "discord.parts.components_v2",
318
+ 'Separator': "discord.parts.components_v2",
319
+ 'ContainerPart': "discord.parts.components_v2",
205
320
  'Label': "discord.parts.components_v2",
206
321
 
207
- # resources
208
- 'Guild': "discord.resources.guild",
209
- 'Channel': "discord.resources.channel",
210
- 'Message': "discord.resources.message",
322
+ 'ComponentTypes': "discord.parts.components",
323
+ 'ActionRowPart': "discord.parts.components",
324
+ 'ButtonStyles': "discord.parts.components",
325
+ 'Button': "discord.parts.components",
326
+ 'SelectOption': "discord.parts.components",
327
+ 'StringSelect': "discord.parts.components",
328
+ 'TextInputStyles': 'discord.parts.components',
329
+ 'TextInput': "discord.parts.components",
330
+ 'DefaultValue': "discord.parts.components",
331
+ 'UserSelect': "discord.parts.components",
332
+ 'RoleSelect': "discord.parts.components",
333
+ 'MentionableSelect': "discord.parts.components",
334
+ 'ChannelSelect': "discord.parts.components",
335
+
336
+ 'EmbedAuthor': "discord.parts.embed",
337
+ 'EmbedThumbnail': "discord.parts.embed",
338
+ 'EmbedField': "discord.parts.embed",
339
+ 'EmbedImage': "discord.parts.embed",
340
+ 'EmbedFooter': "discord.parts.embed",
341
+ 'EmbedPart': "discord.parts.embed",
342
+
343
+ 'MessageFlags': "discord.parts.message",
344
+ 'MessageReferenceTypes': "discord.parts.message",
345
+ 'MessageReference': "discord.parts.message",
346
+ 'Attachment': "discord.parts.message",
347
+ 'MessagePart': "discord.parts.message",
348
+
349
+ 'ModalPart': "discord.parts.modal",
350
+ 'Role': "discord.parts.role",
351
+
352
+ 'ApplicationFlags': "discord.resources.application",
353
+ 'Application': "discord.resources.application",
354
+
211
355
  'BotEmojis': "discord.resources.bot_emojis",
212
- 'User': "discord.resources.user",
356
+
357
+ 'PinnedMessage': "discord.resources.channel",
358
+ 'Channel': "discord.resources.channel",
359
+
360
+ 'Guild': "discord.resources.guild",
361
+
362
+ 'InteractionCallbackTypes': "discord.resources.interaction",
213
363
  'Interaction': "discord.resources.interaction",
214
- 'Application': "discord.resources.application"
364
+
365
+ 'Message': "discord.resources.message",
366
+
367
+ 'User': "discord.resources.user"
215
368
  }
216
369
 
217
370
  module = importlib.import_module(mapping[name])
@@ -1,3 +1,5 @@
1
+ import fnmatch
2
+
1
3
  from ..client_like import ClientLike
2
4
 
3
5
  from ..events.interaction_events import ApplicationCommandData, MessageComponentData, ModalData, InteractionEvent
@@ -146,11 +148,17 @@ class CommandDispatcher:
146
148
 
147
149
  case InteractionTypes.MESSAGE_COMPONENT:
148
150
  name = event.data.custom_id
149
- handler = self._component_handlers.get(name)
151
+ for k, v in self._component_handlers.items():
152
+ if fnmatch.fnmatch(name, k) == True:
153
+ handler = v
154
+ # handler = self._component_handlers.get(name)
150
155
 
151
156
  case InteractionTypes.MODAL_SUBMIT:
152
157
  name = event.data.custom_id
153
- handler = self._component_handlers.get(name)
158
+ for k, v in self._component_handlers.items():
159
+ if fnmatch.fnmatch(name, k) == True:
160
+ handler = v
161
+ # handler = self._component_handlers.get(name)
154
162
 
155
163
  if not handler:
156
164
  self._logger.log_warn(f"No handler registered for interaction '{name}'")
@@ -46,7 +46,7 @@ class GuildChannelDeleteEvent(GuildChannelEvent):
46
46
  pass
47
47
 
48
48
  @dataclass
49
- class ChannelPinsUpdateEvent:
49
+ class ChannelPinsUpdateEvent(DataModel):
50
50
  """Pin update event."""
51
51
  channel_id: int
52
52
  """ID of channel where the pins were updated."""
@@ -3,12 +3,14 @@ from typing import Optional
3
3
  from ..model import DataModel
4
4
 
5
5
  from ..resources.interaction import Interaction
6
+ from ..parts.components import ComponentTypes
6
7
 
7
8
  # ----- Command Interaction -----
8
9
 
9
10
  @dataclass
10
11
  class ApplicationCommandOptionData(DataModel):
11
12
  """Represents the response options from a slash command."""
13
+
12
14
  name: str
13
15
  """Name of the command option."""
14
16
 
@@ -21,6 +23,7 @@ class ApplicationCommandOptionData(DataModel):
21
23
  @dataclass
22
24
  class ApplicationCommandData(DataModel):
23
25
  """Represents the response from a command."""
26
+
24
27
  id: int
25
28
  """ID of the command."""
26
29
 
@@ -39,7 +42,7 @@ class ApplicationCommandData(DataModel):
39
42
  options: Optional[list[ApplicationCommandOptionData]] = field(default_factory=list)
40
43
  """Options of the command (slash command only)."""
41
44
 
42
- def get_command_option_value(self, option_name: str):
45
+ def get_command_option_value(self, option_name: str, default = None):
43
46
  """Get the input for a command option by name.
44
47
 
45
48
  Args:
@@ -52,12 +55,13 @@ class ApplicationCommandData(DataModel):
52
55
  (str | int | float | bool): input data of specified option
53
56
  """
54
57
  for option in self.options:
55
- if option_name != option.name:
56
- continue
57
-
58
- return option.value
58
+ if option.name == option_name:
59
+ return option.value
59
60
 
60
- raise ValueError(f"Option name '{option_name}' could not be found.")
61
+ if default is not None:
62
+ return default
63
+
64
+ raise ValueError(f"Option '{option_name}' not found")
61
65
 
62
66
  # ----- Component Interaction -----
63
67
 
@@ -79,6 +83,7 @@ class MessageComponentData(DataModel):
79
83
  @dataclass
80
84
  class ModalComponentData(DataModel):
81
85
  """Represents the modal field response from a modal."""
86
+
82
87
  type: int
83
88
  """Type of component."""
84
89
 
@@ -94,6 +99,7 @@ class ModalComponentData(DataModel):
94
99
  @dataclass
95
100
  class ModalComponent(DataModel):
96
101
  """Represents the modal component response from a modal."""
102
+
97
103
  type: int
98
104
  """Type of component."""
99
105
 
@@ -128,7 +134,13 @@ class ModalData(DataModel):
128
134
 
129
135
  t = component.component.type
130
136
 
131
- if t in [3,5,6,7,8]: # select menus (w. possibly many option selects!)
137
+ if t in [
138
+ ComponentTypes.STRING_SELECT,
139
+ ComponentTypes.USER_SELECT,
140
+ ComponentTypes.ROLE_SELECT,
141
+ ComponentTypes.MENTIONABLE_SELECT,
142
+ ComponentTypes.CHANNEL_SELECT # select menus (w. possibly many option selects!)
143
+ ]:
132
144
  return component.component.values
133
145
 
134
146
  # text input
discord/http.py CHANGED
@@ -152,7 +152,7 @@ class HTTPClient:
152
152
  if data.get("global"):
153
153
  self.global_reset = asyncio.get_event_loop().time() + retry
154
154
  self.logger.log_warn(
155
- f"Rate limited {retry}s ({'global' if data.get('global') else 'bucket'})"
155
+ f"Rate limited {retry}s ({endpoint})"
156
156
  )
157
157
  await asyncio.sleep(retry + 0.5)
158
158
  continue
discord/models/emoji.py CHANGED
@@ -13,7 +13,7 @@ class EmojiModel(DataModel):
13
13
  """ID of the emoji (if custom)."""
14
14
 
15
15
  animated: bool = False
16
- """If the emoji is animated. Defaults to `False`."""
16
+ """If the emoji is animated. Defaults to False."""
17
17
 
18
18
  @property
19
19
  def mention(self) -> str:
@@ -3,6 +3,8 @@ from ..model import DataModel
3
3
 
4
4
  @dataclass
5
5
  class InteractionCallbackDataModel(DataModel):
6
+ """Represents the interaction callback object."""
7
+
6
8
  id: int
7
9
  """ID of the interaction."""
8
10
 
@@ -23,4 +25,7 @@ class InteractionCallbackDataModel(DataModel):
23
25
 
24
26
  @dataclass
25
27
  class InteractionCallbackModel(DataModel):
28
+ """Represents the interaction callback response object."""
29
+
26
30
  interaction: InteractionCallbackDataModel
31
+ """The interaction object associated with the interaction response."""
discord/parts/channel.py CHANGED
@@ -2,19 +2,41 @@ from dataclasses import dataclass
2
2
  from typing import Optional
3
3
  from ..model import DataModel
4
4
 
5
- # NOTE: Supported Channel Types listed here
6
5
  class ChannelTypes:
7
- """Constants for channel types."""
6
+ """
7
+ Constants for channel types.
8
+
9
+ !!! note
10
+ Only supported Channel Types listed here
11
+ """
12
+
8
13
  GUILD_TEXT = 0
14
+ """Text channel within a server."""
15
+
9
16
  GUILD_CATEGORY = 4
17
+ """Organizational category that contains up to 50 channels."""
18
+
10
19
  GUILD_ANNOUNCEMENT = 5
20
+ """Channel that users can follow and crosspost into their own server (formerly news channels)."""
11
21
 
12
22
  @dataclass
13
23
  class GuildChannel(DataModel):
14
24
  """Parameters for creating/editing a guild channel."""
25
+
15
26
  name: Optional[str] = None
27
+ """Name of the channel."""
28
+
16
29
  type: Optional[int] = None
30
+ """Type of channel. See [`ChannelTypes`][discord.parts.channel.ChannelTypes]."""
31
+
17
32
  topic: Optional[str] = None
33
+ """Topic of channel."""
34
+
18
35
  position: Optional[int] = None
36
+ """Sorting position of the channel (channels with the same position are sorted by id)."""
37
+
19
38
  parent_id: Optional[int] = None
39
+ """ID of the parent category for a channel."""
40
+
20
41
  nsfw: Optional[bool] = None
42
+ """Whether the channel is NSFW."""