mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
fix(discord): avoid native plugin command collisions
This commit is contained in:
@@ -77,12 +77,20 @@ function asTrimmedString(value: unknown): string {
|
||||
return typeof value === "string" ? value.trim() : "";
|
||||
}
|
||||
|
||||
function resolveCommandLabel(channel: string): string {
|
||||
return channel === "discord" ? "/talkvoice" : "/voice";
|
||||
}
|
||||
|
||||
export default function register(api: OpenClawPluginApi) {
|
||||
api.registerCommand({
|
||||
name: "voice",
|
||||
nativeNames: {
|
||||
discord: "talkvoice",
|
||||
},
|
||||
description: "List/set ElevenLabs Talk voice (affects iOS Talk playback).",
|
||||
acceptsArgs: true,
|
||||
handler: async (ctx) => {
|
||||
const commandLabel = resolveCommandLabel(ctx.channel);
|
||||
const args = ctx.args?.trim() ?? "";
|
||||
const tokens = args.split(/\s+/).filter(Boolean);
|
||||
const action = (tokens[0] ?? "status").toLowerCase();
|
||||
@@ -118,13 +126,13 @@ export default function register(api: OpenClawPluginApi) {
|
||||
if (action === "set") {
|
||||
const query = tokens.slice(1).join(" ").trim();
|
||||
if (!query) {
|
||||
return { text: "Usage: /voice set <voiceId|name>" };
|
||||
return { text: `Usage: ${commandLabel} set <voiceId|name>` };
|
||||
}
|
||||
const voices = await listVoices(apiKey);
|
||||
const chosen = findVoice(voices, query);
|
||||
if (!chosen) {
|
||||
const hint = isLikelyVoiceId(query) ? query : `"${query}"`;
|
||||
return { text: `No voice found for ${hint}. Try: /voice list` };
|
||||
return { text: `No voice found for ${hint}. Try: ${commandLabel} list` };
|
||||
}
|
||||
|
||||
const nextConfig = {
|
||||
@@ -144,9 +152,9 @@ export default function register(api: OpenClawPluginApi) {
|
||||
text: [
|
||||
"Voice commands:",
|
||||
"",
|
||||
"/voice status",
|
||||
"/voice list [limit]",
|
||||
"/voice set <voiceId|name>",
|
||||
`${commandLabel} status`,
|
||||
`${commandLabel} list [limit]`,
|
||||
`${commandLabel} set <voiceId|name>`,
|
||||
].join("\n"),
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user