const { Client, SlashCommandBuilder } = require('discord.js')
const { createAudioPlayer, createAudioResource, generateDependencyReport, joinVoiceChannel } = require('@discordjs/voice');
console.log(generateDependencyReport());
module.exports = {
data: new SlashCommandBuilder()
.setName('anthem')
.setDescription('Let the anthem play!'),
async execute(interaction, client) {
const channel = client.channels.cache.get('1033420771294461952');
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
const player = createAudioPlayer();
const subscription = connection.subscribe(player);
const resource = createAudioResource('../Anthem.mp3');
connection.subscribe(player);
player.play(resource);
if (subscription) {
// Unsubscribe after 5 seconds (stop playing audio on the voice connection)
setTimeout(() => subscription.unsubscribe(), 5_000);
}
interaction.reply("Anthem playing in <#1033420771294461952>")
},
};