From 94127a0af22077b4675b30cebd4d99f2f3410290 Mon Sep 17 00:00:00 2001 From: Ting Chien Meng Date: Sat, 11 Jan 2025 14:12:54 -0500 Subject: [PATCH 1/2] fix join voice channel --- .../client-discord/src/actions/joinvoice.ts | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/packages/client-discord/src/actions/joinvoice.ts b/packages/client-discord/src/actions/joinvoice.ts index dbfa556482..8e4813e948 100644 --- a/packages/client-discord/src/actions/joinvoice.ts +++ b/packages/client-discord/src/actions/joinvoice.ts @@ -17,6 +17,7 @@ import { Guild, GuildMember, } from "discord.js"; +import { joinVoiceChannel } from "@discordjs/voice"; export default { name: "JOIN_VOICE", @@ -66,12 +67,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,15 +111,8 @@ 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) @@ -134,7 +123,7 @@ export default { 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, @@ -204,7 +193,7 @@ 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, From 4a267eb83075fcec726a49c2478c66d956f22d17 Mon Sep 17 00:00:00 2001 From: Ting Chien Meng Date: Sat, 11 Jan 2025 15:30:29 -0500 Subject: [PATCH 2/2] add missing function and parameters --- packages/client-discord/src/actions/joinvoice.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/client-discord/src/actions/joinvoice.ts b/packages/client-discord/src/actions/joinvoice.ts index 8e4813e948..71c879712a 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, @@ -117,6 +119,9 @@ export default { 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 { @@ -129,6 +134,9 @@ export default { ?.id as string, adapterCreator: (client.guilds.cache.get(id) as Guild) .voiceAdapterCreator, + selfDeaf: false, + selfMute: false, + group: client.user.id, }); return true; } @@ -199,6 +207,9 @@ You should only respond with the name of the voice channel or none, no commentar ?.id as string, adapterCreator: (client.guilds.cache.get(id) as Guild) .voiceAdapterCreator, + selfDeaf: false, + selfMute: false, + group: client.user.id, }); return true; }