Skip to content

Commit c6c22b9

Browse files
committed
fix: fix debug ext functions
1 parent 04f4a23 commit c6c22b9

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

interactions/client/client.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,12 +1598,14 @@ def get_application_cmd_by_id(
15981598
The command, if one with the given ID exists internally, otherwise None
15991599
16001600
"""
1601+
cmd_id = to_snowflake(cmd_id)
1602+
scope = to_snowflake(scope) if scope is not None else None
1603+
16011604
if scope is not None:
1602-
return self.interactions_by_scope.get(scope, {}).get(cmd_id)
1603-
return next(
1604-
(scope[cmd_id] for scope in self.interactions_by_scope.values() if cmd_id in scope),
1605-
None,
1606-
)
1605+
return next(
1606+
(cmd for cmd in self.interactions_by_scope[scope].values() if cmd.get_cmd_id(scope) == cmd_id), None
1607+
)
1608+
return next(cmd for cmd in self._interaction_lookup.values() if cmd_id in cmd.cmd_id.values())
16071609

16081610
def _raise_sync_exception(self, e: HTTPException, cmds_json: dict, cmd_scope: "Snowflake_Type") -> NoReturn:
16091611
try:
@@ -1701,6 +1703,10 @@ async def _dispatch_interaction(self, event: RawGatewayEvent) -> None: # noqa:
17011703
"""
17021704
interaction_data = event.data
17031705

1706+
if not self._startup:
1707+
self.logger.warning("Received interaction before startup completed, ignoring")
1708+
return
1709+
17041710
if interaction_data["type"] in (
17051711
InteractionType.APPLICATION_COMMAND,
17061712
InteractionType.AUTOCOMPLETE,

interactions/ext/debug_extension/debug_application_cmd.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,11 @@ async def send(cmd_json: dict) -> None:
9696
)
9797

9898
if not remote:
99-
data = application_commands_to_dict(self.bot.interactions, self.bot)[scope]
99+
data = application_commands_to_dict(self.bot.interactions_by_scope, self.bot)[scope]
100100
cmd_obj = self.bot.get_application_cmd_by_id(cmd_id)
101-
for cmd in data:
102-
if cmd["name"] == cmd_obj.name:
103-
return await send(cmd)
104-
101+
cmd_data = next((c for c in data if c["name"] == str(cmd_obj.name)), None)
102+
if cmd_data:
103+
return await send(cmd_data)
105104
else:
106105
data = await self.bot.http.get_application_commands(self.bot.app.id, scope)
107106
try:

interactions/ext/debug_extension/debug_exec.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,13 @@ async def debug_exec(self, ctx: InteractionContext) -> Optional[Message]:
4343
} | globals()
4444

4545
modal = Modal(
46+
ParagraphText(
47+
label="Code to run",
48+
value=last_code,
49+
custom_id="body",
50+
placeholder="Write your code here!",
51+
),
4652
title="Debug-Exec",
47-
components=[
48-
ParagraphText(
49-
label="Code to run",
50-
value=last_code,
51-
custom_id="body",
52-
placeholder="Write your code here!",
53-
)
54-
],
5553
)
5654
await ctx.send_modal(modal)
5755

0 commit comments

Comments
 (0)