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
scurrypy/__init__.py ADDED
@@ -0,0 +1,376 @@
1
+ # scurrypy
2
+
3
+ import importlib
4
+ from typing import TYPE_CHECKING
5
+
6
+ __all__ = [
7
+ "Logger",
8
+ "Client",
9
+ "Intents",
10
+ "set_intents",
11
+ "BaseConfig",
12
+
13
+ "InteractionTypes",
14
+
15
+ "ReadyEvent",
16
+
17
+ "ReactionAddEvent",
18
+ "ReactionRemoveEvent",
19
+ "ReactionRemoveEmojiEvent",
20
+ "ReactionRemoveAllEvent",
21
+
22
+ "GuildCreateEvent",
23
+ "GuildUpdateEvent",
24
+ "GuildDeleteEvent",
25
+
26
+ "MessageCreateEvent",
27
+ "MessageUpdateEvent",
28
+ "MessageDeleteEvent",
29
+
30
+ "GuildChannelCreateEvent",
31
+ "GuildChannelUpdateEvent",
32
+ "GuildChannelDeleteEvent",
33
+ "ChannelPinsUpdateEvent",
34
+
35
+ "InteractionEvent",
36
+
37
+ "ApplicationModel",
38
+ "EmojiModel",
39
+ "GuildModel",
40
+ "MemberModel",
41
+ "UserModel",
42
+ "RoleModel",
43
+
44
+ "ChannelTypes",
45
+ "GuildChannel",
46
+
47
+ "CommandTypes",
48
+ "CommandOptionTypes",
49
+ "SlashCommand",
50
+ "UserCommand",
51
+ "MessageCommand",
52
+
53
+ "ComponentV2Types",
54
+ "SectionPart",
55
+ "TextDisplay",
56
+ "Thumbnail",
57
+ "MediaGalleryItem",
58
+ "MediaGallery",
59
+ "File",
60
+ "SeparatorTypes",
61
+ "Separator",
62
+ "ContainerPart",
63
+ "Label",
64
+
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",
101
+ "Channel",
102
+
103
+ "Guild",
104
+
105
+ "InteractionCallbackTypes",
106
+ "Interaction",
107
+
108
+ "Message",
109
+
110
+ "User",
111
+ ]
112
+
113
+ # For editor support / autocomplete
114
+ if TYPE_CHECKING:
115
+ from .logger import Logger
116
+ from .client import Client
117
+ from .intents import Intents, set_intents
118
+ from .config import BaseConfig
119
+
120
+ from .dispatch.command_dispatcher import InteractionTypes
121
+
122
+ # events
123
+ from .events.ready_event import ReadyEvent
124
+ from .events.reaction_events import (
125
+ ReactionAddEvent,
126
+ ReactionRemoveEvent,
127
+ ReactionRemoveEmojiEvent,
128
+ ReactionRemoveAllEvent,
129
+ )
130
+ from .events.guild_events import (
131
+ GuildCreateEvent,
132
+ GuildUpdateEvent,
133
+ GuildDeleteEvent,
134
+ )
135
+ from .events.message_events import (
136
+ MessageCreateEvent,
137
+ MessageUpdateEvent,
138
+ MessageDeleteEvent,
139
+ )
140
+ from .events.channel_events import (
141
+ GuildChannelCreateEvent,
142
+ GuildChannelUpdateEvent,
143
+ GuildChannelDeleteEvent,
144
+ ChannelPinsUpdateEvent,
145
+ )
146
+ from .events.interaction_events import InteractionEvent
147
+
148
+ # models
149
+ from .models.application import ApplicationModel
150
+ from .models.emoji import EmojiModel
151
+ from .models.guild import GuildModel
152
+ from .models.member import MemberModel
153
+ from .models.user import UserModel
154
+ from .models.role import RoleModel
155
+
156
+ # parts
157
+ from .parts.channel import (
158
+ ChannelTypes,
159
+ GuildChannel
160
+ )
161
+
162
+ from .parts.command import (
163
+ CommandTypes,
164
+ CommandOptionTypes,
165
+ SlashCommand,
166
+ UserCommand,
167
+ MessageCommand
168
+ )
169
+
170
+ from .parts.components_v2 import (
171
+ ComponentV2Types,
172
+ SectionPart,
173
+ TextDisplay,
174
+ Thumbnail,
175
+ MediaGalleryItem,
176
+ MediaGallery,
177
+ File,
178
+ SeparatorTypes,
179
+ Separator,
180
+ ContainerPart,
181
+ Label
182
+ )
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
+
222
+ # resources
223
+ from .resources.application import (
224
+ ApplicationFlags,
225
+ Application
226
+ )
227
+
228
+ from .resources.bot_emojis import BotEmojis
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
+ )
256
+
257
+ # Lazy loader
258
+ def __getattr__(name: str):
259
+ if name not in __all__:
260
+ raise AttributeError(f"module {__name__} has no attribute {name}")
261
+
262
+ mapping = {
263
+ # top-level
264
+ "Logger": "scurrypy.logger",
265
+ "Client": "scurrypy.client",
266
+ "Intents": "scurrypy.intents",
267
+ "set_intents": "scurrypy.intents",
268
+ "BaseConfig": "scurrypy.config",
269
+
270
+ 'InteractionTypes': "scurrypy.dispatch.command_dispatcher",
271
+
272
+ "ReadyEvent": "scurrypy.events.ready_event",
273
+
274
+ "ReactionAddEvent": "scurrypy.events.reaction_events",
275
+ "ReactionRemoveEvent": "scurrypy.events.reaction_events",
276
+ "ReactionRemoveEmojiEvent": "scurrypy.events.reaction_events",
277
+ "ReactionRemoveAllEvent": "scurrypy.events.reaction_events",
278
+
279
+ "GuildCreateEvent": "scurrypy.events.guild_events",
280
+ "GuildUpdateEvent": "scurrypy.events.guild_events",
281
+ "GuildDeleteEvent": "scurrypy.events.guild_events",
282
+
283
+ "MessageCreateEvent": "scurrypy.events.message_events",
284
+ "MessageUpdateEvent": "scurrypy.events.message_events",
285
+ "MessageDeleteEvent": "scurrypy.events.message_events",
286
+
287
+ "GuildChannelCreateEvent": "scurrypy.events.channel_events",
288
+ "GuildChannelUpdateEvent": "scurrypy.events.channel_events",
289
+ "GuildChannelDeleteEvent": "scurrypy.events.channel_events",
290
+ "ChannelPinsUpdateEvent": "scurrypy.events.channel_events",
291
+
292
+ "InteractionEvent": "scurrypy.events.interaction_events",
293
+
294
+ 'ApplicationModel': "scurrypy.models.application",
295
+ 'EmojiModel': "scurrypy.models.emoji",
296
+ 'GuildModel': "scurrypy.models.guild",
297
+ 'MemberModel': "scurrypy.models.member",
298
+ 'UserModel': "scurrypy.models.user",
299
+ 'RoleModel': "scurrypy.models.role",
300
+
301
+ 'ChannelTypes': "scurrypy.parts.channel",
302
+ 'GuildChannel': "scurrypy.parts.channel",
303
+
304
+ 'CommandTypes': "scurrypy.parts.command",
305
+ 'CommandOptionTypes': "scurrypy.parts.command",
306
+ 'SlashCommand': "scurrypy.parts.command",
307
+ 'UserCommand': "scurrypy.parts.command",
308
+ 'MessageCommand': "scurrypy.parts.command",
309
+
310
+ 'ComponentV2Types': "scurrypy.parts.components_v2",
311
+ 'SectionPart': "scurrypy.parts.components_v2",
312
+ 'TextDisplay': "scurrypy.parts.components_v2",
313
+ 'Thumbnail': "scurrypy.parts.components_v2",
314
+ 'MediaGalleryItem': "scurrypy.parts.components_v2",
315
+ 'MediaGallery': "scurrypy.parts.components_v2",
316
+ 'File': "scurrypy.parts.components_v2",
317
+ 'SeparatorTypes': "scurrypy.parts.components_v2",
318
+ 'Separator': "scurrypy.parts.components_v2",
319
+ 'ContainerPart': "scurrypy.parts.components_v2",
320
+ 'Label': "scurrypy.parts.components_v2",
321
+
322
+ 'ComponentTypes': "scurrypy.parts.components",
323
+ 'ActionRowPart': "scurrypy.parts.components",
324
+ 'ButtonStyles': "scurrypy.parts.components",
325
+ 'Button': "scurrypy.parts.components",
326
+ 'SelectOption': "scurrypy.parts.components",
327
+ 'StringSelect': "scurrypy.parts.components",
328
+ 'TextInputStyles': 'scurrypy.parts.components',
329
+ 'TextInput': "scurrypy.parts.components",
330
+ 'DefaultValue': "scurrypy.parts.components",
331
+ 'UserSelect': "scurrypy.parts.components",
332
+ 'RoleSelect': "scurrypy.parts.components",
333
+ 'MentionableSelect': "scurrypy.parts.components",
334
+ 'ChannelSelect': "scurrypy.parts.components",
335
+
336
+ 'EmbedAuthor': "scurrypy.parts.embed",
337
+ 'EmbedThumbnail': "scurrypy.parts.embed",
338
+ 'EmbedField': "scurrypy.parts.embed",
339
+ 'EmbedImage': "scurrypy.parts.embed",
340
+ 'EmbedFooter': "scurrypy.parts.embed",
341
+ 'EmbedPart': "scurrypy.parts.embed",
342
+
343
+ 'MessageFlags': "scurrypy.parts.message",
344
+ 'MessageReferenceTypes': "scurrypy.parts.message",
345
+ 'MessageReference': "scurrypy.parts.message",
346
+ 'Attachment': "scurrypy.parts.message",
347
+ 'MessagePart': "scurrypy.parts.message",
348
+
349
+ 'ModalPart': "scurrypy.parts.modal",
350
+ 'Role': "scurrypy.parts.role",
351
+
352
+ 'ApplicationFlags': "scurrypy.resources.application",
353
+ 'Application': "scurrypy.resources.application",
354
+
355
+ 'BotEmojis': "scurrypy.resources.bot_emojis",
356
+
357
+ 'PinnedMessage': "scurrypy.resources.channel",
358
+ 'Channel': "scurrypy.resources.channel",
359
+
360
+ 'Guild': "scurrypy.resources.guild",
361
+
362
+ 'InteractionCallbackTypes': "scurrypy.resources.interaction",
363
+ 'Interaction': "scurrypy.resources.interaction",
364
+
365
+ 'Message': "scurrypy.resources.message",
366
+
367
+ 'User': "scurrypy.resources.user"
368
+ }
369
+
370
+ module = importlib.import_module(mapping[name])
371
+ attr = getattr(module, name)
372
+ globals()[name] = attr # cache it for future lookups
373
+ return attr
374
+
375
+ def __dir__():
376
+ return sorted(list(globals().keys()) + __all__)
@@ -5,7 +5,7 @@ from .http import HTTPClient
5
5
  from .logger import Logger
6
6
 
7
7
  class ClientLike(Protocol):
8
- """Exposes a common interface for [`Client`][discord.client.Client]."""
8
+ """Exposes a common interface for [`Client`][scurrypy.client.Client]."""
9
9
  application_id: int
10
10
  """Bot's application ID."""
11
11
 
@@ -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
@@ -23,7 +25,7 @@ class CommandDispatcher:
23
25
  InteractionTypes.MESSAGE_COMPONENT: MessageComponentData,
24
26
  InteractionTypes.MODAL_SUBMIT: ModalData
25
27
  }
26
- """Maps [`InteractionTypes`][discord.dispatch.command_dispatcher.InteractionTypes] to their respective dataclass."""
28
+ """Maps [`InteractionTypes`][scurrypy.dispatch.command_dispatcher.InteractionTypes] to their respective dataclass."""
27
29
 
28
30
  def __init__(self, client: ClientLike):
29
31
  self.application_id = client.application_id
@@ -64,7 +66,7 @@ class CommandDispatcher:
64
66
  await self._http.request(
65
67
  'PUT',
66
68
  f"applications/{self.application_id}/guilds/{guild_id}/commands",
67
- data=[command._to_dict() for command in cmds]
69
+ data=[command.to_dict() for command in cmds]
68
70
  )
69
71
 
70
72
  async def _register_global_commands(self, commands: list):
@@ -74,7 +76,7 @@ class CommandDispatcher:
74
76
  commands (list): list of serialized commands
75
77
  """
76
78
 
77
- global_commands = [command._to_dict() for command in commands]
79
+ global_commands = [command.to_dict() for command in commands]
78
80
 
79
81
  await self._http.request('PUT', f"applications/{self.application_id}/commands", data=global_commands)
80
82
 
@@ -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}'")
@@ -7,25 +7,25 @@ class EventDispatcher:
7
7
  """Central hub for handling Discord Gateway events."""
8
8
 
9
9
  RESOURCE_MAP = { # maps discord events to their respective dataclass (lazy loading)
10
- 'READY': ('discord.events.ready_event', 'ReadyEvent'),
10
+ 'READY': ('scurrypy.events.ready_event', 'ReadyEvent'),
11
11
 
12
- 'GUILD_CREATE': ('discord.events.guild_events', 'GuildCreateEvent'),
13
- 'GUILD_UPDATE': ('discord.events.guild_events', 'GuildUpdateEvent'),
14
- 'GUILD_DELETE': ('discord.events.guild_events', 'GuildDeleteEvent'),
12
+ 'GUILD_CREATE': ('scurrypy.events.guild_events', 'GuildCreateEvent'),
13
+ 'GUILD_UPDATE': ('scurrypy.events.guild_events', 'GuildUpdateEvent'),
14
+ 'GUILD_DELETE': ('scurrypy.events.guild_events', 'GuildDeleteEvent'),
15
15
 
16
- 'CHANNEL_CREATE': ('discord.events.channel_events', 'GuildChannelCreateEvent'),
17
- 'CHANNEL_UPDATE': ('discord.events.channel_events', 'GuildChannelUpdateEvent'),
18
- 'CHANNEL_DELETE': ('discord.events.channel_events', 'GuildChannelDeleteEvent'),
19
- 'CHANNEL_PINS_UPDATE': ('discord.events.channel_events', 'ChannelPinsUpdateEvent'),
16
+ 'CHANNEL_CREATE': ('scurrypy.events.channel_events', 'GuildChannelCreateEvent'),
17
+ 'CHANNEL_UPDATE': ('scurrypy.events.channel_events', 'GuildChannelUpdateEvent'),
18
+ 'CHANNEL_DELETE': ('scurrypy.events.channel_events', 'GuildChannelDeleteEvent'),
19
+ 'CHANNEL_PINS_UPDATE': ('scurrypy.events.channel_events', 'ChannelPinsUpdateEvent'),
20
20
 
21
- 'MESSAGE_CREATE': ('discord.events.message_events', 'MessageCreateEvent'),
22
- 'MESSAGE_UPDATE': ('discord.events.message_events', 'MessageUpdateEvent'),
23
- 'MESSAGE_DELETE': ('discord.events.message_events', 'MessageDeleteEvent'),
21
+ 'MESSAGE_CREATE': ('scurrypy.events.message_events', 'MessageCreateEvent'),
22
+ 'MESSAGE_UPDATE': ('scurrypy.events.message_events', 'MessageUpdateEvent'),
23
+ 'MESSAGE_DELETE': ('scurrypy.events.message_events', 'MessageDeleteEvent'),
24
24
 
25
- 'MESSAGE_REACTION_ADD': ('discord.events.reaction_events', 'ReactionAddEvent'),
26
- 'MESSAGE_REACTION_REMOVE': ('discord.events.reaction_events', 'ReactionRemoveEvent'),
27
- 'MESSAGE_REACTION_REMOVE_ALL': ('discord.events.reaction_events', 'ReactionRemoveAllEvent'),
28
- 'MESSAGE_REACTION_REMOVE_EMOJI': ('discord.events.reaction_events', 'ReactionRemoveEmojiEvent'),
25
+ 'MESSAGE_REACTION_ADD': ('scurrypy.events.reaction_events', 'ReactionAddEvent'),
26
+ 'MESSAGE_REACTION_REMOVE': ('scurrypy.events.reaction_events', 'ReactionRemoveEvent'),
27
+ 'MESSAGE_REACTION_REMOVE_ALL': ('scurrypy.events.reaction_events', 'ReactionRemoveAllEvent'),
28
+ 'MESSAGE_REACTION_REMOVE_EMOJI': ('scurrypy.events.reaction_events', 'ReactionRemoveEmojiEvent'),
29
29
 
30
30
  # and other events...
31
31
  }
@@ -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,17 +3,19 @@ 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
 
15
17
  type: int
16
- """Type of command option. See [`CommandOptionTypes`][discord.parts.command.CommandOptionTypes]."""
18
+ """Type of command option. See [`CommandOptionTypes`][scurrypy.parts.command.CommandOptionTypes]."""
17
19
 
18
20
  value: str | int | float | bool
19
21
  """Input value for option."""
@@ -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
@@ -141,7 +153,7 @@ class InteractionEvent(DataModel):
141
153
  """Represents the interaction response."""
142
154
 
143
155
  interaction: Interaction
144
- """Interaction resource object. See [`Interaction`][discord.resources.interaction.Interaction]."""
156
+ """Interaction resource object. See [`Interaction`][scurrypy.resources.interaction.Interaction]."""
145
157
 
146
158
  data: Optional[ApplicationCommandData | MessageComponentData | ModalData] = None
147
159
  """Interaction response data."""
@@ -9,25 +9,25 @@ from ..models.member import MemberModel
9
9
  class MessageCreateEvent(DataModel):
10
10
  """Received when a message is created."""
11
11
  message: Message
12
- """Message resource object. See [`Resource.Message`][discord.resources.message.Message]."""
12
+ """Message resource object. See [`Resource.Message`][scurrypy.resources.message.Message]."""
13
13
 
14
14
  guild_id: Optional[int]
15
15
  """Guild ID of the updated message (if in a guild channel)."""
16
16
 
17
17
  member: Optional[MemberModel] # guild-only author info
18
- """Partial Member object of the author of the message. See [`MemberModel`][discord.models.member.MemberModel]."""
18
+ """Partial Member object of the author of the message. See [`MemberModel`][scurrypy.models.member.MemberModel]."""
19
19
 
20
20
  @dataclass
21
21
  class MessageUpdateEvent(DataModel):
22
22
  """Received when a message is updated."""
23
23
  message: Message
24
- """Message resource object. See [`Resource.Message`][discord.resources.message.Message]."""
24
+ """Message resource object. See [`Resource.Message`][scurrypy.resources.message.Message]."""
25
25
 
26
26
  guild_id: Optional[int]
27
27
  """Guild ID of the updated message (if in a guild channel)."""
28
28
 
29
29
  member: Optional[MemberModel]
30
- """Partial Member object of the author of the message. See [`MemberModel`][discord.models.member.MemberModel]."""
30
+ """Partial Member object of the author of the message. See [`MemberModel`][scurrypy.models.member.MemberModel]."""
31
31
 
32
32
  @dataclass
33
33
  class MessageDeleteEvent(DataModel):
@@ -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
@@ -54,7 +54,7 @@ class IntentFlagParams(TypedDict, total=False):
54
54
  message_content: bool
55
55
 
56
56
  def set_intents(**flags: Unpack[IntentFlagParams]):
57
- """Set bot intents using [`IntentFlagParams`][discord.intents.IntentFlagParams].
57
+ """Set bot intents using [`IntentFlagParams`][scurrypy.intents.IntentFlagParams].
58
58
  `Intents.DEFAULT` = (GUILDS | GUILD_MESSAGES) will also be set.
59
59
 
60
60
  Args: