const Command = require('../Structures/Command.js') const Discord = require('discord.js') module.exports = new Command({ name: "play", description: "Play a song!", async run(message, args, client) { const { getVoiceConnection, joinVoiceChannel, AudioPlayerStatus, createAudioResource, getNextResource, createAudioPlayer, NoSubscriberBehavior } = require('@discordjs/voice'); //Input Command in here if (message.member.voice.channel == null){ return message.reply(`You are not in a voice channel!`) } const connection = joinVoiceChannel({ channelId: message.member.voice.channel.id, guildId: message.guild.id, adapterCreator: message.guild.voiceAdapterCreator, }) const player = createAudioPlayer() const subscription = connection.subscribe(player) player.play(createAudioResource('../halloween.mp3')) message.reply('Did i do it right?') player.on(AudioPlayerStatus.Idle, () => { player.stop() connection.destroy() }) player.on('error', error => { console.error(`Error: ${error.message} with resource ${error.resource.metadata.title}`); player.play(getNextResource()) }) } })