Skip to content

Commit 0513a9e

Browse files
committed
Removed auto_convert since we don't need it anymore.
1 parent dc7ead8 commit 0513a9e

File tree

5 files changed

+15
-73
lines changed

5 files changed

+15
-73
lines changed

discord_slash/client.py

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ def add_slash_command(self,
339339
cmd,
340340
name: str = None,
341341
description: str = None,
342-
auto_convert: dict = None,
343342
guild_ids: typing.List[int] = None,
344343
options: list = None,
345344
has_subcommands: bool = False):
@@ -352,8 +351,6 @@ def add_slash_command(self,
352351
:type name: str
353352
:param description: Description of the slash command. Defaults to command docstring or ``None``.
354353
:type description: str
355-
:param auto_convert: Dictionary of how to convert option values. Default ``None``.
356-
:type auto_convert: dict
357354
:param guild_ids: List of Guild ID of where the command will be used. Default ``None``, which will be global command.
358355
:type guild_ids: List[int]
359356
:param options: Options of the slash command. This will affect ``auto_convert`` and command data at Discord API. Default ``None``.
@@ -377,13 +374,9 @@ def add_slash_command(self,
377374
if options is None:
378375
options = manage_commands.generate_options(cmd, description)
379376

380-
if options:
381-
auto_convert = manage_commands.generate_auto_convert(options)
382-
383377
_cmd = {
384378
"func": cmd,
385379
"description": description,
386-
"auto_convert": auto_convert,
387380
"guild_ids": guild_ids,
388381
"api_options": options,
389382
"has_subcommands": has_subcommands
@@ -399,7 +392,6 @@ def add_subcommand(self,
399392
description: str = None,
400393
base_description: str = None,
401394
subcommand_group_description: str = None,
402-
auto_convert: dict = None,
403395
guild_ids: typing.List[int] = None,
404396
options: list = None):
405397
"""
@@ -419,8 +411,6 @@ def add_subcommand(self,
419411
:type base_description: str
420412
:param subcommand_group_description: Description of the subcommand_group. Default ``None``.
421413
:type subcommand_group_description: str
422-
:param auto_convert: Dictionary of how to convert option values. Default ``None``.
423-
:type auto_convert: dict
424414
:param guild_ids: List of guild ID of where the command will be used. Default ``None``, which will be global command.
425415
:type guild_ids: List[int]
426416
:param options: Options of the subcommand. This will affect ``auto_convert`` and command data at Discord API. Default ``None``.
@@ -441,13 +431,9 @@ def add_subcommand(self,
441431
if options is None:
442432
options = manage_commands.generate_options(cmd, description)
443433

444-
if options:
445-
auto_convert = manage_commands.generate_auto_convert(options)
446-
447434
_cmd = {
448435
"func": None,
449436
"description": base_description,
450-
"auto_convert": {},
451437
"guild_ids": guild_ids,
452438
"api_options": [],
453439
"has_subcommands": True
@@ -458,7 +444,6 @@ def add_subcommand(self,
458444
"description": description,
459445
"base_desc": base_description,
460446
"sub_group_desc": subcommand_group_description,
461-
"auto_convert": auto_convert,
462447
"guild_ids": guild_ids,
463448
"api_options": options
464449
}
@@ -487,7 +472,6 @@ def slash(self,
487472
*,
488473
name: str = None,
489474
description: str = None,
490-
auto_convert: dict = None,
491475
guild_id: int = None,
492476
guild_ids: typing.List[int] = None,
493477
options: typing.List[dict] = None):
@@ -499,11 +483,11 @@ def slash(self,
499483
All args must be passed as keyword-args.
500484
501485
.. note::
502-
Role, User, and Channel types are passed as id if you don't set ``auto_convert``, since API doesn't give type of the option for now.\n
503-
Also, if ``options`` is passed, then ``auto_convert`` will be automatically created or overrided.
486+
If you don't pass `options` but has extra args, then it will automatically generate options.
487+
However, it is not recommended to use it since descriptions will be "No Description." or the command's description.
504488
505489
.. warning::
506-
Unlike discord.py's command, ``*args``, keyword-only args, converters, etc. are NOT supported.
490+
Unlike discord.py's command, ``*args``, keyword-only args, converters, etc. are not supported or behave differently.
507491
508492
Example:
509493
@@ -518,21 +502,10 @@ async def _slash(ctx): # Normal usage.
518502
async def _pick(ctx, choice1, choice2): # Command with 1 or more args.
519503
await ctx.send(content=str(random.choice([choice1, choice2])))
520504
521-
Example of formatting ``auto_convert``:
522-
523-
.. code-block:: python
524-
525-
{"option_role": "role", # For key put name of the option and for value put type of the option.
526-
"option_user": SlashCommandOptionType.USER, # Also can use an enumeration member for the type
527-
"option_user_two": 6, # or number
528-
"option_channel": "CHANNEL"} # or upper case string.
529-
530505
:param name: Name of the slash command. Default name of the coroutine.
531506
:type name: str
532507
:param description: Description of the slash command. Default ``None``.
533508
:type description: str
534-
:param auto_convert: Dictionary of how to convert option values. Default ``None``.
535-
:type auto_convert: dict
536509
:param guild_id: Deprecated. Use ``guild_ids`` instead.
537510
:type guild_id: int
538511
:param guild_ids: List of Guild ID of where the command will be used. Default ``None``, which will be global command.
@@ -545,7 +518,7 @@ async def _pick(ctx, choice1, choice2): # Command with 1 or more args.
545518
guild_ids = [guild_id]
546519

547520
def wrapper(cmd):
548-
self.add_slash_command(cmd, name, description, auto_convert, guild_ids, options)
521+
self.add_slash_command(cmd, name, description, guild_ids, options)
549522
return cmd
550523

551524
return wrapper
@@ -560,14 +533,20 @@ def subcommand(self,
560533
base_desc: str = None,
561534
subcommand_group_description: str = None,
562535
sub_group_desc: str = None,
563-
auto_convert: dict = None,
564536
guild_ids: typing.List[int] = None,
565537
options: typing.List[dict] = None):
566538
"""
567539
Decorator that registers subcommand.\n
568540
Unlike discord.py, you don't need base command.\n
569541
All args must be passed as keyword-args.
570542
543+
.. note::
544+
If you don't pass `options` but has extra args, then it will automatically generate options.
545+
However, it is not recommended to use it since descriptions will be "No Description." or the command's description.
546+
547+
.. warning::
548+
Unlike discord.py's command, ``*args``, keyword-only args, converters, etc. are not supported or behave differently.
549+
571550
Example:
572551
573552
.. code-block:: python
@@ -599,8 +578,6 @@ async def _group_kick_user(ctx, user):
599578
:param subcommand_group_description: Description of the subcommand_group. Default ``None``.
600579
:type subcommand_group_description: str
601580
:param sub_group_desc: Alias of ``subcommand_group_description``.
602-
:param auto_convert: Dictionary of how to convert option values. Default ``None``.
603-
:type auto_convert: dict
604581
:param guild_ids: List of guild ID of where the command will be used. Default ``None``, which will be global command.
605582
:type guild_ids: List[int]
606583
:param options: Options of the subcommand. This will affect ``auto_convert`` and command data at Discord API. Default ``None``.
@@ -610,7 +587,7 @@ async def _group_kick_user(ctx, user):
610587
subcommand_group_description = subcommand_group_description or sub_group_desc
611588

612589
def wrapper(cmd):
613-
self.add_subcommand(cmd, base, subcommand_group, name, description, base_description, subcommand_group_description, auto_convert, guild_ids, options)
590+
self.add_subcommand(cmd, base, subcommand_group, name, description, base_description, subcommand_group_description, guild_ids, options)
614591
return cmd
615592

616593
return wrapper

discord_slash/cog_ext.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
def cog_slash(*,
88
name: str = None,
99
description: str = None,
10-
auto_convert: dict = None,
1110
guild_ids: typing.List[int] = None,
1211
options: typing.List[dict] = None):
1312
"""
@@ -30,8 +29,6 @@ async def ping(self, ctx: SlashContext):
3029
:type name: str
3130
:param description: Description of the slash command. Default ``None``.
3231
:type description: str
33-
:param auto_convert: Dictionary of how to convert option values. Default ``None``.
34-
:type auto_convert: dict
3532
:param guild_ids: List of Guild ID of where the command will be used. Default ``None``, which will be global command.
3633
:type guild_ids: List[int]
3734
:param options: Options of the slash command. This will affect ``auto_convert`` and command data at Discord API. Default ``None``.
@@ -44,15 +41,9 @@ def wrapper(cmd):
4441
else:
4542
opts = options
4643

47-
if opts:
48-
auto_conv = manage_commands.generate_auto_convert(opts)
49-
else:
50-
auto_conv = auto_convert
51-
5244
_cmd = {
5345
"func": cmd,
5446
"description": desc,
55-
"auto_convert": auto_conv,
5647
"guild_ids": guild_ids,
5748
"api_options": opts,
5849
"has_subcommands": False
@@ -70,7 +61,6 @@ def cog_subcommand(*,
7061
base_desc: str = None,
7162
subcommand_group_description: str = None,
7263
sub_group_desc: str = None,
73-
auto_convert: dict = None,
7464
guild_ids: typing.List[int] = None,
7565
options: typing.List[dict] = None):
7666
"""
@@ -103,8 +93,6 @@ async def group_say(self, ctx: SlashContext, text: str):
10393
:param subcommand_group_description: Description of the subcommand_group. Default ``None``.
10494
:type subcommand_group_description: str
10595
:param sub_group_desc: Alias of ``subcommand_group_description``.
106-
:param auto_convert: Dictionary of how to convert option values. Default ``None``.
107-
:type auto_convert: dict
10896
:param guild_ids: List of guild ID of where the command will be used. Default ``None``, which will be global command.
10997
:type guild_ids: List[int]
11098
:param options: Options of the subcommand. This will affect ``auto_convert`` and command data at Discord API. Default ``None``.
@@ -120,18 +108,12 @@ def wrapper(cmd):
120108
else:
121109
opts = options
122110

123-
if opts:
124-
auto_conv = manage_commands.generate_auto_convert(opts)
125-
else:
126-
auto_conv = auto_convert
127-
128111
_sub = {
129112
"func": cmd,
130113
"name": name or cmd.__name__,
131114
"description": desc,
132115
"base_desc": base_description,
133116
"sub_group_desc": subcommand_group_description,
134-
"auto_convert": auto_conv,
135117
"guild_ids": guild_ids,
136118
"api_options": opts
137119
}

discord_slash/model.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class CommandObject:
1717
:ivar name: Name of the command.
1818
:ivar func: The coroutine of the command.
1919
:ivar description: Description of the command.
20-
:ivar auto_convert: Dictionary of the `auto_convert` of the command.
2120
:ivar allowed_guild_ids: List of the allowed guild id.
2221
:ivar options: List of the option of the command. Used for `auto_register`.
2322
:ivar __commands_checks__: Check of the command.
@@ -26,7 +25,6 @@ def __init__(self, name, cmd): # Let's reuse old command formatting.
2625
self.name = name.lower()
2726
self.func = cmd["func"]
2827
self.description = cmd["description"]
29-
self.auto_convert = cmd["auto_convert"] or {}
3028
self.allowed_guild_ids = cmd["guild_ids"] or []
3129
self.options = cmd["api_options"] or []
3230
self.has_subcommands = cmd["has_subcommands"]

discord_slash/utils/manage_commands.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -207,24 +207,6 @@ def generate_options(function: Callable, description: str = "No description.") -
207207
return options
208208

209209

210-
def generate_auto_convert(options: list) -> dict:
211-
"""
212-
Generate an auto_convert dict from command options.
213-
214-
.. note::
215-
This is automatically used if you pass options.
216-
217-
:param options: The list of options.
218-
"""
219-
auto_convert = {}
220-
for x in options:
221-
if x["type"] in (SlashCommandOptionType.SUB_COMMAND, SlashCommandOptionType.SUB_COMMAND_GROUP):
222-
raise Exception("You can't use subcommand or subcommand_group type!")
223-
auto_convert[x["name"]] = x["type"]
224-
225-
return auto_convert
226-
227-
228210
def create_choice(value: str, name: str):
229211
"""
230212
Creates choices used for creating command option.

docs/migrate_to_109.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,7 @@ Note that removing `if not hasattr(...):` block then moving to main file like th
104104
# No worries for not doing `bot.slash` because its automatically added now.
105105
...
106106
107+
Auto-convert
108+
------------
107109

110+
It got deleted, so please remove all of it if you used it.

0 commit comments

Comments
 (0)