66from . import http
77from . import error
88
9+
910class ChoiceData :
1011 """
1112 Command choice data object
1213
1314 :ivar name: Name of the choice, this is what the user will see
1415 :ivar value: Values of the choice, this is what discord will return to you
1516 """
17+
1618 def __init__ (self , name , value ):
1719 self .name = name
1820 self .value = value
@@ -31,8 +33,9 @@ class OptionData:
3133 :ivar choices: A list of :class:`ChoiceData`, cannot be present on subcommand groups
3234 :ivar options: List of :class:`OptionData`, this will be present if it's a subcommand group
3335 """
36+
3437 def __init__ (
35- self , name , description , required = False , choices = None , options = None , ** kwargs
38+ self , name , description , required = False , choices = None , options = None , ** kwargs
3639 ):
3740 self .name = name
3841 self .description = description
@@ -72,7 +75,7 @@ class CommandData:
7275 """
7376
7477 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
7679 ):
7780 self .name = name
7881 self .description = description
@@ -89,9 +92,9 @@ def __init__(
8992 def __eq__ (self , other ):
9093 if isinstance (other , CommandData ):
9194 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
9598 )
9699 else :
97100 return False
@@ -112,6 +115,7 @@ class CommandObject:
112115 :ivar connector: Kwargs connector of the command.
113116 :ivar __commands_checks__: Check of the command.
114117 """
118+
115119 def __init__ (self , name , cmd ): # Let's reuse old command formatting.
116120 self .name = name .lower ()
117121 self .func = cmd ["func" ]
@@ -187,8 +191,9 @@ class SubcommandObject(CommandObject):
187191 :ivar base_description: Description of the base command.
188192 :ivar subcommand_group_description: Description of the subcommand_group.
189193 """
194+
190195 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.
192197 super ().__init__ (name , sub )
193198 self .base = base .lower ()
194199 self .subcommand_group = sub_group .lower () if sub_group else sub_group
@@ -203,6 +208,7 @@ class CogCommandObject(CommandObject):
203208 .. warning::
204209 Do not manually init this model.
205210 """
211+
206212 def __init__ (self , * args ):
207213 super ().__init__ (* args )
208214 self .cog = None # Manually set this later.
@@ -228,6 +234,7 @@ class CogSubcommandObject(SubcommandObject):
228234 .. warning::
229235 Do not manually init this model.
230236 """
237+
231238 def __init__ (self , * args ):
232239 super ().__init__ (* args )
233240 self .cog = None # Manually set this later.
@@ -278,6 +285,7 @@ def from_type(cls, t: type):
278285
279286class SlashMessage (discord .Message ):
280287 """discord.py's :class:`discord.Message` but overridden ``edit`` and ``delete`` to work for slash command."""
288+
281289 def __init__ (self , * , state , channel , data , _http : http .SlashCommandRequest , interaction_token ):
282290 # Yes I know it isn't the best way but this makes implementation simple.
283291 super ().__init__ (state = state , channel = channel , data = data )
@@ -318,15 +326,13 @@ async def _slash_edit(self, **fields):
318326 _resp ["allowed_mentions" ] = allowed_mentions .to_dict () if allowed_mentions else \
319327 self ._state .allowed_mentions .to_dict () if self ._state .allowed_mentions else {}
320328
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 )
322330
323331 delete_after = fields .get ("delete_after" )
324332 if delete_after :
325333 await self .delete (delay = delete_after )
326334 if files :
327- for file in files :
328- file .close ()
329-
335+ [x .close () for x in files ]
330336
331337 async def edit (self , ** fields ):
332338 """Refer :meth:`discord.Message.edit`."""
@@ -350,4 +356,5 @@ async def wrap():
350356 with suppress (discord .HTTPException ):
351357 await asyncio .sleep (delay )
352358 await self ._http .delete (self .__interaction_token , self .id )
359+
353360 self ._state .loop .create_task (wrap ())
0 commit comments