mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-21 16:41:56 +00:00
fix(discord): avoid invalid /acp native option payload
This commit is contained in:
@@ -320,8 +320,7 @@ function buildChatCommands(): ChatCommandDefinition[] {
|
||||
args: [
|
||||
{
|
||||
name: "action",
|
||||
description:
|
||||
"spawn | cancel | steer | close | sessions | status | set-mode | set | cwd | permissions | timeout | model | reset-options | doctor | install | help",
|
||||
description: "Action to run",
|
||||
type: "string",
|
||||
choices: [
|
||||
"spawn",
|
||||
|
||||
@@ -109,6 +109,23 @@ describe("commands registry", () => {
|
||||
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", () => {
|
||||
const acp = listChatCommands().find((command) => command.key === "acp");
|
||||
expect(acp).toBeTruthy();
|
||||
|
||||
Reference in New Issue
Block a user