#My bot can't speak when running on heroku

41 messages · Page 1 of 1 (latest)

tame arrow
#

My bot works fine when running on my pc, but when I deploy it to heroku, it can't speak. It connects on the channel but doesn't speak, and I get no errors on the console.

const { generateDependencyReport } = require('@discordjs/voice');
console.log(generateDependencyReport());

Running this code on heroku I get this output.

Core Dependencies
- @discordjs/voice: 0.11.0
- prism-media: 1.3.4

Opus Libraries
- @discordjs/opus: 0.8.0
- opusscript: not found

Encryption Libraries
- sodium-native: not found
- sodium: 3.0.2
- libsodium-wrappers: 0.7.10
- tweetnacl: not found

FFmpeg
- version: 5.0.1-static https://johnvansickle.com/ffmpeg/ 
- libopus: yes

Can someone help me?

scenic novaBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

tame arrow
formal temple
#

do npm list (while on your heroku vm) and show what you have there

formal temple
#

might be a firewall thing? not sure

tame arrow
karmic willow
#

do you have a ffmpeg buildpack installed?

tame arrow
#

I'm using ffmpeg-static

karmic willow
#

i dont think that works on heroku. Search ”heroku ffmpeg buildpack” you can find the instructions on how to install that there

tame arrow
#

Ok, i'm gonna try this

#

It didn't work :(

karmic willow
#

is there any additional info in the logs?

tame arrow
#

But there doesn't seem to be anything wrong with it

#

On the console I receive no output when I run the command

#

The bot just enters the channel, send a message but doesn't play anything

elfin solstice
#

What does it try to play to the channel?

tame arrow
#

An ogg file

elfin solstice
#

And where does it get that ogg file from?

tame arrow
#

I have a folder with them

#

The files are in heroku too

deft willow
#

if your bot are in stack ``heroku-22rollback toheroku-20` that patch the bug

tame arrow
#

I'm using heroku-20 :(

deft willow
#

your bot send audio in local ?

tame arrow
#

Yes

deft willow
#

can i see a code ?

tame arrow
#
import fs from "fs";
import path from "path";
import { Command } from "types/command";
import { SlashCommandBuilder } from "@discordjs/builders";
import { DiscordGatewayAdapterCreator, joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayer, AudioPlayerStatus } from "@discordjs/voice";

const audio: Command = {
    data: new SlashCommandBuilder()
        .setName("som")
        .setDescription("ELE GOOOOOOSTA!")
        .addStringOption(option =>
            option.setName("audio")
                .setDescription("Qual áudio você ouvir")
                .setRequired(true)
                .setChoices(...getAudioChoices())),
    execute: async (interaction) => {
        const file = interaction.options.getString("audio");
        const user = await interaction.guild.members.cache.get(interaction.user.id).fetch();

        if (user.voice.channelId === null) {
            await interaction.reply({ content: "Você precisa estar em um canal de voz para usar esse comando!", ephemeral: true });
            return;
        }

        const connection = joinVoiceChannel({
            channelId: user.voice.channelId,
            guildId: user.voice.guild.id,
            adapterCreator: user.voice.channel.guild.voiceAdapterCreator as unknown as DiscordGatewayAdapterCreator,
        });
        
        const audioPlayer = createAudioPlayer();
        connection.subscribe(audioPlayer);
        const audio = createAudioResource(file);
        audioPlayer.play(audio);

        await interaction.reply({ content: "Ratinhoooooooo!", ephemeral: true });
    }
}

function getAudioChoices() {
    const audioPath = path.join(__dirname, "../../media/audio/");
    const files = fs.readdirSync(audioPath);

    return files.map(file => {
        return { name: file.split("-").join(" ").replace(".ogg", ""), value: path.join(audioPath, file) }
    });
}

module.exports = audio;
stoic dawn
#

Add that buildpack in your setting section. link upside ☝️

tame arrow
#

I'm gonna try it, ty

stoic dawn
#

Ok tell me after try

tame arrow
#

@stoic dawn

#

I had already added this buildpack