Discord: fix voice command typing

This commit is contained in:
Shadow
2026-02-20 16:31:41 -06:00
parent 4ab946eebf
commit ab27d7b05a
3 changed files with 13 additions and 6 deletions

View File

@@ -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<APIApplicationCommandChannelOption["channel_types"]> = [
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",

View File

@@ -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,