From ab27d7b05abb28fb8d13f4d98d96bc12759f3778 Mon Sep 17 00:00:00 2001 From: Shadow Date: Fri, 20 Feb 2026 16:31:41 -0600 Subject: [PATCH] Discord: fix voice command typing --- src/discord/monitor/provider.ts | 8 ++++++-- src/discord/voice/command.ts | 6 ++++-- src/discord/voice/manager.ts | 5 +++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/discord/monitor/provider.ts b/src/discord/monitor/provider.ts index e0cf1d956..3a44da898 100644 --- a/src/discord/monitor/provider.ts +++ b/src/discord/monitor/provider.ts @@ -2,8 +2,10 @@ import { inspect } from "node:util"; import { Client, ReadyListener, + type BaseCommand, type BaseMessageInteractiveComponent, type Modal, + type Plugin, } from "@buape/carbon"; import { GatewayCloseCodes, type GatewayPlugin } from "@buape/carbon/gateway"; import { VoicePlugin } from "@buape/carbon/voice"; @@ -433,7 +435,7 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) { ); } const voiceManagerRef: { current: DiscordVoiceManager | null } = { current: null }; - const commands = commandSpecs.map((spec) => + const commands: BaseCommand[] = commandSpecs.map((spec) => createDiscordNativeCommand({ command: spec, cfg, @@ -524,7 +526,9 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) { } } - const clientPlugins = [createDiscordGatewayPlugin({ discordConfig: discordCfg, runtime })]; + const clientPlugins: Plugin[] = [ + createDiscordGatewayPlugin({ discordConfig: discordCfg, runtime }), + ]; if (voiceEnabled) { clientPlugins.push(new VoicePlugin()); } diff --git a/src/discord/voice/command.ts b/src/discord/voice/command.ts index d62151ccb..dabfff10f 100644 --- a/src/discord/voice/command.ts +++ b/src/discord/voice/command.ts @@ -3,10 +3,12 @@ import { Command, CommandWithSubcommands, type CommandInteraction, + type CommandOptions, } from "@buape/carbon"; import { ApplicationCommandOptionType, ChannelType as DiscordChannelType, + type APIApplicationCommandChannelOption, } from "discord-api-types/v10"; import { resolveCommandAuthorizedFromAuthorizers } from "../../channels/command-gating.js"; import type { OpenClawConfig } from "../../config/config.js"; @@ -25,7 +27,7 @@ import { resolveDiscordSenderIdentity } from "../monitor/sender-identity.js"; import { resolveDiscordThreadParentInfo } from "../monitor/threading.js"; import type { DiscordVoiceManager } from "./manager.js"; -const VOICE_CHANNEL_TYPES: DiscordChannelType[] = [ +const VOICE_CHANNEL_TYPES: NonNullable = [ DiscordChannelType.GuildVoice, DiscordChannelType.GuildStageVoice, ]; @@ -192,7 +194,7 @@ export function createDiscordVoiceCommand(params: VoiceCommandContext): CommandW description = "Join a voice channel"; defer = true; ephemeral = params.ephemeralDefault; - options = [ + options: CommandOptions = [ { name: "channel", description: "Voice channel to join", diff --git a/src/discord/voice/manager.ts b/src/discord/voice/manager.ts index 02849c40b..ff048d7ac 100644 --- a/src/discord/voice/manager.ts +++ b/src/discord/voice/manager.ts @@ -620,15 +620,16 @@ export class DiscordVoiceManager { logger.warn(`discord voice: TTS failed: ${ttsResult.error ?? "unknown error"}`); return; } + const audioPath = ttsResult.audioPath; logVoiceVerbose( `tts ok (${speakText.length} chars): guild ${entry.guildId} channel ${entry.channelId}`, ); this.enqueuePlayback(entry, async () => { logVoiceVerbose( - `playback start: guild ${entry.guildId} channel ${entry.channelId} file ${path.basename(ttsResult.audioPath)}`, + `playback start: guild ${entry.guildId} channel ${entry.channelId} file ${path.basename(audioPath)}`, ); - const resource = createAudioResource(ttsResult.audioPath); + const resource = createAudioResource(audioPath); entry.player.play(resource); await entersState(entry.player, AudioPlayerStatus.Playing, PLAYBACK_READY_TIMEOUT_MS).catch( () => undefined,