|
1 | 1 | import asyncio |
| 2 | +from collections import defaultdict |
2 | 3 | import inspect |
3 | 4 | import re |
4 | 5 | import typing |
@@ -288,6 +289,8 @@ def _dm_permission_validator(self, attribute: str, value: bool) -> None: |
288 | 289 | def to_dict(self) -> dict: |
289 | 290 | data = super().to_dict() |
290 | 291 |
|
| 292 | + data["name_localizations"] = self.name.to_locale_dict() |
| 293 | + |
291 | 294 | if self.default_member_permissions is not None: |
292 | 295 | data["default_member_permissions"] = str(int(self.default_member_permissions)) |
293 | 296 | else: |
@@ -1466,9 +1469,9 @@ def application_commands_to_dict( # noqa: C901 |
1466 | 1469 | `Client.interactions` should be the variable passed to this |
1467 | 1470 |
|
1468 | 1471 | """ |
1469 | | - cmd_bases = {} # {cmd_base: [commands]} |
| 1472 | + cmd_bases: defaultdict[str, list[InteractionCommand]] = defaultdict(list) # {cmd_base: [commands]} |
1470 | 1473 | """A store of commands organised by their base command""" |
1471 | | - output = {} |
| 1474 | + output: defaultdict["Snowflake_Type", list[dict]] = defaultdict(list) |
1472 | 1475 | """The output dictionary""" |
1473 | 1476 |
|
1474 | 1477 | def squash_subcommand(subcommands: List) -> Dict: |
@@ -1514,9 +1517,6 @@ def squash_subcommand(subcommands: List) -> Dict: |
1514 | 1517 | for _scope, cmds in commands.items(): |
1515 | 1518 | for cmd in cmds.values(): |
1516 | 1519 | cmd_name = str(cmd.name) |
1517 | | - if cmd_name not in cmd_bases: |
1518 | | - cmd_bases[cmd_name] = [cmd] |
1519 | | - continue |
1520 | 1520 | if cmd not in cmd_bases[cmd_name]: |
1521 | 1521 | cmd_bases[cmd_name].append(cmd) |
1522 | 1522 |
|
@@ -1556,15 +1556,14 @@ def squash_subcommand(subcommands: List) -> Dict: |
1556 | 1556 | cmd.nsfw = nsfw |
1557 | 1557 | # end validation of attributes |
1558 | 1558 | cmd_data = squash_subcommand(cmd_list) |
| 1559 | + |
| 1560 | + for s in scopes: |
| 1561 | + output[s].append(cmd_data) |
1559 | 1562 | else: |
1560 | | - scopes = cmd_list[0].scopes |
1561 | | - cmd_data = cmd_list[0].to_dict() |
1562 | | - for s in scopes: |
1563 | | - if s not in output: |
1564 | | - output[s] = [cmd_data] |
1565 | | - continue |
1566 | | - output[s].append(cmd_data) |
1567 | | - return output |
| 1563 | + for cmd in cmd_list: |
| 1564 | + for s in cmd.scopes: |
| 1565 | + output[s].append(cmd.to_dict()) |
| 1566 | + return dict(output) |
1568 | 1567 |
|
1569 | 1568 |
|
1570 | 1569 | def _compare_commands(local_cmd: dict, remote_cmd: dict) -> bool: |
|
0 commit comments