Bot connect but doesnt play anything

These are my dependences: Core Dependencies - @discordjs/voice: 0.18.0 - prism-media: 1.3.5 Opus Libraries - @discordjs/opus: 0.9.0 - opusscript: 0.0.8 Encryption Libraries - sodium-native: 4.3.1 - sodium: not found - libsodium-wrappers: not found - @stablelib/xchacha20poly1305: not found - @noble/ciphers: not found FFmpeg - version: 2024-07-24-git-896c22ef00-full_build-www.gyan.dev - libopus: yes
4 Replies
d.js toolkit
d.js toolkit2mo ago
- What are your intents? GuildVoiceStates is required to receive voice data! - Show what dependencies you are using -- generateDependencyReport() is exported from @discordjs/voice. - Try looking at common examples: https://github.com/discordjs/voice-examples. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Samu_
Samu_OP2mo ago
this is my code:
const AUDIO_FILE_PATH = path.join(__dirname, 'audio.mp3');


const channel = await client.channels.fetch(VOICE_CHANNEL_ID);
if (!channel || channel.type !== 'GUILD_VOICE') {
console.error('Il canale specificato non è valido o non è un canale vocale.');
return;
}

const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator
});

const player = createAudioPlayer();
const resource = createAudioResource(AUDIO_FILE_PATH);

player.play(resource);
connection.subscribe(player);



console.log('Audio in riproduzione nel canale vocale.');
};
const AUDIO_FILE_PATH = path.join(__dirname, 'audio.mp3');


const channel = await client.channels.fetch(VOICE_CHANNEL_ID);
if (!channel || channel.type !== 'GUILD_VOICE') {
console.error('Il canale specificato non è valido o non è un canale vocale.');
return;
}

const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator
});

const player = createAudioPlayer();
const resource = createAudioResource(AUDIO_FILE_PATH);

player.play(resource);
connection.subscribe(player);



console.log('Audio in riproduzione nel canale vocale.');
};
Octoboomer
Octoboomer2mo ago
I’m surprised it even connects Channel.type is a number, which isn’t comparable to a string (always unequal)
Samu_
Samu_OP2mo ago
so apparently the bot works well on my pc but in my windows vps it doesnt play anything ye Im not, but the bot works on my pc also in v13, I literally copyied and pasted it in my vps (with the same ffmpeg and node version) but it doesnt play anything if I kick the bot from the voice channel I get this error:
C:\Users\Administrator\Desktop\Voice Support\node_modules\@discordjs\voice\dist\index.js:373
this.socket.once("close", () => reject(new Error("Cannot perform IP discovery - socket closed")));
^

Error: Cannot perform IP discovery - socket closed
at Socket.<anonymous> (C:\Users\Administrator\Desktop\Voice Support\node_modules\@discordjs\voice\dist\index.js:373:46)
at Object.onceWrapper (node:events:627:28)
at Socket.emit (node:events:525:35)
at socketCloseNT (node:dgram:754:8)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on VoiceConnection instance at:
at VoiceConnection.onNetworkingError (C:\Users\Administrator\Desktop\ Voice Support\node_modules\@discordjs\voice\dist\index.js:1930:10)
at Networking.emit (node:events:513:28)
at C:\Users\Administrator\Desktop\Voice Support\node_modules\@discordjs\voice\dist\index.js:740:32
at processTicksAndRejections (node:internal/process/task_queues:96:5)
C:\Users\Administrator\Desktop\Voice Support\node_modules\@discordjs\voice\dist\index.js:373
this.socket.once("close", () => reject(new Error("Cannot perform IP discovery - socket closed")));
^

Error: Cannot perform IP discovery - socket closed
at Socket.<anonymous> (C:\Users\Administrator\Desktop\Voice Support\node_modules\@discordjs\voice\dist\index.js:373:46)
at Object.onceWrapper (node:events:627:28)
at Socket.emit (node:events:525:35)
at socketCloseNT (node:dgram:754:8)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on VoiceConnection instance at:
at VoiceConnection.onNetworkingError (C:\Users\Administrator\Desktop\ Voice Support\node_modules\@discordjs\voice\dist\index.js:1930:10)
at Networking.emit (node:events:513:28)
at C:\Users\Administrator\Desktop\Voice Support\node_modules\@discordjs\voice\dist\index.js:740:32
at processTicksAndRejections (node:internal/process/task_queues:96:5)

Did you find this page helpful?