Skip to content

Commit b0e665e

Browse files
authored
Merge pull request #2160 from elizaOS/tcm-join-voice
fix: fix client-discord join voice action
2 parents 0bdafda + 4a267eb commit b0e665e

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

packages/client-discord/src/actions/joinvoice.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
IAgentRuntime,
99
Memory,
1010
State,
11+
generateText,
12+
ModelClass,
1113
} from "@elizaos/core";
1214
import {
1315
Channel,
@@ -17,6 +19,7 @@ import {
1719
Guild,
1820
GuildMember,
1921
} from "discord.js";
22+
import { joinVoiceChannel } from "@discordjs/voice";
2023

2124
export default {
2225
name: "JOIN_VOICE",
@@ -66,12 +69,7 @@ export default {
6669
return false;
6770
}
6871

69-
const client = state.discordClient as Client;
70-
71-
// Check if the client is connected to any voice channel
72-
const isConnectedToVoice = client.voice.adapters.size === 0;
73-
74-
return isConnectedToVoice;
72+
return true;
7573
},
7674
description: "Join a voice channel to participate in voice chat.",
7775
handler: async (
@@ -115,31 +113,30 @@ export default {
115113
);
116114
});
117115

118-
if (!state.voiceManager) {
119-
state.voiceManager = new VoiceManager({
120-
client: state.discordClient,
121-
runtime: runtime,
122-
});
123-
}
124-
125116
if (targetChannel) {
126-
state.voiceManager.joinVoiceChannel({
117+
joinVoiceChannel({
127118
channelId: targetChannel.id,
128119
guildId: (discordMessage as DiscordMessage).guild?.id as string,
129120
adapterCreator: (client.guilds.cache.get(id) as Guild)
130121
.voiceAdapterCreator,
122+
selfDeaf: false,
123+
selfMute: false,
124+
group: client.user.id,
131125
});
132126
return true;
133127
} else {
134128
const member = (discordMessage as DiscordMessage)
135129
.member as GuildMember;
136130
if (member?.voice?.channel) {
137-
state.voiceManager.joinVoiceChannel({
131+
joinVoiceChannel({
138132
channelId: member.voice.channel.id,
139133
guildId: (discordMessage as DiscordMessage).guild
140134
?.id as string,
141135
adapterCreator: (client.guilds.cache.get(id) as Guild)
142136
.voiceAdapterCreator,
137+
selfDeaf: false,
138+
selfMute: false,
139+
group: client.user.id,
143140
});
144141
return true;
145142
}
@@ -204,12 +201,15 @@ You should only respond with the name of the voice channel or none, no commentar
204201
});
205202

206203
if (targetChannel) {
207-
state.voiceManager.joinVoiceChannel({
204+
joinVoiceChannel({
208205
channelId: targetChannel.id,
209206
guildId: (discordMessage as DiscordMessage).guild
210207
?.id as string,
211208
adapterCreator: (client.guilds.cache.get(id) as Guild)
212209
.voiceAdapterCreator,
210+
selfDeaf: false,
211+
selfMute: false,
212+
group: client.user.id,
213213
});
214214
return true;
215215
}

0 commit comments

Comments
 (0)