@@ -47,12 +47,12 @@ def __init__(self, argument_type, name, description=None, required=False, choice
4747 self ._json = {}
4848 self .argument_type = argument_type
4949 self .name = name
50- self .description = description or self .name
50+ self .description = _or ( description , self .name )
5151 if required is True :
52- self .required = required or []
53- if options is not MISSING :
54- self .options = options or []
55- if choices is not MISSING :
52+ self .required = _default ([], required )
53+ if not _none ( options ) :
54+ self .options = _default ([], options )
55+ if not _none ( choices ) :
5656 self ._json ["choices" ] = choices
5757 def __repr__ (self ) -> str :
5858 return f"<discord_ui.SlashOption({ str (self .to_dict ())} )>"
@@ -121,7 +121,7 @@ def choices(self) -> typing.List[dict]:
121121
122122 .. note::
123123
124- Choices are formated like this: ``[{"name": "name of the choice", "value": "the real value"}, ...]``
124+ Choices are formated like this: ``[{"name": "name of the choice", "value": "the real value"}, ...]``
125125
126126 :type: List[:class:`dict`]
127127 """
@@ -256,7 +256,7 @@ def __init__(self, allowed: dict=MISSING, forbidden=MISSING) -> None:
256256
257257 Example
258258 ```py
259- SlashPermission(allowed=[
259+ SlashPermission(allowed=[
260260 await bot.fetch_user(bot.owner_id)
261261 ], forbidden={
262262 539459006847255232: SlashPermission.User,
@@ -347,10 +347,7 @@ def __init__(self, callback, name=MISSING, description=MISSING, options=MISSING,
347347 "type" : CommandType .SLASH
348348 }
349349
350- # Check options before callback because callback makes an option check
351- if options is MISSING :
352- options = []
353- self .options = options
350+ self .options = _default ([], options )
354351 if callback is not None :
355352 if not inspect .iscoroutinefunction (callback ):
356353 raise NoAsyncCallback ()
@@ -410,7 +407,7 @@ def __eq__(self, o: object) -> bool:
410407 )
411408 elif isinstance (o , SlashCommand ):
412409 return (
413- o ._json ('type' ) == self ._json ["type" ]
410+ o ._json ('type' ) == self ._json ["type" ]
414411 and o .name == self .name
415412 and o .description == self .description
416413 and o .options == self .options
@@ -536,12 +533,12 @@ def __init__(self, callback, name=MISSING, description=MISSING, options=MISSING,
536533 async def my_function(command, parameter=None):
537534 pass
538535
539- SlashCommand(callback=my_function, name="hello_world", description="This is a test command",
536+ SlashCommand(callback=my_function, name="hello_world", description="This is a test command",
540537 options=[
541538 SlashOption(str, name="parameter", description="this is a parameter", choices=[{ "name": "choice 1", "value": 1 }])
542- ], guild_ids=[785567635802816595], default_permission=False,
543- guild_permissions={
544- 785567635802816595: SlashPermission(allowed={"539459006847254542": SlashPermission.USER})
539+ ], guild_ids=[785567635802816595], default_permission=False,
540+ guild_permissions={
541+ 785567635802816595: SlashPermission(allowed={"539459006847254542": SlashPermission.USER})
545542 })
546543 ```
547544 """
0 commit comments