6
6
from . import http
7
7
from . import error
8
8
9
+
9
10
class ChoiceData :
10
11
"""
11
12
Command choice data object
12
13
13
14
:ivar name: Name of the choice, this is what the user will see
14
15
:ivar value: Values of the choice, this is what discord will return to you
15
16
"""
17
+
16
18
def __init__ (self , name , value ):
17
19
self .name = name
18
20
self .value = value
@@ -31,8 +33,9 @@ class OptionData:
31
33
:ivar choices: A list of :class:`ChoiceData`, cannot be present on subcommand groups
32
34
:ivar options: List of :class:`OptionData`, this will be present if it's a subcommand group
33
35
"""
36
+
34
37
def __init__ (
35
- self , name , description , required = False , choices = None , options = None , ** kwargs
38
+ self , name , description , required = False , choices = None , options = None , ** kwargs
36
39
):
37
40
self .name = name
38
41
self .description = description
@@ -72,7 +75,7 @@ class CommandData:
72
75
"""
73
76
74
77
def __init__ (
75
- self , name , description , options = [] , id = None , application_id = None , version = None , ** kwargs
78
+ self , name , description , options = None , id = None , application_id = None , version = None , ** kwargs
76
79
):
77
80
self .name = name
78
81
self .description = description
@@ -89,9 +92,9 @@ def __init__(
89
92
def __eq__ (self , other ):
90
93
if isinstance (other , CommandData ):
91
94
return (
92
- self .name == other .name
93
- and self .description == other .description
94
- and self .options == other .options
95
+ self .name == other .name
96
+ and self .description == other .description
97
+ and self .options == other .options
95
98
)
96
99
else :
97
100
return False
@@ -112,6 +115,7 @@ class CommandObject:
112
115
:ivar connector: Kwargs connector of the command.
113
116
:ivar __commands_checks__: Check of the command.
114
117
"""
118
+
115
119
def __init__ (self , name , cmd ): # Let's reuse old command formatting.
116
120
self .name = name .lower ()
117
121
self .func = cmd ["func" ]
@@ -187,8 +191,9 @@ class SubcommandObject(CommandObject):
187
191
:ivar base_description: Description of the base command.
188
192
:ivar subcommand_group_description: Description of the subcommand_group.
189
193
"""
194
+
190
195
def __init__ (self , sub , base , name , sub_group = None ):
191
- sub ["has_subcommands" ] = True # For the inherited class.
196
+ sub ["has_subcommands" ] = True # For the inherited class.
192
197
super ().__init__ (name , sub )
193
198
self .base = base .lower ()
194
199
self .subcommand_group = sub_group .lower () if sub_group else sub_group
@@ -203,6 +208,7 @@ class CogCommandObject(CommandObject):
203
208
.. warning::
204
209
Do not manually init this model.
205
210
"""
211
+
206
212
def __init__ (self , * args ):
207
213
super ().__init__ (* args )
208
214
self .cog = None # Manually set this later.
@@ -228,6 +234,7 @@ class CogSubcommandObject(SubcommandObject):
228
234
.. warning::
229
235
Do not manually init this model.
230
236
"""
237
+
231
238
def __init__ (self , * args ):
232
239
super ().__init__ (* args )
233
240
self .cog = None # Manually set this later.
@@ -278,6 +285,7 @@ def from_type(cls, t: type):
278
285
279
286
class SlashMessage (discord .Message ):
280
287
"""discord.py's :class:`discord.Message` but overridden ``edit`` and ``delete`` to work for slash command."""
288
+
281
289
def __init__ (self , * , state , channel , data , _http : http .SlashCommandRequest , interaction_token ):
282
290
# Yes I know it isn't the best way but this makes implementation simple.
283
291
super ().__init__ (state = state , channel = channel , data = data )
@@ -318,15 +326,13 @@ async def _slash_edit(self, **fields):
318
326
_resp ["allowed_mentions" ] = allowed_mentions .to_dict () if allowed_mentions else \
319
327
self ._state .allowed_mentions .to_dict () if self ._state .allowed_mentions else {}
320
328
321
- await self ._http .edit (_resp , self .__interaction_token , self .id , files = files )
329
+ await self ._http .edit (_resp , self .__interaction_token , self .id , files = files )
322
330
323
331
delete_after = fields .get ("delete_after" )
324
332
if delete_after :
325
333
await self .delete (delay = delete_after )
326
334
if files :
327
- for file in files :
328
- file .close ()
329
-
335
+ [x .close () for x in files ]
330
336
331
337
async def edit (self , ** fields ):
332
338
"""Refer :meth:`discord.Message.edit`."""
@@ -350,4 +356,5 @@ async def wrap():
350
356
with suppress (discord .HTTPException ):
351
357
await asyncio .sleep (delay )
352
358
await self ._http .delete (self .__interaction_token , self .id )
359
+
353
360
self ._state .loop .create_task (wrap ())
0 commit comments