mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:21:35 +00:00
fix(discord): avoid invalid /acp native option payload
This commit is contained in:
@@ -320,8 +320,7 @@ function buildChatCommands(): ChatCommandDefinition[] {
|
|||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
name: "action",
|
name: "action",
|
||||||
description:
|
description: "Action to run",
|
||||||
"spawn | cancel | steer | close | sessions | status | set-mode | set | cwd | permissions | timeout | model | reset-options | doctor | install | help",
|
|
||||||
type: "string",
|
type: "string",
|
||||||
choices: [
|
choices: [
|
||||||
"spawn",
|
"spawn",
|
||||||
|
|||||||
@@ -109,6 +109,23 @@ describe("commands registry", () => {
|
|||||||
expect(findCommandByNativeName("tts", "discord")).toBeUndefined();
|
expect(findCommandByNativeName("tts", "discord")).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("keeps discord native command specs within slash-command limits", () => {
|
||||||
|
const native = listNativeCommandSpecsForConfig(
|
||||||
|
{ commands: { native: true } },
|
||||||
|
{ provider: "discord" },
|
||||||
|
);
|
||||||
|
for (const spec of native) {
|
||||||
|
expect(spec.name).toMatch(/^[a-z0-9_-]{1,32}$/);
|
||||||
|
expect(spec.description.length).toBeGreaterThan(0);
|
||||||
|
expect(spec.description.length).toBeLessThanOrEqual(100);
|
||||||
|
for (const arg of spec.args ?? []) {
|
||||||
|
expect(arg.name).toMatch(/^[a-z0-9_-]{1,32}$/);
|
||||||
|
expect(arg.description.length).toBeGreaterThan(0);
|
||||||
|
expect(arg.description.length).toBeLessThanOrEqual(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it("keeps ACP native action choices aligned with implemented handlers", () => {
|
it("keeps ACP native action choices aligned with implemented handlers", () => {
|
||||||
const acp = listChatCommands().find((command) => command.key === "acp");
|
const acp = listChatCommands().find((command) => command.key === "acp");
|
||||||
expect(acp).toBeTruthy();
|
expect(acp).toBeTruthy();
|
||||||
|
|||||||
Reference in New Issue
Block a user