Skip to content

Commit f80b1ad

Browse files
committed
Fixed problems with subcommand auto-registering
1 parent 4907643 commit f80b1ad

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

discord_slash/client.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,20 @@ def remove_cog_commands(self, cog):
143143

144144
async def register_all_commands(self):
145145
"""
146-
Registers all slash commands except subcommands to Discord API.\n
146+
Registers all slash commands to Discord API.\n
147147
If ``auto_register`` is ``True``, then this will be automatically called.
148148
"""
149149
await self._discord.wait_until_ready() # In case commands are still not registered to SlashCommand.
150150
self.logger.info("Registering commands...")
151151
for x in self.commands.keys():
152152
selected = self.commands[x]
153-
if selected.has_subcommands and hasattr(selected, "invoke"):
153+
if selected.has_subcommands and selected.func:
154154
# Registering both subcommand and command with same base name / name
155-
# will result in only one type of command being registered,
156-
# so we will only register subcommands.
157-
self.logger.warning(f"Detected command name with same subcommand base name! Skipping registering this command: {x}")
158-
continue
159-
if selected.has_subcommands and not hasattr(selected, "invoke"):
155+
# will result in only subcommand being registered,
156+
# so we will warn this at registering subcommands.
157+
self.logger.warning(f"Detected command name with same subcommand base name! "
158+
f"This command will only have subcommand: {x}")
159+
if selected.has_subcommands:
160160
tgt = self.subcommands[x]
161161
options = []
162162
for y in tgt.keys():
@@ -171,7 +171,7 @@ async def register_all_commands(self):
171171
options.append(_dict)
172172
else:
173173
base_dict = {
174-
"name": sub.subcommand_group,
174+
"name": y,
175175
"description": "No Description.",
176176
"type": 2,
177177
"options": []
@@ -344,7 +344,7 @@ def add_subcommand(self,
344344
name = name.lower()
345345
_cmd = {
346346
"func": None,
347-
"description": "No description.",
347+
"description": base_desc,
348348
"auto_convert": {},
349349
"guild_ids": guild_ids,
350350
"api_options": [],
@@ -517,7 +517,7 @@ async def _group_kick_user(ctx, user):
517517
auto_convert[x["name"]] = x["type"]
518518

519519
def wrapper(cmd):
520-
self.add_subcommand(cmd, base, subcommand_group, sub_group_desc, name, description, auto_convert, guild_ids, options)
520+
self.add_subcommand(cmd, base, subcommand_group, name, description, base_desc, sub_group_desc, auto_convert, guild_ids, options)
521521
return cmd
522522

523523
return wrapper

0 commit comments

Comments
 (0)