#audio file isn't played

3 messages · Page 1 of 1 (latest)

haughty schooner
#

• 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.

bitter grove
#
        const connection = joinVoiceChannel({
            channelId: '1085663926592737334',
            guildId: '1085663926592737330',
            adapterCreator: client.guilds.cache.get("1085663926592737330").voiceAdapterCreator,
            selfDeaf: false,
            selfMute: false
        });

        const player = createAudioPlayer({
            behaviors: {
                noSubscriber: NoSubscriberBehavior.Play
            }
        });
        const resource = createAudioResource(path.join(__dirname, 'response/output.wav'))

        player.play(resource)

        const subscription = connection.subscribe(player)

        player.on(AudioPlayerStatus.Playing, () => {
            console.log('Broadcasting reply to Discord.')
        })

        player.on('error', error => {
            console.error(`Error: ${error.message} with resource ${error.resource.metadata.title}`);
        });

        if (subscription) {
            setTimeout(() => subscription.unsubscribe(), 25000)
        }
night reef
#

Have you tried swapping player.play() and connection.subscribe() so player.play() comes after it?