Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions interactions/models/internal/application_commands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
from collections import defaultdict
import inspect
import re
import typing
Expand Down Expand Up @@ -1466,9 +1467,9 @@ def application_commands_to_dict( # noqa: C901
`Client.interactions` should be the variable passed to this

"""
cmd_bases = {} # {cmd_base: [commands]}
cmd_bases: defaultdict[str, list[InteractionCommand]] = defaultdict(list) # {cmd_base: [commands]}
"""A store of commands organised by their base command"""
output = {}
output: defaultdict["Snowflake_Type", list[dict]] = defaultdict(list)
"""The output dictionary"""

def squash_subcommand(subcommands: List) -> Dict:
Expand Down Expand Up @@ -1514,9 +1515,6 @@ def squash_subcommand(subcommands: List) -> Dict:
for _scope, cmds in commands.items():
for cmd in cmds.values():
cmd_name = str(cmd.name)
if cmd_name not in cmd_bases:
cmd_bases[cmd_name] = [cmd]
continue
if cmd not in cmd_bases[cmd_name]:
cmd_bases[cmd_name].append(cmd)

Expand Down Expand Up @@ -1556,15 +1554,14 @@ def squash_subcommand(subcommands: List) -> Dict:
cmd.nsfw = nsfw
# end validation of attributes
cmd_data = squash_subcommand(cmd_list)

for s in scopes:
output[s].append(cmd_data)
else:
scopes = cmd_list[0].scopes
cmd_data = cmd_list[0].to_dict()
for s in scopes:
if s not in output:
output[s] = [cmd_data]
continue
output[s].append(cmd_data)
return output
for cmd in cmd_list:
for s in cmd.scopes:
output[s].append(cmd.to_dict())
return dict(output)


def _compare_commands(local_cmd: dict, remote_cmd: dict) -> bool:
Expand Down