|
63 | 63 | from .shard import AutoShardedClient |
64 | 64 | from .types import interactions |
65 | 65 | from .user import User |
66 | | -from .utils import MISSING, async_all, find, get |
| 66 | +from .utils import MISSING, find |
| 67 | +from .utils.private import async_all |
67 | 68 |
|
68 | 69 | if TYPE_CHECKING: |
69 | 70 | from .member import Member |
@@ -216,13 +217,13 @@ def get_application_command( |
216 | 217 | return command |
217 | 218 | elif (names := name.split())[0] == command.name and isinstance(command, SlashCommandGroup): |
218 | 219 | while len(names) > 1: |
219 | | - command = get(commands, name=names.pop(0)) |
| 220 | + command = find(lambda c: c.name == names.pop(0), commands) |
220 | 221 | if not isinstance(command, SlashCommandGroup) or ( |
221 | 222 | guild_ids is not None and command.guild_ids != guild_ids |
222 | 223 | ): |
223 | 224 | return |
224 | 225 | commands = command.subcommands |
225 | | - command = get(commands, name=names.pop()) |
| 226 | + command = find(lambda c: c.name == names.pop(), commands) |
226 | 227 | if not isinstance(command, type) or (guild_ids is not None and command.guild_ids != guild_ids): |
227 | 228 | return |
228 | 229 | return command |
@@ -357,7 +358,7 @@ def _check_command(cmd: ApplicationCommand, match: Mapping[str, Any]) -> bool: |
357 | 358 |
|
358 | 359 | # Now let's see if there are any commands on discord that we need to delete |
359 | 360 | for cmd, value_ in registered_commands_dict.items(): |
360 | | - match = get(pending, name=value_["name"]) |
| 361 | + match = find(lambda c: c.name == value_["name"], pending) |
361 | 362 | if match is None: |
362 | 363 | # We have this command registered but not in our list |
363 | 364 | return_value.append( |
@@ -516,7 +517,7 @@ def register( |
516 | 517 | ) |
517 | 518 | continue |
518 | 519 | # We can assume the command item is a command, since it's only a string if action is delete |
519 | | - match = get(pending, name=cmd["command"].name, type=cmd["command"].type) |
| 520 | + match = find(lambda c: c.name == cmd["command"].name and c.type == cmd["command"].type, pending) |
520 | 521 | if match is None: |
521 | 522 | continue |
522 | 523 | if cmd["action"] == "edit": |
@@ -605,10 +606,9 @@ def register( |
605 | 606 | registered = await register("bulk", data, guild_id=guild_id) |
606 | 607 |
|
607 | 608 | for i in registered: |
608 | | - cmd = get( |
| 609 | + cmd = find( |
| 610 | + lambda c: c.name == i["name"] and c.type == i.get("type"), |
609 | 611 | self.pending_application_commands, |
610 | | - name=i["name"], |
611 | | - type=i.get("type"), |
612 | 612 | ) |
613 | 613 | if not cmd: |
614 | 614 | raise ValueError(f"Registered command {i['name']}, type {i.get('type')} not found in pending commands") |
@@ -712,11 +712,9 @@ async def on_connect(): |
712 | 712 | registered_guild_commands[guild_id] = app_cmds |
713 | 713 |
|
714 | 714 | for i in registered_commands: |
715 | | - cmd = get( |
| 715 | + cmd = find( |
| 716 | + lambda c: c.name == i["name"] and c.guild_ids is None and c.type == i.get("type"), |
716 | 717 | self.pending_application_commands, |
717 | | - name=i["name"], |
718 | | - guild_ids=None, |
719 | | - type=i.get("type"), |
720 | 718 | ) |
721 | 719 | if cmd: |
722 | 720 | cmd.id = i["id"] |
|
0 commit comments