I am trying to make a bot to play music, currently I am trying using a audio file on my computer which I know works as it plays when used with mpg123. The bot can join the voice channel but when this function is called it does not produce any sound, does anyone have any suggestions?
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require('@discordjs/voice');
...
function play(connection, messageCreate, server) {
let resource = createAudioResource(__dirname '/try.mp3', { inlineVolume : true });
const player = createAudioPlayer();
connection.subscribe(player);
player.play(resource, {seek: 0, volume: 1.0});
}
CodePudding user response:
The most likely problem I can think of is a common one: you need the GUILD_VOICE_STATES intent for your bot the join a voice channel. If you don't have it, it'll show up as having joined, but actually still be in the signalling state which prohibits it from doing anything.
If you do have that intent already, or adding it did not solve your problem, consider debugging your dependencies with the method outlined here.