'My bot glows green for a second, then stops

Right now, I only really want my bot to play one file directly off my computer. Here's the code:

const { Client, Intents, MessageEmbed } = require('discord.js');
const { token } = require('./config.json');
const { joinVoiceChannel, createAudioPlayer, createAudioResource} = require('@discordjs/voice');
const { join } = require('path')
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_VOICE_STATES] });

client.once('ready', () => {
    console.log('Ready!');
});

client.on('messageCreate', msg => {
    if(msg.content === '!join') {
    connection = joinVoiceChannel({
        channelId: msg.member.voice.channel.id,
        guildId: msg.guild.id,
        adapterCreator: msg.guild.voiceAdapterCreator
    })
    }

    if (msg.content === '!play') {
    console.log(generateDependencyReport())
    const player = createAudioPlayer()
    let resource = createAudioResource(join('./Downloads/', 'musicFile.mp3'));
    player.play(resource)
    connection.subscribe(player)
    }
}
client.login(token);

I'm not really facing trouble getting my bot to join, but once I tell it to play the file, it doesn't play anything. Rather it flashes green for a second then just stays silent. I've made sure that all my intents are on, and I've also checked that all my dependencies are up to date. Thank you for reading! Btw discord.js v13 is the version I'm running



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source