scurrypy 0.4.2__tar.gz → 0.5.2__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.
Potentially problematic release.
This version of scurrypy might be problematic. Click here for more details.
- {scurrypy-0.4.2 → scurrypy-0.5.2}/PKG-INFO +11 -17
- {scurrypy-0.4.2 → scurrypy-0.5.2}/README.md +10 -16
- {scurrypy-0.4.2 → scurrypy-0.5.2}/pyproject.toml +7 -7
- scurrypy-0.5.2/scurrypy/__init__.py +376 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/client_like.py +1 -1
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/dispatch/command_dispatcher.py +13 -5
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/dispatch/event_dispatcher.py +15 -15
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/events/channel_events.py +1 -1
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/events/interaction_events.py +21 -9
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/events/message_events.py +4 -4
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/http.py +1 -1
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/intents.py +1 -1
- scurrypy-0.5.2/scurrypy/model.py +71 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/models/emoji.py +1 -1
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/models/interaction.py +5 -0
- scurrypy-0.5.2/scurrypy/parts/channel.py +42 -0
- scurrypy-0.5.2/scurrypy/parts/command.py +90 -0
- scurrypy-0.5.2/scurrypy/parts/components.py +224 -0
- scurrypy-0.5.2/scurrypy/parts/components_v2.py +144 -0
- scurrypy-0.5.2/scurrypy/parts/embed.py +83 -0
- scurrypy-0.5.2/scurrypy/parts/message.py +137 -0
- scurrypy-0.5.2/scurrypy/parts/modal.py +16 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/parts/role.py +1 -13
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/resources/channel.py +6 -6
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/resources/guild.py +3 -4
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/resources/interaction.py +23 -22
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/resources/message.py +13 -13
- {scurrypy-0.4.2 → scurrypy-0.5.2}/scurrypy.egg-info/PKG-INFO +11 -17
- scurrypy-0.5.2/scurrypy.egg-info/SOURCES.txt +56 -0
- scurrypy-0.5.2/scurrypy.egg-info/top_level.txt +1 -0
- scurrypy-0.4.2/discord/__init__.py +0 -223
- scurrypy-0.4.2/discord/model.py +0 -90
- scurrypy-0.4.2/discord/parts/action_row.py +0 -208
- scurrypy-0.4.2/discord/parts/channel.py +0 -20
- scurrypy-0.4.2/discord/parts/command.py +0 -102
- scurrypy-0.4.2/discord/parts/components_v2.py +0 -353
- scurrypy-0.4.2/discord/parts/embed.py +0 -154
- scurrypy-0.4.2/discord/parts/message.py +0 -194
- scurrypy-0.4.2/discord/parts/modal.py +0 -21
- scurrypy-0.4.2/scurrypy.egg-info/SOURCES.txt +0 -56
- scurrypy-0.4.2/scurrypy.egg-info/top_level.txt +0 -1
- {scurrypy-0.4.2 → scurrypy-0.5.2}/LICENSE +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/client.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/config.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/dispatch/__init__.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/dispatch/prefix_dispatcher.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/error.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/events/__init__.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/events/guild_events.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/events/hello_event.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/events/reaction_events.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/events/ready_event.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/gateway.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/logger.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/models/__init__.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/models/application.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/models/guild.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/models/integration.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/models/member.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/models/role.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/models/user.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/parts/__init__.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/parts/component_types.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/resources/__init__.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/resources/application.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/resources/bot_emojis.py +0 -0
- {scurrypy-0.4.2/discord → scurrypy-0.5.2/scurrypy}/resources/user.py +0 -0
- {scurrypy-0.4.2 → scurrypy-0.5.2}/scurrypy.egg-info/dependency_links.txt +0 -0
- {scurrypy-0.4.2 → scurrypy-0.5.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scurrypy
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.2
|
|
4
4
|
Summary: Dataclass-driven Discord API Wrapper in Python
|
|
5
5
|
Author: Furmissile
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -8,7 +8,7 @@ Description-Content-Type: text/markdown
|
|
|
8
8
|
License-File: LICENSE
|
|
9
9
|
Dynamic: license-file
|
|
10
10
|
|
|
11
|
-
#
|
|
11
|
+
# __ScurryPy__
|
|
12
12
|
|
|
13
13
|
[](https://badge.fury.io/py/scurrypy)
|
|
14
14
|
|
|
@@ -20,22 +20,17 @@ A dataclass-driven Discord API wrapper in Python!
|
|
|
20
20
|
|
|
21
21
|
While this wrapper is mainly used for various squirrel-related shenanigans, it can also be used for more generic bot purposes.
|
|
22
22
|
|
|
23
|
-
---
|
|
24
|
-
|
|
25
23
|
## Features
|
|
26
|
-
* Command and event handling
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
---
|
|
24
|
+
* Command, and event handling
|
|
25
|
+
* Unix shell-style wildcards for component routing
|
|
26
|
+
* Declarative style using decorators
|
|
27
|
+
* Supports both legacy and new features
|
|
28
|
+
* Respects Discord’s rate limits
|
|
32
29
|
|
|
33
|
-
##
|
|
30
|
+
## Notes & Early Status
|
|
34
31
|
* This is an early version — feedback, ideas, and contributions are very welcome! That said, there may be bumps along the way, so expect occasional bugs and quirks.
|
|
35
32
|
* Certain features are not yet supported, while others are intentionally omitted. See the [docs](https://furmissile.github.io/scurrypy) for full details.
|
|
36
33
|
|
|
37
|
-
---
|
|
38
|
-
|
|
39
34
|
## Getting Started
|
|
40
35
|
*Note: This section also appears in the documentation, but here are complete examples ready to use with your bot credentials.*
|
|
41
36
|
|
|
@@ -58,7 +53,7 @@ load_dotenv(dotenv_path='./path/to/env')
|
|
|
58
53
|
|
|
59
54
|
client = discord.Client(
|
|
60
55
|
token=os.getenv("DISCORD_TOKEN"),
|
|
61
|
-
application_id=APPLICATION_ID #
|
|
56
|
+
application_id=APPLICATION_ID # your bot’s application ID
|
|
62
57
|
)
|
|
63
58
|
|
|
64
59
|
@client.command(
|
|
@@ -84,7 +79,7 @@ load_dotenv(dotenv_path='./path/to/env')
|
|
|
84
79
|
|
|
85
80
|
client = discord.Client(
|
|
86
81
|
token=os.getenv("DISCORD_TOKEN"),
|
|
87
|
-
application_id=APPLICATION_ID
|
|
82
|
+
application_id=APPLICATION_ID # your bot’s application ID
|
|
88
83
|
intents=discord.set_intents(message_content=True),
|
|
89
84
|
prefix='!' # your custom prefix
|
|
90
85
|
)
|
|
@@ -126,5 +121,4 @@ If you plan to make substantial changes or release your own variant:
|
|
|
126
121
|
See the [License](./LICENSE) for details.
|
|
127
122
|
|
|
128
123
|
## Like What You See?
|
|
129
|
-
|
|
130
|
-
for more examples, guides, and API reference!
|
|
124
|
+
Explore the full [documentation](https://furmissile.github.io/scurrypy) for more examples, guides, and API reference.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# __ScurryPy__
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/py/scurrypy)
|
|
4
4
|
|
|
@@ -10,22 +10,17 @@ A dataclass-driven Discord API wrapper in Python!
|
|
|
10
10
|
|
|
11
11
|
While this wrapper is mainly used for various squirrel-related shenanigans, it can also be used for more generic bot purposes.
|
|
12
12
|
|
|
13
|
-
---
|
|
14
|
-
|
|
15
13
|
## Features
|
|
16
|
-
* Command and event handling
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
---
|
|
14
|
+
* Command, and event handling
|
|
15
|
+
* Unix shell-style wildcards for component routing
|
|
16
|
+
* Declarative style using decorators
|
|
17
|
+
* Supports both legacy and new features
|
|
18
|
+
* Respects Discord’s rate limits
|
|
22
19
|
|
|
23
|
-
##
|
|
20
|
+
## Notes & Early Status
|
|
24
21
|
* This is an early version — feedback, ideas, and contributions are very welcome! That said, there may be bumps along the way, so expect occasional bugs and quirks.
|
|
25
22
|
* Certain features are not yet supported, while others are intentionally omitted. See the [docs](https://furmissile.github.io/scurrypy) for full details.
|
|
26
23
|
|
|
27
|
-
---
|
|
28
|
-
|
|
29
24
|
## Getting Started
|
|
30
25
|
*Note: This section also appears in the documentation, but here are complete examples ready to use with your bot credentials.*
|
|
31
26
|
|
|
@@ -48,7 +43,7 @@ load_dotenv(dotenv_path='./path/to/env')
|
|
|
48
43
|
|
|
49
44
|
client = discord.Client(
|
|
50
45
|
token=os.getenv("DISCORD_TOKEN"),
|
|
51
|
-
application_id=APPLICATION_ID #
|
|
46
|
+
application_id=APPLICATION_ID # your bot’s application ID
|
|
52
47
|
)
|
|
53
48
|
|
|
54
49
|
@client.command(
|
|
@@ -74,7 +69,7 @@ load_dotenv(dotenv_path='./path/to/env')
|
|
|
74
69
|
|
|
75
70
|
client = discord.Client(
|
|
76
71
|
token=os.getenv("DISCORD_TOKEN"),
|
|
77
|
-
application_id=APPLICATION_ID
|
|
72
|
+
application_id=APPLICATION_ID # your bot’s application ID
|
|
78
73
|
intents=discord.set_intents(message_content=True),
|
|
79
74
|
prefix='!' # your custom prefix
|
|
80
75
|
)
|
|
@@ -116,5 +111,4 @@ If you plan to make substantial changes or release your own variant:
|
|
|
116
111
|
See the [License](./LICENSE) for details.
|
|
117
112
|
|
|
118
113
|
## Like What You See?
|
|
119
|
-
|
|
120
|
-
for more examples, guides, and API reference!
|
|
114
|
+
Explore the full [documentation](https://furmissile.github.io/scurrypy) for more examples, guides, and API reference.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "scurrypy"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.5.2"
|
|
8
8
|
|
|
9
9
|
description = "Dataclass-driven Discord API Wrapper in Python"
|
|
10
10
|
readme = "README.md"
|
|
@@ -14,10 +14,10 @@ dependencies = []
|
|
|
14
14
|
|
|
15
15
|
[tool.setuptools]
|
|
16
16
|
packages = [
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
17
|
+
"scurrypy",
|
|
18
|
+
"scurrypy.dispatch",
|
|
19
|
+
"scurrypy.events",
|
|
20
|
+
"scurrypy.models",
|
|
21
|
+
"scurrypy.resources",
|
|
22
|
+
"scurrypy.parts"
|
|
23
23
|
]
|
|
@@ -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`][
|
|
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`][
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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': ('
|
|
10
|
+
'READY': ('scurrypy.events.ready_event', 'ReadyEvent'),
|
|
11
11
|
|
|
12
|
-
'GUILD_CREATE': ('
|
|
13
|
-
'GUILD_UPDATE': ('
|
|
14
|
-
'GUILD_DELETE': ('
|
|
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': ('
|
|
17
|
-
'CHANNEL_UPDATE': ('
|
|
18
|
-
'CHANNEL_DELETE': ('
|
|
19
|
-
'CHANNEL_PINS_UPDATE': ('
|
|
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': ('
|
|
22
|
-
'MESSAGE_UPDATE': ('
|
|
23
|
-
'MESSAGE_DELETE': ('
|
|
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': ('
|
|
26
|
-
'MESSAGE_REACTION_REMOVE': ('
|
|
27
|
-
'MESSAGE_REACTION_REMOVE_ALL': ('
|
|
28
|
-
'MESSAGE_REACTION_REMOVE_EMOJI': ('
|
|
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
|
}
|