How to play sound with a music discord bot on heroku

discord.js music bot
discord.js play audio
discord bot play mp3
how to make a discord music bot
discord music bot source code
discord bot hosting
ytdl-core-discord
discord bot play youtube audio

I'm creating a Discord Music Bot in discord.js, I already installed ffmpeg, and everything seems to work normally, but when I execute play command, bot joins a channel, send a message, but doesn't play anything, I've already checked console and it doesn't log anything. I know it's not a problem with code since it works perfectly locally, the problem is when I try to use heroku, I thought it could be a opusscript problem but I don't know.

Well hello there, It would be better if you posted an example of your code and a detailed error-log. From what I can understand,

I can tell you that you can play mp3 files that are not being downloaded from YouTube easily without any dependencies needed (except FFMPEG). You might want to check the documentation by navigating to https://discord.js.org :)

Here is the full link of the topic in Discord.js documentation: https://discord.js.org/#/docs/main/stable/topics/voice

I'm saying again, I can't understand your situation too much. Provide an excepted behaviour and some examples of code.

In the other hand, your code may not work if you're using master branch and using a code for stable release. Please check your branch and make the needed changes for code-breaking updates.

helionmusic/rhinobot_heroku: RhinoBot Discord music bot , RhinoBot Discord music bot with setup intructions for hosting on free Heroku This is just a guide on how to get the bot hosted on Heroku's free cloud service. In this video I'm going to show you how to deploy your Music Bot to Heroku using GitHub as a deployment method. Link to my Discord: https://discord.gg/bZSwjPy Link to code repository: https

I don't find code relevant here, since it works perfectly in my localhost, but when I start to host it at Heroku, nothing happens. Here you have it, maybe there's an error, but as I said I think the problem is with opusscript or node-opus. Here are my Heroku buildpacks

And this is my code:

const ytdl = require('ytdl-core');

let voiceChn = message.member.voiceChannel;

if(!voiceChn) return message.channel.send('¡Join a voice channel first!.'); 

if(!args) return message.channel.send('Add a youtube URL to play it.');

voiceChn.join()
    .then(connection => {
        const url = ytdl(args.join(' '), { filter : 'audioonly' });

        const dispatcher = connection.playStream(url);

        message.delete();

        message.channel.send('Now playing : '+ args);

    }).catch(console.error);

amishshah/ytdl-core-discord - Buildpacks, A ytdl-core wrapper focused on efficiency for use in Discord music bots. this module uses prism-media to extract Opus audio from a stream without having to pipe making playback smoother and allowing you to play over more connections  The discord API provides you with an easy tool to create and use your own bots and tools. For this tutorial we are going to create a basic music bot and add it to our server, not only for developers any one can do it. The bot will have the following command : PLAY command. HELP command. QUEUE command. NOWPLAYING command. LOOP command. SKIP command.

For what its worth I am seeing a very similar issue. My bot should join the channel, play a sound clip from a S3 bucket (which is made public), and then leave. Here's my code:

async function executePlaySoundCommand(message, filePath) {
  try {
    const voiceChannel = message.member.voiceChannel;
    const connection = await voiceChannel.join();
    console.log(`filePath: ${filePath}`);
    const file = `${process.env.S3_URL}/${filePath}`;
    console.log(`file: ${file}`);
    const dispatcher = await connection.playArbitraryInput(file);
    console.log('Playback finished');
    dispatcher.on('end', () => {
      voiceChannel.leave();
    });
  } catch (err) {
    console.log(err);
  }
}

Locally the bot will join the channel, play the sound and then leave as expected. However in heroku, the bot will join the channel, then immediately leave. Below are the sanitized logs from heroku:

Executing <command-name> command
filePath: <audio-file>.mp3
file: https://s3-eu-west-1.amazonaws.com/<s3-bucket-name>/<audio-file>.mp3
Playback finished

I don't think there's anything wrong with my code(?), looking into ffmpeg protocols to see if I have missed something.

mrsmook/music-discord-heroku-bot - Buttons, A discord Node.js music bot app. For this tutorial we are going to create a basic music bot and add it to our PLAY command. Get a youtube API token. The discord API provides you with an easy tool to create and use your own bots and tools. For this tutorial we are going to create a basic music bot and add it to our server, not only for developers any one can do it. The bot will have the following command : PLAY command. HELP command. QUEUE command. NOWPLAYING command. LOOP command. SKIP command.

Coding Your Own Discord Bot - Discord.js - Playing Music, The bot will be able to play, skip and stop the music and will also support queuing functionality. Prerequisites. Before we get started creating the bot make sure that  A simple music bot written using discord.py rewrite and youtube_dl. - music_bot_example.py I have deployed this bot on heroku. it queues the songs but never

HOW TO HOST YOUR DISCORD BOT FOR FREE! (Heroku , This is the complete guide to hosting a Discord bot and getting it up and running We're going to walk through the exact steps to get your bot up and running 24/7 in like Heroku, Amazon AWS, and even how to host your own Discord bot on a Raspberry Pi. If this sounds “alien” to you, a quick explanation is how IPV4 vs. discord music bot heroku, discord music bot hindi, discord music bot how to play playlist, discord music bot hydra Watch my Videos 🎬 : How to Download and Install Java in Your PC 2020!:

How to create a music bot using Discord.js, command not working. So my discord.js bot works locally playing YouTube videos But when I push to Heroku, the bot joins and says that it is playing music , but no output. I keep having to install them locally to npm for sound to work. 3. MusicBot is the original Discord music bot written for Python 3.5+, using the discord.py library. It plays requested songs from YouTube and other services into a Discord server (or multiple servers). It plays requested songs from YouTube and other services into a Discord server (or multiple servers).

Comments
  • Just found this on another stack overflow post. Heroku isn’t a virtual server, it does not bear well with the opus library. It’s recommended by the discord developers community to not use heroku to host bots since the platform isn’t meant for bot hosting as its unstable (downtimes) and doesn’t support opus (without extended modifications). From here (stackoverflow.com/questions/52372170/…)