const { Client, GatewayIntentBits, Collection } = require('discord.js'); const { joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayerStatus } = require('@discordjs/voice'); const { CronJob } = require('cron'); const path = require('path'); const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildPresences ] }); // Settings from DB or Env const VC_ID = process.env.VC_ID || '1457687430189682781'; const AUDIO_PATH = path.join(__dirname, '../assets/audio/sahur.mp3'); client.once('ready', () => { console.log('Bot is ready!'); // Sahur Alarm: 03:30 Asia/Jakarta new CronJob('30 03 * * *', async () => { const guild = client.guilds.cache.first(); // Simplified for single server const channel = guild.channels.cache.get(VC_ID); if (channel) { const connection = joinVoiceChannel({ channelId: channel.id, guildId: guild.id, adapterCreator: guild.voiceAdapterCreator, }); const player = createAudioPlayer(); const resource = createAudioResource(AUDIO_PATH); player.play(resource); connection.subscribe(player); player.on(AudioPlayerStatus.Idle, () => { connection.destroy(); }); } }, null, true, 'Asia/Jakarta'); }); client.login(process.env.DISCORD_TOKEN);