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