Skip to content

Commit 94127a0

Browse files
committed
fix join voice channel
1 parent 0bdafda commit 94127a0

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

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

+5-16
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
Guild,
1818
GuildMember,
1919
} from "discord.js";
20+
import { joinVoiceChannel } from "@discordjs/voice";
2021

2122
export default {
2223
name: "JOIN_VOICE",
@@ -66,12 +67,7 @@ export default {
6667
return false;
6768
}
6869

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;
70+
return true;
7571
},
7672
description: "Join a voice channel to participate in voice chat.",
7773
handler: async (
@@ -115,15 +111,8 @@ export default {
115111
);
116112
});
117113

118-
if (!state.voiceManager) {
119-
state.voiceManager = new VoiceManager({
120-
client: state.discordClient,
121-
runtime: runtime,
122-
});
123-
}
124-
125114
if (targetChannel) {
126-
state.voiceManager.joinVoiceChannel({
115+
joinVoiceChannel({
127116
channelId: targetChannel.id,
128117
guildId: (discordMessage as DiscordMessage).guild?.id as string,
129118
adapterCreator: (client.guilds.cache.get(id) as Guild)
@@ -134,7 +123,7 @@ export default {
134123
const member = (discordMessage as DiscordMessage)
135124
.member as GuildMember;
136125
if (member?.voice?.channel) {
137-
state.voiceManager.joinVoiceChannel({
126+
joinVoiceChannel({
138127
channelId: member.voice.channel.id,
139128
guildId: (discordMessage as DiscordMessage).guild
140129
?.id as string,
@@ -204,7 +193,7 @@ You should only respond with the name of the voice channel or none, no commentar
204193
});
205194

206195
if (targetChannel) {
207-
state.voiceManager.joinVoiceChannel({
196+
joinVoiceChannel({
208197
channelId: targetChannel.id,
209198
guildId: (discordMessage as DiscordMessage).guild
210199
?.id as string,

0 commit comments

Comments
 (0)