mirror of https://github.com/openclaw/openclaw.git
Discord: resolve bind approvals in-place
This commit is contained in:
parent
1a188ffb87
commit
b334cf63f5
|
|
@ -168,10 +168,11 @@ async function dispatchPluginDiscordInteractiveEvent(params: {
|
|||
decision: pluginBindingApproval.decision,
|
||||
senderId: params.interactionCtx.userId,
|
||||
});
|
||||
let cleared = false;
|
||||
try {
|
||||
await respond.clearComponents();
|
||||
cleared = true;
|
||||
await respond.clearComponents({
|
||||
text: buildPluginBindingResolvedText(resolved),
|
||||
});
|
||||
return "handled";
|
||||
} catch {
|
||||
try {
|
||||
await respond.acknowledge();
|
||||
|
|
@ -180,21 +181,19 @@ async function dispatchPluginDiscordInteractiveEvent(params: {
|
|||
}
|
||||
}
|
||||
try {
|
||||
await respond.followUp({
|
||||
await respond.reply({
|
||||
text: buildPluginBindingResolvedText(resolved),
|
||||
ephemeral: true,
|
||||
});
|
||||
} catch (err) {
|
||||
logError(`discord plugin binding approval: failed to follow up: ${String(err)}`);
|
||||
if (!cleared) {
|
||||
try {
|
||||
await respond.reply({
|
||||
text: buildPluginBindingResolvedText(resolved),
|
||||
ephemeral: true,
|
||||
});
|
||||
} catch {
|
||||
// Interaction may no longer accept a direct reply.
|
||||
}
|
||||
logError(`discord plugin binding approval: failed to reply: ${String(err)}`);
|
||||
try {
|
||||
await respond.followUp({
|
||||
text: buildPluginBindingResolvedText(resolved),
|
||||
ephemeral: true,
|
||||
});
|
||||
} catch {
|
||||
// Interaction may no longer accept a follow-up.
|
||||
}
|
||||
}
|
||||
return "handled";
|
||||
|
|
|
|||
|
|
@ -918,11 +918,13 @@ describe("discord component interactions", () => {
|
|||
|
||||
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
||||
|
||||
expect(update).toHaveBeenCalledWith({ components: [] });
|
||||
expect(followUp).toHaveBeenCalledWith({
|
||||
content: expect.stringContaining("bind approval"),
|
||||
ephemeral: true,
|
||||
});
|
||||
expect(update).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
content: expect.any(String),
|
||||
components: [],
|
||||
}),
|
||||
);
|
||||
expect(followUp).not.toHaveBeenCalled();
|
||||
expect(dispatchReplyMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue