8
8
IAgentRuntime ,
9
9
Memory ,
10
10
State ,
11
+ generateText ,
12
+ ModelClass ,
11
13
} from "@elizaos/core" ;
12
14
import {
13
15
Channel ,
@@ -17,6 +19,7 @@ import {
17
19
Guild ,
18
20
GuildMember ,
19
21
} from "discord.js" ;
22
+ import { joinVoiceChannel } from "@discordjs/voice" ;
20
23
21
24
export default {
22
25
name : "JOIN_VOICE" ,
@@ -66,12 +69,7 @@ export default {
66
69
return false ;
67
70
}
68
71
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 ;
75
73
} ,
76
74
description : "Join a voice channel to participate in voice chat." ,
77
75
handler : async (
@@ -115,31 +113,30 @@ export default {
115
113
) ;
116
114
} ) ;
117
115
118
- if ( ! state . voiceManager ) {
119
- state . voiceManager = new VoiceManager ( {
120
- client : state . discordClient ,
121
- runtime : runtime ,
122
- } ) ;
123
- }
124
-
125
116
if ( targetChannel ) {
126
- state . voiceManager . joinVoiceChannel ( {
117
+ joinVoiceChannel ( {
127
118
channelId : targetChannel . id ,
128
119
guildId : ( discordMessage as DiscordMessage ) . guild ?. id as string ,
129
120
adapterCreator : ( client . guilds . cache . get ( id ) as Guild )
130
121
. voiceAdapterCreator ,
122
+ selfDeaf : false ,
123
+ selfMute : false ,
124
+ group : client . user . id ,
131
125
} ) ;
132
126
return true ;
133
127
} else {
134
128
const member = ( discordMessage as DiscordMessage )
135
129
. member as GuildMember ;
136
130
if ( member ?. voice ?. channel ) {
137
- state . voiceManager . joinVoiceChannel ( {
131
+ joinVoiceChannel ( {
138
132
channelId : member . voice . channel . id ,
139
133
guildId : ( discordMessage as DiscordMessage ) . guild
140
134
?. id as string ,
141
135
adapterCreator : ( client . guilds . cache . get ( id ) as Guild )
142
136
. voiceAdapterCreator ,
137
+ selfDeaf : false ,
138
+ selfMute : false ,
139
+ group : client . user . id ,
143
140
} ) ;
144
141
return true ;
145
142
}
@@ -204,12 +201,15 @@ You should only respond with the name of the voice channel or none, no commentar
204
201
} ) ;
205
202
206
203
if ( targetChannel ) {
207
- state . voiceManager . joinVoiceChannel ( {
204
+ joinVoiceChannel ( {
208
205
channelId : targetChannel . id ,
209
206
guildId : ( discordMessage as DiscordMessage ) . guild
210
207
?. id as string ,
211
208
adapterCreator : ( client . guilds . cache . get ( id ) as Guild )
212
209
. voiceAdapterCreator ,
210
+ selfDeaf : false ,
211
+ selfMute : false ,
212
+ group : client . user . id ,
213
213
} ) ;
214
214
return true ;
215
215
}
0 commit comments