Trying to play an audio file

Hello, I started a few days ago with discordjs, I have now tried to play an audio that I have locally, a lot of information is from discord 12 or 13 and in 14 I can't find much help, I don't know why the bot joins To the voice channel, the playing audio log pops up but it doesn't play any audio, I gave it all the permissions I would swear to the voice and when I put logs to catch errors I don't get that it is going at all wrong in reading This is my replit repo https://replit.com/@FranyxD/Zetydiscordbot?s=app
FranyxD
replit
Zety_discord_bot
Run Node.js code live in your browser. Write and run code in 50+ languages online with Replit, a powerful IDE, compiler, & interpreter.
7 Replies
d.js toolkit
d.js toolkit8mo 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!
FranyxD
FranyxDOP8mo ago
My discord is 14.15.2 and my discord voice is 0.17 Using the lts of node Yes, I have it in my package.json dependencies I have mp3 and ogg filed just in case
FranyxD
FranyxDOP8mo ago
FranyxD
replit
Zety_discord_bot
Run Node.js code live in your browser. Write and run code in 50+ languages online with Replit, a powerful IDE, compiler, & interpreter.
FranyxD
FranyxDOP8mo ago
It's the /commands/utility/play.js Okay module.exports = { data: new SlashCommandBuilder() .setName("play") .setDescription( "Command to make the bot join a voice channel and play an mp3", ), async execute(interaction) { if (!interaction.inGuild()) { // Check if the command was used in a guild interaction.reply("This command can only be used in a server."); return; } const { member } = interaction; // Get the member who ran the command const channel = member.voice.channel; // Get the voice channel the member is in if (!channel) { // Check if the member is in a voice channel interaction.reply("You need to be in a voice channel to play audio!"); return; } if (!channel.permissionsFor(interaction.guild.members.me).has("STREAM")) { interaction.reply("I don't have permission to stream audio in this voice channel."); return; } // Join the voice channel const connection = joinVoiceChannel({ // Create a connection to the voice channel channelId: channel.id, // Use the ID of the voice channel guildId: channel.guild.id, // Use the ID of the guild adapterCreator: channel.guild.voiceAdapterCreator, selfDeaf: false, }); // Play audio const player = createAudioPlayer(); const resource = createAudioResource('./sample.ogg'); player.play(resource); // Play "track.mp3" across two voice connections connection.subscribe(player); // Check if the bot is playing audio player.on(AudioPlayerStatus.Playing, () => { console.log("Bot is playing audio."); }); // Check if the bot is reading the mp3 file player.on(AudioPlayerStatus.Buffering, () => { console.log("Bot is reading the mp3 file."); }); await interaction.reply("Playing mp3"); }, }; Using discord guide, I don't know what I'm missing It's 14.15.2 I have never gotten an error that I don't have permissions. Yes I ll try that The other message you send me I don't understand at all Nope 😅 // Play audio const player = createAudioPlayer(); const resource = createAudioResource(path.resolve(__dirname, 'sample.ogg')); player.play(resource); // Play "track.mp3" across two voice connections connection.subscribe(player); This? Bot, can't and the I know It's just I don't know what you mean, I need to change the bot permission? So if it's irrelevant, why not works? I change to absolute and it's the same What type of permission need to mark at the bot
d.js docs
d.js docs8mo ago
:guide: Getting Started: Introduction - Debugging Dependencies read more
FranyxD
FranyxDOP8mo ago
Do you have an example files of how to do this things? In guide don't finde for discord voice
ThePedroo
ThePedroo8mo ago
I'd start with logging the states If it was ffmpeg being missing, prism-media would throw an error
Want results from more Discord servers?
Add your server