Tommy
Tommy
DIAdiscord.js - Imagine an app
Created by Tommy on 7/25/2024 in #djs-voice
Mp3 audio not playing
Hello i followed various guides and threads in this server to create a command !play that enables the bot to stream an mp3 file located in his folder. The bot joins the channel but the audio don't start, no errors in the terminal. [email protected] Node v16.20.2 @discordjs/[email protected] @discordjs/[email protected]
const { entersState, joinVoiceChannel, VoiceConnectionStatus, EndBehaviorType, createAudioPlayer, createAudioResource, AudioPlayerStatus } = require('@discordjs/voice');
const ffmpeg = require('ffmpeg-static');

client.on('messageCreate', async (message) => {
if (message.content === '!play') {
if (!message.member.voice?.channel) return message.channel.send('You need to be a voice channel to execute this command')

const connection = joinVoiceChannel({
channelId: message.member.voice.channelId,
guildId: message.guildId,
adapterCreator: message.guild.voiceAdapterCreator
})

const player = createAudioPlayer()
const resource = createAudioResource('./music/song.mp3')

connection.subscribe(player)

player.play(resource)
}
})
const { entersState, joinVoiceChannel, VoiceConnectionStatus, EndBehaviorType, createAudioPlayer, createAudioResource, AudioPlayerStatus } = require('@discordjs/voice');
const ffmpeg = require('ffmpeg-static');

client.on('messageCreate', async (message) => {
if (message.content === '!play') {
if (!message.member.voice?.channel) return message.channel.send('You need to be a voice channel to execute this command')

const connection = joinVoiceChannel({
channelId: message.member.voice.channelId,
guildId: message.guildId,
adapterCreator: message.guild.voiceAdapterCreator
})

const player = createAudioPlayer()
const resource = createAudioResource('./music/song.mp3')

connection.subscribe(player)

player.play(resource)
}
})
23 replies