#voice is playing on local but not on server

18 messages · Page 1 of 1 (latest)

bitter cradle
#

Hi Ive got a problem with this code:

if(interaction.commandName === 'musicradio') {

    const { createAudioPlayer, createAudioResource, joinVoiceChannel } = require('@discordjs/voice');
    const { ActionRowBuilder, StringSelectMenuBuilder } = require('discord.js');
    
    // Code für den Slash Command mit dem Namen "musicradio"
    const voiceChannel = interaction.member.voice.channel;
    
    if (!voiceChannel) return interaction.reply('Du musst in einem Voice Channel sein, um mit mir Musik zu hören.');
    
    const radioOptions = [
        labels
        // Weitere Sender können hier hinzugefügt werden
    ];
    
    const selectMenu = new StringSelectMenuBuilder()
        .setCustomId('radioSelect')
        .setPlaceholder('Wähle einen Sender aus')
        .addOptions(radioOptions);
    
    const row = new ActionRowBuilder().addComponents(selectMenu);
    
    interaction.reply({
        content: 'Wähle einen Sender aus:',
        components: [row],
        ephemeral: 'true',
    }).then(() => {
        const filter = i => i.user.id === interaction.user.id && i.customId === 'radioSelect';
        const collector = interaction.channel.createMessageComponentCollector({ filter, time: 15000 });
    
        collector.on('collect', async i => {
            if (!i.deferred) {
                // Der Benutzer hat die Interaktion noch nicht abgeschlossen
                const selectedRadio = radioOptions.find(option => option.value === i.values[0]);
                if (selectedRadio) {
                    i.deferUpdate(); // Bestätige die Interaktion, um Timeout-Fehler zu vermeiden
                    const vconnection = joinVoiceChannel({
                        channelId: voiceChannel.id,
                        guildId: interaction.guild.id,
                        adapterCreator: interaction.guild.voiceAdapterCreator
                    });
                    const resource = createAudioResource(selectedRadio.value, { inlineVolume: true });
                    const player = createAudioPlayer();

player.on('error', error => {
    console.error('Fehler beim Abspielen des Audios:', error.message);
});

vconnection.on('error', error => {
    console.error('Fehler beim Verbinden zum Voice-Channel:', error.message);
});

                    vconnection.subscribe(player);
                    player.play(resource);
    
                    // Nachrichten löschen nach 30 Sekunden
                    setTimeout(() => {
                        //interaction.channel.messages.fetch({ limit: 1 }).then(messages => {
                        //    interaction.channel.bulkDelete(messages);
                        //});
                    }, 30000); // 30000 Millisekunden = 30 Sekunden
    
                } else {
                    i.deferUpdate(); // Bestätige die Interaktion, um Timeout-Fehler zu vermeiden
                    interaction.followUp('Ungültige Auswahl.');
                }
            } else {
                // Die Interaktion wurde bereits abgeschlossen
                console.log('Die Interaktion wurde bereits abgeschlossen.');
            }
        });
    
        collector.on('end', collected => {
            if (collected.size === 0) {
                interaction.followUp({ content: 'Die Auswahl wurde abgebrochen, weil keine Option ausgewählt wurde.', ephemeral: 'true' });
            }
        });
    });
    
}```
 my bot is not playing music when hosted on a Server but plays music when hosted localy, does anyone has / had the same issue and knows what to fix ? Btw Ive got no errors 😦 Thank you
opaque jettyBOT
#
  • What are your intents? GuildVoiceStates is required to receive voice data!
  • Show what dependencies you are using -- generateDependencyReport() is exported from @discordjs/voice.
  • Try looking at common examples: https://github.com/discordjs/voice-examples.
  • 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!
wooden timber
#

Either network issues or missing/wrong version of ffmpeg and/or other dependencies (see tag, show your dependencies)

raven geyser
crystal bluff
raven geyser
raven geyser
#

@wooden timber could you help?

raven geyser
#

its not network issues or missing/wrong version of ffmpeg I checked them all

raven geyser
#

i tried to open a port and it didn’t work

wooden timber
opaque tinsel
#

your issue likely is because you're using ffmpeg static

#

download the ffmpeg binaries from the website directly into the server instead

raven geyser
opaque tinsel
#

👍

raven geyser
opaque tinsel
#

there could be