From 49dd9b22dfba4fdd74514dd7c749608b0474ec84 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Mon, 16 Feb 2026 08:12:26 +0000 Subject: [PATCH] V8 --- bot/bot.log | 220 +++++++++++++++++++++++++++++++++++++++++++++++++++ bot/index.js | 77 +++++++++++------- 2 files changed, 270 insertions(+), 27 deletions(-) diff --git a/bot/bot.log b/bot/bot.log index f0535a9..7561074 100644 --- a/bot/bot.log +++ b/bot/bot.log @@ -20,3 +20,223 @@ Ready! Logged in as AsepXiaoQin#6954 FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg [2026-02-16T07:56:42.611Z] Alarm scheduled at 30 3 * * * Alarm scheduled at 30 3 * * * +[2026-02-16T08:01:31.081Z] Playing local file via DisTube: /home/ubuntu/executor/workspace/bot/assets/audio/sahur.mp3 +Playing local file via DisTube: /home/ubuntu/executor/workspace/bot/assets/audio/sahur.mp3 +[2026-02-16T08:01:32.552Z] Error in testsahur: Cannot find any song with this query (/home/ubuntu/executor/workspace/bot/assets/audio/sahur.mp3) +Error in testsahur: Cannot find any song with this query (/home/ubuntu/executor/workspace/bot/assets/audio/sahur.mp3) +[2026-02-16T08:01:50.209Z] Fetching stream via DisTube for: iwak peyek +Fetching stream via DisTube for: iwak peyek +[2026-02-16T08:01:51.090Z] DisTube Error: undefined +DisTube Error: undefined +[2026-02-16T08:01:51.102Z] Unhandled Rejection: Cannot read properties of undefined (reading 'includes') +TypeError: Cannot read properties of undefined (reading 'includes') + at DisTube. (/home/ubuntu/executor/workspace/bot/index.js:250:23) + at DisTube.emit (node:events:518:28) + at DisTube.emitError (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2546:10) + at QueueManager.emitError (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:154:18) + at #handlePlayingError (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2100:10) + at QueueManager.playSong (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2147:31) + at process.processTicksAndRejections (node:internal/process/task_queues:105:5) + at async DisTube.play (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2352:24) + at async Client. (/home/ubuntu/executor/workspace/bot/index.js:153:17) +Unhandled Rejection: Cannot read properties of undefined (reading 'includes') +TypeError: Cannot read properties of undefined (reading 'includes') + at DisTube. (/home/ubuntu/executor/workspace/bot/index.js:250:23) + at DisTube.emit (node:events:518:28) + at DisTube.emitError (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2546:10) + at QueueManager.emitError (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:154:18) + at #handlePlayingError (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2100:10) + at QueueManager.playSong (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2147:31) + at process.processTicksAndRejections (node:internal/process/task_queues:105:5) + at async DisTube.play (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2352:24) + at async Client. (/home/ubuntu/executor/workspace/bot/index.js:153:17) +[2026-02-16T08:02:06.620Z] Fetching stream via DisTube for: bawa dia kembali +Fetching stream via DisTube for: bawa dia kembali +[2026-02-16T08:02:27.067Z] Fetching stream via DisTube for: y que fue +Fetching stream via DisTube for: y que fue +[2026-02-16T08:02:27.837Z] DisTube Error: undefined +DisTube Error: undefined +TypeError: Cannot read properties of undefined (reading 'includes') + at DisTube. (/home/ubuntu/executor/workspace/bot/index.js:250:23) + at DisTube.emit (node:events:518:28) + at DisTube.emitError (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2546:10) + at QueueManager.emitError (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:154:18) + at #handlePlayingError (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2100:10) + at QueueManager.playSong (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2147:31) + at process.processTicksAndRejections (node:internal/process/task_queues:105:5) + at async DisTube.play (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2352:24) + at async Client. (/home/ubuntu/executor/workspace/bot/index.js:153:17) +[2026-02-16T08:02:27.840Z] Unhandled Rejection: Cannot read properties of undefined (reading 'includes') +Unhandled Rejection: Cannot read properties of undefined (reading 'includes') +TypeError: Cannot read properties of undefined (reading 'includes') + at DisTube. (/home/ubuntu/executor/workspace/bot/index.js:250:23) + at DisTube.emit (node:events:518:28) + at DisTube.emitError (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2546:10) + at QueueManager.emitError (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:154:18) + at #handlePlayingError (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2100:10) + at QueueManager.playSong (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2147:31) + at process.processTicksAndRejections (node:internal/process/task_queues:105:5) + at async DisTube.play (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2352:24) + at async Client. (/home/ubuntu/executor/workspace/bot/index.js:153:17) +[dotenv@17.3.1] injecting env (4) from .env -- tip: πŸ” prevent committing .env to code: https://dotenvx.com/precommit +DisTubeError [INVALID_KEY]: 'ffmpegPath' does not need to be provided in DisTubeOptions + at checkInvalidKey (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1288:25) + at new Options (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1692:5) + at new DisTube (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2281:20) + at Object. (/home/ubuntu/executor/workspace/bot/index.js:47:17) + at Module._compile (node:internal/modules/cjs/loader:1688:14) + at Object..js (node:internal/modules/cjs/loader:1820:10) + at Module.load (node:internal/modules/cjs/loader:1423:32) + at Function._load (node:internal/modules/cjs/loader:1246:12) + at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) + at Module._compile (node:internal/modules/cjs/loader:1688:14) { + errorCode: 'INVALID_KEY' +} +[dotenv@17.3.1] injecting env (4) from .env -- tip: βš™οΈ suppress all logs with { quiet: true } +DisTubeError [INVALID_KEY]: 'ffmpegPath' does not need to be provided in DisTubeOptions + at checkInvalidKey (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1288:25) + at new Options (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1692:5) + at new DisTube (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2281:20) + at Object. (/home/ubuntu/executor/workspace/bot/index.js:47:17) + at Module._compile (node:internal/modules/cjs/loader:1688:14) + at Object..js (node:internal/modules/cjs/loader:1820:10) + at Module.load (node:internal/modules/cjs/loader:1423:32) + at Function._load (node:internal/modules/cjs/loader:1246:12) + at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) + at Module._compile (node:internal/modules/cjs/loader:1688:14) { + errorCode: 'INVALID_KEY' +} +[dotenv@17.3.1] injecting env (4) from .env -- tip: βš™οΈ suppress all logs with { quiet: true } +DisTubeError [INVALID_KEY]: 'ffmpegPath' does not need to be provided in DisTubeOptions + at checkInvalidKey (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1288:25) + at new Options (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1692:5) + at new DisTube (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2281:20) + at Object. (/home/ubuntu/executor/workspace/bot/index.js:47:17) + at Module._compile (node:internal/modules/cjs/loader:1688:14) + at Object..js (node:internal/modules/cjs/loader:1820:10) + at Module.load (node:internal/modules/cjs/loader:1423:32) + at Function._load (node:internal/modules/cjs/loader:1246:12) + at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) + at Module._compile (node:internal/modules/cjs/loader:1688:14) { + errorCode: 'INVALID_KEY' +} +[dotenv@17.3.1] injecting env (4) from .env -- tip: βš™οΈ suppress all logs with { quiet: true } +DisTubeError [INVALID_KEY]: 'ffmpegPath' does not need to be provided in DisTubeOptions + at checkInvalidKey (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1288:25) + at new Options (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1692:5) + at new DisTube (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2281:20) + at Object. (/home/ubuntu/executor/workspace/bot/index.js:47:17) + at Module._compile (node:internal/modules/cjs/loader:1688:14) + at Object..js (node:internal/modules/cjs/loader:1820:10) + at Module.load (node:internal/modules/cjs/loader:1423:32) + at Function._load (node:internal/modules/cjs/loader:1246:12) + at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) + at Module._compile (node:internal/modules/cjs/loader:1688:14) { + errorCode: 'INVALID_KEY' +} +[dotenv@17.3.1] injecting env (4) from .env -- tip: βš™οΈ suppress all logs with { quiet: true } +DisTubeError [INVALID_KEY]: 'ffmpegPath' does not need to be provided in DisTubeOptions + at checkInvalidKey (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1288:25) + at new Options (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1692:5) + at new DisTube (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2281:20) + at Object. (/home/ubuntu/executor/workspace/bot/index.js:47:17) + at Module._compile (node:internal/modules/cjs/loader:1688:14) + at Object..js (node:internal/modules/cjs/loader:1820:10) + at Module.load (node:internal/modules/cjs/loader:1423:32) + at Function._load (node:internal/modules/cjs/loader:1246:12) + at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) + at Module._compile (node:internal/modules/cjs/loader:1688:14) { + errorCode: 'INVALID_KEY' +} +[dotenv@17.3.1] injecting env (4) from .env -- tip: πŸ› οΈ run anywhere with `dotenvx run -- yourcommand` +DisTubeError [INVALID_KEY]: 'ffmpegPath' does not need to be provided in DisTubeOptions + at checkInvalidKey (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1288:25) + at new Options (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1692:5) + at new DisTube (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2281:20) + at Object. (/home/ubuntu/executor/workspace/bot/index.js:47:17) + at Module._compile (node:internal/modules/cjs/loader:1688:14) + at Object..js (node:internal/modules/cjs/loader:1820:10) + at Module.load (node:internal/modules/cjs/loader:1423:32) + at Function._load (node:internal/modules/cjs/loader:1246:12) + at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) + at Module._compile (node:internal/modules/cjs/loader:1688:14) { + errorCode: 'INVALID_KEY' +} +[dotenv@17.3.1] injecting env (4) from .env -- tip: βš™οΈ specify custom .env file path with { path: '/custom/path/.env' } +DisTubeError [INVALID_KEY]: 'ffmpegPath' does not need to be provided in DisTubeOptions + at checkInvalidKey (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1288:25) + at new Options (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1692:5) + at new DisTube (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2281:20) + at Object. (/home/ubuntu/executor/workspace/bot/index.js:47:17) + at Module._compile (node:internal/modules/cjs/loader:1688:14) + at Object..js (node:internal/modules/cjs/loader:1820:10) + at Module.load (node:internal/modules/cjs/loader:1423:32) + at Function._load (node:internal/modules/cjs/loader:1246:12) + at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) + at Module._compile (node:internal/modules/cjs/loader:1688:14) { + errorCode: 'INVALID_KEY' +} +[dotenv@17.3.1] injecting env (4) from .env -- tip: βš™οΈ write to custom object with { processEnv: myObject } +DisTubeError [INVALID_KEY]: 'ffmpegPath' does not need to be provided in DisTubeOptions + at checkInvalidKey (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1288:25) + at new Options (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1692:5) + at new DisTube (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2281:20) + at Object. (/home/ubuntu/executor/workspace/bot/index.js:47:17) + at Module._compile (node:internal/modules/cjs/loader:1688:14) + at Object..js (node:internal/modules/cjs/loader:1820:10) + at Module.load (node:internal/modules/cjs/loader:1423:32) + at Function._load (node:internal/modules/cjs/loader:1246:12) + at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) + at Module._compile (node:internal/modules/cjs/loader:1688:14) { + errorCode: 'INVALID_KEY' +} +[dotenv@17.3.1] injecting env (4) from .env -- tip: βš™οΈ specify custom .env file path with { path: '/custom/path/.env' } +DisTubeError [INVALID_KEY]: 'ffmpegPath' does not need to be provided in DisTubeOptions + at checkInvalidKey (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1288:25) + at new Options (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1692:5) + at new DisTube (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2281:20) + at Object. (/home/ubuntu/executor/workspace/bot/index.js:47:17) + at Module._compile (node:internal/modules/cjs/loader:1688:14) + at Object..js (node:internal/modules/cjs/loader:1820:10) + at Module.load (node:internal/modules/cjs/loader:1423:32) + at Function._load (node:internal/modules/cjs/loader:1246:12) + at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) + at Module._compile (node:internal/modules/cjs/loader:1688:14) { + errorCode: 'INVALID_KEY' +} +[dotenv@17.3.1] injecting env (4) from .env -- tip: βš™οΈ load multiple .env files with { path: ['.env.local', '.env'] } +DisTubeError [INVALID_KEY]: 'ffmpegPath' does not need to be provided in DisTubeOptions + at checkInvalidKey (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1288:25) + at new Options (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:1692:5) + at new DisTube (/home/ubuntu/executor/workspace/bot/node_modules/distube/dist/index.js:2281:20) + at Object. (/home/ubuntu/executor/workspace/bot/index.js:47:17) + at Module._compile (node:internal/modules/cjs/loader:1688:14) + at Object..js (node:internal/modules/cjs/loader:1820:10) + at Module.load (node:internal/modules/cjs/loader:1423:32) + at Function._load (node:internal/modules/cjs/loader:1246:12) + at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) + at Module._compile (node:internal/modules/cjs/loader:1688:14) { + errorCode: 'INVALID_KEY' +} +[dotenv@17.3.1] injecting env (4) from .env -- tip: πŸ” prevent committing .env to code: https://dotenvx.com/precommit +[2026-02-16T08:08:04.055Z] Encryption library (libsodium) is ready. +Encryption library (libsodium) is ready. +[2026-02-16T08:08:05.553Z] Bot berhasil login! +Bot berhasil login! +[2026-02-16T08:08:05.555Z] Ready! Logged in as AsepXiaoQin#6954 +[2026-02-16T08:08:05.558Z] FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg +Ready! Logged in as AsepXiaoQin#6954 +FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg +[2026-02-16T08:08:06.805Z] Alarm scheduled at 30 3 * * * +Alarm scheduled at 30 3 * * * +[dotenv@17.3.1] injecting env (4) from .env -- tip: πŸ›‘οΈ auth for agents: https://vestauth.com +[2026-02-16T08:08:28.564Z] Encryption library (libsodium) is ready. +Encryption library (libsodium) is ready. +[2026-02-16T08:08:30.304Z] Bot berhasil login! +[2026-02-16T08:08:30.304Z] Ready! Logged in as AsepXiaoQin#6954 +[2026-02-16T08:08:30.305Z] FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg +Bot berhasil login! +Ready! Logged in as AsepXiaoQin#6954 +FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg +[2026-02-16T08:08:30.810Z] Alarm scheduled at 30 3 * * * +Alarm scheduled at 30 3 * * * diff --git a/bot/index.js b/bot/index.js index f59e062..e21d8b5 100644 --- a/bot/index.js +++ b/bot/index.js @@ -3,6 +3,12 @@ const { DisTube } = require('distube'); const { YtDlpPlugin } = require('@distube/yt-dlp'); const { SoundCloudPlugin } = require('@distube/soundcloud'); const { SpotifyPlugin } = require('@distube/spotify'); +const { + joinVoiceChannel, + createAudioPlayer, + createAudioResource, + AudioPlayerStatus +} = require('@discordjs/voice'); const { CronJob } = require('cron'); const path = require('path'); const fs = require('fs'); @@ -49,7 +55,7 @@ const distube = new DisTube(client, { }); const VC_ID = process.env.VC_ID; -const AUDIO_PATH = path.join(__dirname, 'assets/audio/sahur.mp3'); +const AUDIO_PATH = path.join(__dirname, 'assets', 'audio', 'sahur.mp3'); const PREFIX = '!'; function logToFile(message) { @@ -62,6 +68,41 @@ function logToFile(message) { console.log(message); } +async function playLocalIndependent(channel) { + if (!fs.existsSync(AUDIO_PATH)) { + logToFile(`Audio file not found: ${AUDIO_PATH}`); + return; + } + + try { + // Leave DisTube first to avoid collision + await distube.voices.leave(channel.guild.id); + + const connection = joinVoiceChannel({ + channelId: channel.id, + guildId: channel.guild.id, + adapterCreator: channel.guild.voiceAdapterCreator, + }); + + const player = createAudioPlayer(); + const resource = createAudioResource(AUDIO_PATH); + + player.play(resource); + connection.subscribe(player); + + player.on(AudioPlayerStatus.Idle, () => { + connection.destroy(); + }); + + player.on('error', error => { + logToFile(`Audio Player Error: ${error.message}`); + connection.destroy(); + }); + } catch (err) { + logToFile(`Independent play error: ${err.message}`); + } +} + client.once(Events.ClientReady, () => { logToFile(`Bot berhasil login!`); logToFile(`Ready! Logged in as ${client.user.tag}`); @@ -86,14 +127,8 @@ client.once(Events.ClientReady, () => { const channel = guild.channels.cache.get(VC_ID); if (channel && fs.existsSync(AUDIO_PATH)) { try { - // Use DisTube to play alarm - await distube.voices.join(channel, { selfDeaf: false, selfMute: false }); - await distube.play(channel, AUDIO_PATH, { - textChannel: guild.systemChannel || undefined, - skip: true, - member: guild.members.me || undefined - }); - logToFile('Alarm playing via DisTube.'); + await playLocalIndependent(channel); + logToFile('Alarm playing via independent @discordjs/voice.'); } catch (err) { logToFile(`Alarm play error: ${err.message}`); } @@ -125,15 +160,9 @@ client.on(Events.InteractionCreate, async interaction => { if (!fs.existsSync(AUDIO_PATH)) return interaction.reply({ content: `File audio tidak ditemukan di ${AUDIO_PATH}`, ephemeral: true }); await interaction.deferReply(); - logToFile(`Playing local file via DisTube: ${AUDIO_PATH}`); + logToFile(`Playing local file independently: ${AUDIO_PATH}`); try { - await distube.voices.join(voiceChannel, { selfDeaf: false, selfMute: false }); - await distube.play(voiceChannel, AUDIO_PATH, { - member: interaction.member, - textChannel: interaction.channel, - interaction, - skip: true - }); + await playLocalIndependent(voiceChannel); await interaction.editReply('Memainkan suara sahur... πŸ“’'); } catch (e) { logToFile(`Error in testsahur: ${e.message}`); @@ -219,13 +248,7 @@ client.on(Events.MessageCreate, async message => { } else if (command === 'testsahur') { if (!voiceChannel) return message.reply('Anda harus berada di voice channel!'); try { - await distube.voices.join(voiceChannel, { selfDeaf: false, selfMute: false }); - await distube.play(voiceChannel, AUDIO_PATH, { - member: message.member, - textChannel: message.channel, - message, - skip: true - }); + await playLocalIndependent(voiceChannel); message.reply('Mengetes suara sahur... πŸ“’'); } catch (e) { message.reply(`❌ Error: ${e.message}`); @@ -246,11 +269,11 @@ distube queue.textChannel.send(`βœ… **${song.name}** ditambahkan ke antrean oleh ${song.user}`); }) .on('error', (channel, e) => { - logToFile(`DisTube Error: ${e.message}`); - if (e.message.includes('Sign in to confirm you’re not a bot')) { + logToFile(`DisTube Error: ${e.message || e}`); + if (e.message && e.message.includes('Sign in to confirm you’re not a bot')) { if (channel) channel.send(`❌ YouTube memblokir akses bot. Silakan coba link dari SoundCloud atau Spotify.`); } else if (channel) { - channel.send(`❌ Terjadi kesalahan: ${e.message.slice(0, 2000)}`); + channel.send(`❌ Terjadi kesalahan: ${(e.message || e).toString().slice(0, 2000)}`); } });