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/parts/command.py CHANGED
@@ -1,8 +1,12 @@
1
1
  from dataclasses import dataclass, field
2
- from typing import Literal
3
2
 
4
3
  from ..model import DataModel
5
4
 
5
+ class CommandTypes:
6
+ CHAT_INPUT = 1
7
+ USER_COMMAND = 2
8
+ MESSAGE_COMMAND = 3
9
+
6
10
  class CommandOptionTypes:
7
11
  """Slash command option input types."""
8
12
 
@@ -34,69 +38,53 @@ class CommandOptionTypes:
34
38
  """file upload"""
35
39
 
36
40
  @dataclass
37
- class MessageCommand(DataModel):
38
- """Represents the message command object."""
39
- type: Literal[3] = field(init=False, default=3) # MESSAGE
41
+ class CommandOption(DataModel):
42
+ """Option for a slash command."""
43
+
44
+ type: int
45
+ """Type of option. See [`CommandOptionTypes`][discord.parts.command.CommandOptionTypes]."""
46
+
40
47
  name: str
48
+ """Name of option."""
49
+
50
+ description: str
51
+ """Description of option."""
52
+
53
+ required: bool = False
54
+ """Whether this option is required. Defaults to False."""
41
55
 
42
56
  @dataclass
43
- class UserCommand(DataModel):
44
- """Represents the user command object"""
45
- type: Literal[2] = field(init=False, default=2) # USER
57
+ class SlashCommand(DataModel):
58
+ """Represents the slash command object."""
59
+
46
60
  name: str
61
+ """Name of the command."""
62
+
63
+ description: str
64
+ """Description of the command."""
65
+
66
+ options: list[CommandOption] = field(default_factory=list)
67
+ """Parameters or options for the command."""
68
+
69
+ type: int = field(init=False, default=CommandTypes.CHAT_INPUT)
70
+ """Command type. Always `CommandTypes.CHAT_INPUT` for this class. See [`CommandTypes`][discord.parts.command.CommandTypes]."""
47
71
 
48
72
  @dataclass
49
- class _CommandOption(DataModel):
50
- """Option for a slash command."""
51
- type: int # refer to CommandOptionTypes
73
+ class UserCommand(DataModel):
74
+ """Represents the user command object"""
75
+
52
76
  name: str
53
- description: str
54
- required: bool = True
77
+ """Name of the command."""
78
+
79
+ type: int = field(init=False, default=CommandTypes.USER_COMMAND)
80
+ """Command type. Always `CommandTypes.USER_COMMAND` for this class. See [`CommandTypes`][discord.parts.command.CommandTypes]."""
55
81
 
56
82
  @dataclass
57
- class SlashCommand(DataModel):
58
- type: Literal[1] = field(init=False, default=1) # CHAT_INPUT
83
+ class MessageCommand(DataModel):
84
+ """Represents the message command object."""
85
+
59
86
  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
87
+ """Name of the command."""
88
+
89
+ type: int = field(init=False, default=CommandTypes.MESSAGE_COMMAND)
90
+ """Command type. Always `CommandTypes.MESSAGE_COMMAND` for this class. See [`CommandTypes`][discord.parts.command.CommandTypes]."""
@@ -0,0 +1,224 @@
1
+ from dataclasses import dataclass, field
2
+ from typing import Literal, Optional
3
+ from ..model import DataModel
4
+
5
+ from .component_types import *
6
+
7
+ from ..models.emoji import EmojiModel
8
+
9
+ class ComponentTypes:
10
+ ACTION_ROW = 1
11
+ BUTTON = 2
12
+ STRING_SELECT = 3
13
+ TEXT_INPUT = 4
14
+ USER_SELECT = 5
15
+ ROLE_SELECT = 6
16
+ MENTIONABLE_SELECT = 7
17
+ CHANNEL_SELECT = 8
18
+
19
+ @dataclass
20
+ class ActionRowPart(DataModel, ContainerChild):
21
+ """Represents a container of interactable components."""
22
+
23
+ components: list[ActionRowChild] = field(default_factory=list)
24
+ """Up to 5 interactive button components or a single select component."""
25
+
26
+ type: int = field(init=False, default=ComponentTypes.ACTION_ROW)
27
+ """Component type. Always `ComponentTypes.ACTION_ROW` for this class. See [`ComponentTypes`][discord.parts.components.ComponentTypes]."""
28
+
29
+ class ButtonStyles:
30
+ """Represents button styles for a Button component."""
31
+
32
+ PRIMARY = 1
33
+ """The most important or recommended action in a group of options. (Blurple)"""
34
+
35
+ SECONDARY = 2
36
+ """Alternative or supporting actions. (Gray)"""
37
+
38
+ SUCCESS = 3
39
+ """Positive confirmation or completion actions. (Green)"""
40
+
41
+ DANGER = 4
42
+ """An action with irreversible consequences. (Red)"""
43
+
44
+ LINK = 5
45
+ """Navigates to a URL. (Gray + window)"""
46
+
47
+ @dataclass
48
+ class Button(DataModel, ActionRowChild, SectionAccessory):
49
+ """Represents the Button component."""
50
+
51
+ style: int
52
+ """A button style. See [`ButtonStyles`][discord.parts.components.ButtonStyles]."""
53
+
54
+ custom_id: str
55
+ """ID for the button."""
56
+
57
+ label: Optional[str] = None
58
+ """Text that appears on the button."""
59
+
60
+ emoji: EmojiModel = None
61
+ """Partial emoji icon."""
62
+
63
+ url: Optional[str] = None
64
+ """URL for link-style buttons."""
65
+
66
+ disabled: Optional[bool] = False
67
+ """Whether the button is disabled. Defaults to False."""
68
+
69
+ type: int = field(init=False, default=ComponentTypes.BUTTON)
70
+ """Component type. Always `ComponentTypes.BUTTON` for this class. See [`ComponentTypes`][discord.parts.components.ComponentTypes]."""
71
+
72
+ @dataclass
73
+ class SelectOption(DataModel):
74
+ """Represents the Select Option component"""
75
+
76
+ label: str
77
+ """User-facing name of the option."""
78
+
79
+ value: str
80
+ """Developer-defined value of the option."""
81
+
82
+ description: Optional[str] = None
83
+ """Additional description of the option."""
84
+
85
+ emoji: Optional[EmojiModel] = None
86
+ """Partial emoji obhect."""
87
+
88
+ default: Optional[bool] = False
89
+ """Whether this option is selected by default."""
90
+
91
+ @dataclass
92
+ class StringSelect(DataModel, ActionRowChild, LabelChild):
93
+ """Represents the String Select component."""
94
+
95
+ custom_id: str
96
+ """ID for the select menu."""
97
+
98
+ options: list[SelectOption] = field(default_factory=list)
99
+ """Specified choices in a select menu. See [`SelectOption`][discord.parts.components.SelectOption]."""
100
+
101
+ placeholder: Optional[str] = None
102
+ """Placeholder text if nothing is selected or default."""
103
+
104
+ min_values: Optional[int] = 1
105
+ """Minimum number of items that must be chosen."""
106
+
107
+ max_values: Optional[int] = 1
108
+ """Maximum number of items that can be chosen."""
109
+
110
+ required: Optional[bool] = False
111
+ """Whether the string select is required to answer in a modal. Defaults to False."""
112
+
113
+ disabled: Optional[bool] = False # does not work on Modals!
114
+ """Whether select menu is disabled in a message. Defaults to False."""
115
+
116
+ type: int = field(init=False, default=ComponentTypes.STRING_SELECT)
117
+ """Component type. Always `ComponentTypes.STRING_SELECT` for this class. See [`ComponentTypes`][discord.parts.components.ComponentTypes]."""
118
+
119
+ class TextInputStyles:
120
+ """Represents the types of Text Inputs."""
121
+
122
+ SHORT = 1
123
+ """One line text input."""
124
+
125
+ PARAGRAPH = 2
126
+ """Multi-line text input."""
127
+
128
+ @dataclass
129
+ class TextInput(DataModel, LabelChild):
130
+ """Represents the Text Input component."""
131
+
132
+ style: TextInputStyles = TextInputStyles.SHORT
133
+ """Text input style. See [`TextInputStyles`][discord.parts.components.TextInputStyles]."""
134
+
135
+ custom_id: str = None
136
+ """ID for the input."""
137
+
138
+ required: Optional[bool] = False
139
+ """Whether this component is required to be filled."""
140
+
141
+ min_length: Optional[int] = None
142
+ """Minimum input length for a text input."""
143
+
144
+ max_length: Optional[int] = None
145
+ """Maximum input length for a text input."""
146
+
147
+ required: Optional[bool] = True
148
+ """Whether this component is required to be filled. Defaults to True."""
149
+
150
+ value: Optional[str] = None
151
+ """Pre-filled value for this component."""
152
+
153
+ placeholder: Optional[str] = None
154
+ """Custom placeholder text if the input is empty."""
155
+
156
+ type: int = field(init=False, default=ComponentTypes.TEXT_INPUT)
157
+ """Component type. Always `ComponentTypes.TEXT_INPUT` for this class. See [`ComponentTypes`][discord.parts.components.ComponentTypes]."""
158
+
159
+ @dataclass
160
+ class DefaultValue(DataModel):
161
+ """Represents the Default Value for Select components."""
162
+
163
+ id: int
164
+ """ID of role, user, or channel."""
165
+
166
+ type: Literal["role", "user", "channel"]
167
+ """Type of value that `id` represents."""
168
+
169
+ @dataclass
170
+ class SelectMenu(DataModel):
171
+ """Represents common fields for Discord's select menus."""
172
+
173
+ custom_id: str
174
+ """ID for the select menu."""
175
+
176
+ placeholder: Optional[str] = None
177
+ """Placeholder text if nothing is selected."""
178
+
179
+ default_values: list[DefaultValue] = field(default_factory=list)
180
+ """
181
+ List of default values for auto-populated select menu components. See [`DefaultValue`][discord.parts.components.DefaultValue].
182
+ Number of default values must be in the range of `min_values` to `max_values`.
183
+ """
184
+
185
+ min_values: Optional[int] = 1
186
+ """Minimum number of items that must be chosen. Defaults to 1."""
187
+
188
+ max_values: Optional[int] = 1
189
+ """Maximum number of items that can be chosen. Defaults to 1."""
190
+
191
+ required: Optional[bool] = False
192
+ """Whether the user select is required to answer in a modal. Defaults to False."""
193
+
194
+ disabled: Optional[bool] = False
195
+ """Whether select menu is disabled in a message. Defaults to False."""
196
+
197
+
198
+ @dataclass
199
+ class UserSelect(SelectMenu, ActionRowChild, LabelChild):
200
+ """Represents the User Select component."""
201
+
202
+ type: int = field(init=False, default=ComponentTypes.USER_SELECT)
203
+ """Component type. Always `ComponentTypes.USER_SELECT` for this class. See [`ComponentTypes`][discord.parts.components.ComponentTypes]."""
204
+
205
+ @dataclass
206
+ class RoleSelect(SelectMenu, ActionRowChild, LabelChild):
207
+ """Represents the Role Select component."""
208
+
209
+ type: int = field(init=False, default=ComponentTypes.ROLE_SELECT)
210
+ """Component type. Always `ComponentTypes.ROLE_SELECT` for this class. See [`ComponentTypes`][discord.parts.components.ComponentTypes]."""
211
+
212
+ @dataclass
213
+ class MentionableSelect(SelectMenu, ActionRowChild, LabelChild):
214
+ """Represents the Mentionable Select component."""
215
+
216
+ type: int = field(init=False, default=ComponentTypes.MENTIONABLE_SELECT)
217
+ """Component type. Always `ComponentTypes.MENTIONABLE_SELECT` for this class. See [`ComponentTypes`][discord.parts.components.ComponentTypes]."""
218
+
219
+ @dataclass
220
+ class ChannelSelect(SelectMenu, ActionRowChild, LabelChild):
221
+ """Represents the Channel Select component."""
222
+
223
+ type: int = field(init=False, default=ComponentTypes.CHANNEL_SELECT)
224
+ """Component type. Always `ComponentTypes.CHANNEL_SELECT` for this class. See [`ComponentTypes`][discord.parts.components.ComponentTypes]."""