diff --git a/packages/client-discord/src/actions/joinvoice.ts b/packages/client-discord/src/actions/joinvoice.ts index dbfa556482e..71c879712af 100644 --- a/packages/client-discord/src/actions/joinvoice.ts +++ b/packages/client-discord/src/actions/joinvoice.ts @@ -8,6 +8,8 @@ import { IAgentRuntime, Memory, State, + generateText, + ModelClass, } from "@elizaos/core"; import { Channel, @@ -17,6 +19,7 @@ import { Guild, GuildMember, } from "discord.js"; +import { joinVoiceChannel } from "@discordjs/voice"; export default { name: "JOIN_VOICE", @@ -66,12 +69,7 @@ export default { return false; } - const client = state.discordClient as Client; - - // Check if the client is connected to any voice channel - const isConnectedToVoice = client.voice.adapters.size === 0; - - return isConnectedToVoice; + return true; }, description: "Join a voice channel to participate in voice chat.", handler: async ( @@ -115,31 +113,30 @@ export default { ); }); - if (!state.voiceManager) { - state.voiceManager = new VoiceManager({ - client: state.discordClient, - runtime: runtime, - }); - } - if (targetChannel) { - state.voiceManager.joinVoiceChannel({ + joinVoiceChannel({ channelId: targetChannel.id, guildId: (discordMessage as DiscordMessage).guild?.id as string, adapterCreator: (client.guilds.cache.get(id) as Guild) .voiceAdapterCreator, + selfDeaf: false, + selfMute: false, + group: client.user.id, }); return true; } else { const member = (discordMessage as DiscordMessage) .member as GuildMember; if (member?.voice?.channel) { - state.voiceManager.joinVoiceChannel({ + joinVoiceChannel({ channelId: member.voice.channel.id, guildId: (discordMessage as DiscordMessage).guild ?.id as string, adapterCreator: (client.guilds.cache.get(id) as Guild) .voiceAdapterCreator, + selfDeaf: false, + selfMute: false, + group: client.user.id, }); return true; } @@ -204,12 +201,15 @@ You should only respond with the name of the voice channel or none, no commentar }); if (targetChannel) { - state.voiceManager.joinVoiceChannel({ + joinVoiceChannel({ channelId: targetChannel.id, guildId: (discordMessage as DiscordMessage).guild ?.id as string, adapterCreator: (client.guilds.cache.get(id) as Guild) .voiceAdapterCreator, + selfDeaf: false, + selfMute: false, + group: client.user.id, }); return true; }