Bot dont Play audio

Hello my bot dont play but i dont know why
const voiceChannel = interaction.member.voice.channel;
const connection = joinVoiceChannel({
channelId: voiceChannel.id,
guildId: voiceChannel.guild.id,
adapterCreator: voiceChannel.guild.voiceAdapterCreator,
});

connection.on(VoiceConnectionStatus.Ready, () => {
console.log('Connecté et pres a Jouer');
});

const player = createAudioPlayer();

const resource = createAudioResource('../test.mp3');

setTimeout(() => {
player.play(resource);
}, 500);
const voiceChannel = interaction.member.voice.channel;
const connection = joinVoiceChannel({
channelId: voiceChannel.id,
guildId: voiceChannel.guild.id,
adapterCreator: voiceChannel.guild.voiceAdapterCreator,
});

connection.on(VoiceConnectionStatus.Ready, () => {
console.log('Connecté et pres a Jouer');
});

const player = createAudioPlayer();

const resource = createAudioResource('../test.mp3');

setTimeout(() => {
player.play(resource);
}, 500);
37 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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 staff
_Syio
_SyioOP7mo ago
he join but he dont play
으후루꾸루후으
The connection didn't subscribe the player . Call the expression connection.subscribe(player) before playing audio source
_Syio
_SyioOP7mo ago
okay he dont play :c
const voiceChannel = interaction.member.voice.channel;
const connection = joinVoiceChannel({
channelId: voiceChannel.id,
guildId: voiceChannel.guild.id,
adapterCreator: voiceChannel.guild.voiceAdapterCreator,
});

connection.on(VoiceConnectionStatus.Ready, () => {
console.log('Connecté et pres a Jouer');
});

const player = createAudioPlayer();
connection.subscribe(player)
const resource = createAudioResource('../test.mp3');

setTimeout(() => {
player.play(resource);
}, 500);
const voiceChannel = interaction.member.voice.channel;
const connection = joinVoiceChannel({
channelId: voiceChannel.id,
guildId: voiceChannel.guild.id,
adapterCreator: voiceChannel.guild.voiceAdapterCreator,
});

connection.on(VoiceConnectionStatus.Ready, () => {
console.log('Connecté et pres a Jouer');
});

const player = createAudioPlayer();
connection.subscribe(player)
const resource = createAudioResource('../test.mp3');

setTimeout(() => {
player.play(resource);
}, 500);
으후루꾸루후으
it seems weird :Thonk: check the player status:
player.on("playing", () => {
console.log("player started");
})
player.on("playing", () => {
console.log("player started");
})
check if the message appears to ensure the player plays the audio source
_Syio
_SyioOP7mo ago
ok he play but 0 sound
으후루꾸루후으
then the problem is about audio source
_Syio
_SyioOP7mo ago
shit but
_Syio
_SyioOP7mo ago
으후루꾸루후으
the file path maybe the problem is the path relatvie to the entry file(like index.js)?
_Syio
_SyioOP7mo ago
No description
_Syio
_SyioOP7mo ago
No description
으후루꾸루후으
check the file "../test.mp3"'s path
_Syio
_SyioOP7mo ago
No description
으후루꾸루후으
is the "main.js" file the entry of the program?
_Syio
_SyioOP7mo ago
yes and the commande is in command
_Syio
_SyioOP7mo ago
No description
으후루꾸루후으
the relative paths are calculated with the entry file's directory so the mp3 file's path has to be "./test.mp3"
_Syio
_SyioOP7mo ago
omggg thank youu
으후루꾸루후으
it works differently when you import some modules
_Syio
_SyioOP7mo ago
ah okayy because i have this
const IdConfig = require('../DataBase/IdConfig.json')
const IdConfig = require('../DataBase/IdConfig.json')
으후루꾸루후으
yes check the player sends its sound
_Syio
_SyioOP7mo ago
yes is good thank you man
으후루꾸루후으
:blobreachReverse:
_Syio
_SyioOP7mo ago
:blobreachReverse: you know how use ytdl ?
으후루꾸루후으
yeah
_Syio
_SyioOP7mo ago
lol im noob
const stream = ytdl('https://www.youtube.com/...', { filter: 'audioonly' });
const resource = createAudioResource(stream);
const stream = ytdl('https://www.youtube.com/...', { filter: 'audioonly' });
const resource = createAudioResource(stream);
으후루꾸루후으
:dogeHaHa:
_Syio
_SyioOP7mo ago
always this erreur
으후루꾸루후으
recently ytdl has some connection problems this error is not just for you
_Syio
_SyioOP7mo ago
Ow okayy
으후루꾸루후으
:caillou:
_Syio
_SyioOP7mo ago
thx you ❤️
으후루꾸루후으
:blobreachReverse:
_Syio
_SyioOP7mo ago
your good dev 🙂
으후루꾸루후으
thx :meguFace:
_Syio
_SyioOP7mo ago
:blobreachReverse:
Want results from more Discord servers?
Add your server