diff --git a/bot.log b/bot.log index fa61254..fae7d9a 100644 --- a/bot.log +++ b/bot.log @@ -1,27 +1,8 @@ Bot Starting... -[dotenv@17.3.1] injecting env (2) from .env -- tip: âš™ī¸ load multiple .env files with { path: ['.env.local', '.env'] } +[dotenv@17.3.1] injecting env (2) from .env -- tip: đŸ› ī¸ run anywhere with `dotenvx run -- yourcommand` Keep-Alive aktif di port 8080 Bot logged in as XiaoMao#2565 Memulai refresh slash commands... -(node:19382) DeprecationWarning: The ready event has been renamed to clientReady to distinguish it from the gateway READY event and will only emit under that name in v15. Please use clientReady instead. +(node:20219) DeprecationWarning: The ready event has been renamed to clientReady to distinguish it from the gateway READY event and will only emit under that name in v15. Please use clientReady instead. (Use `node --trace-deprecation ...` to show where the warning was created) Berhasil mendaftarkan slash commands! -(node:19382) Warning: Supplying "ephemeral" for interaction response options is deprecated. Utilize flags instead. -Command /queue diterima dari: rio.xmc -Command /play diterima dari: rio.xmc -/home/ubuntu/executor/workspace/index.js:149 - if (channel) channel.send(`❌ Error: ${e.message.slice(0, 1900)}`); - ^ - -TypeError: Cannot read properties of undefined (reading 'slice') - at DisTube. (/home/ubuntu/executor/workspace/index.js:149:57) - at DisTube.emit (node:events:518:28) - at DisTube.emitError (/home/ubuntu/executor/workspace/node_modules/distube/dist/index.js:2546:10) - at QueueManager.emitError (/home/ubuntu/executor/workspace/node_modules/distube/dist/index.js:154:18) - at #handlePlayingError (/home/ubuntu/executor/workspace/node_modules/distube/dist/index.js:2100:10) - at QueueManager.playSong (/home/ubuntu/executor/workspace/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/node_modules/distube/dist/index.js:2352:24) - at async Client. (/home/ubuntu/executor/workspace/index.js:86:13) - -Node.js v22.18.0 diff --git a/index.js b/index.js index f5fab78..5b378e7 100644 --- a/index.js +++ b/index.js @@ -62,77 +62,78 @@ const commands = [ client.on('interactionCreate', async interaction => { if (!interaction.isChatInputCommand()) return; - // Force Defer: Baris paling pertama setelah pengecekan command - await interaction.deferReply({ ephemeral: false }); + const { commandName } = interaction; - console.log(`Command /${interaction.commandName} diterima dari: ${interaction.user.tag}`); + if (commandName === 'play') { + // PRIORITAS UTAMA: Defer secepat mungkin untuk menghindari timeout + await interaction.deferReply(); + console.log('Command diterima, sedang memproses...'); - // 2. Gunakan Try-Catch: Bungkus semua proses agar bot tidak mati jika error - try { - const { commandName } = interaction; - - // 3. Sinkronisasi Voice: Pastikan user ada di voice channel - if (!interaction.member.voice.channel) { - return interaction.editReply('Kamu harus berada di voice channel untuk menggunakan bot ini!'); - } - - if (commandName === 'play') { + try { const query = interaction.options.getString('query'); + if (!interaction.member.voice.channel) { + return interaction.editReply('Kamu harus berada di voice channel untuk menggunakan bot ini!'); + } + // Memberikan feedback awal await interaction.editReply({ content: `🔍 Sedang mencari lagu: **${query}**...` }); - // 4. Fix DisTube Play: Pemanggilan profesional dengan parameter lengkap await distube.play(interaction.member.voice.channel, query, { textChannel: interaction.channel, member: interaction.member, - interaction // Menyertakan interaksi jika diperlukan oleh plugin + interaction }); - } else if (commandName === 'skip') { - const queue = distube.getQueue(interaction.guild); - if (!queue) return interaction.editReply('❌ Tidak ada lagu yang sedang diputar!'); - - await distube.skip(interaction.guild); - await interaction.editReply('â­ī¸ Lagu berhasil dilewati!'); - - } else if (commandName === 'stop') { - await distube.stop(interaction.guild); - await interaction.editReply('âšī¸ Musik dihentikan dan bot keluar dari voice channel!'); - - } else if (commandName === 'pause') { - const queue = distube.getQueue(interaction.guild); - if (!queue) return interaction.editReply('❌ Tidak ada lagu untuk dijeda!'); - - distube.pause(interaction.guild); - await interaction.editReply('â¸ī¸ Musik berhasil dijeda!'); - - } else if (commandName === 'resume') { - const queue = distube.getQueue(interaction.guild); - if (!queue) return interaction.editReply('❌ Tidak ada lagu untuk dilanjutkan!'); - - distube.resume(interaction.guild); - await interaction.editReply('â–ļī¸ Musik dilanjutkan!'); - - } else if (commandName === 'queue') { - const queue = distube.getQueue(interaction.guild); - if (!queue) return interaction.editReply('📭 Antrean saat ini kosong!'); - - const q = queue.songs - .map((song, i) => `${i === 0 ? 'â–ļī¸ **Memutar:**' : `**${i}.**`} ${song.name} - \`${song.formattedDuration}\``) - .join('\n'); - - await interaction.editReply(`đŸŽļ **Daftar Antrean:**\n${q.slice(0, 2000)}`); + } catch (error) { + console.error('Play Error:', error); + await interaction.editReply({ content: `❌ Terjadi kesalahan: ${error.message}` }); } - } catch (error) { - console.error('Interaction Error:', error); - - // Cek apakah interaksi sudah di-defer atau di-reply untuk menghindari error tambahan - if (interaction.deferred || interaction.replied) { - await interaction.editReply({ content: `❌ Terjadi kesalahan: ${error.message}` }); - } else { - await interaction.reply({ content: `❌ Terjadi kesalahan fatal: ${error.message}`, ephemeral: true }); + } else { + // Untuk command lain, kita tetap gunakan try-catch global + try { + await interaction.deferReply(); + + if (!interaction.member.voice.channel) { + return interaction.editReply('Kamu harus berada di voice channel!'); + } + + if (commandName === 'skip') { + const queue = distube.getQueue(interaction.guild); + if (!queue) return interaction.editReply('❌ Tidak ada lagu yang sedang diputar!'); + await distube.skip(interaction.guild); + await interaction.editReply('â­ī¸ Lagu berhasil dilewati!'); + + } else if (commandName === 'stop') { + await distube.stop(interaction.guild); + await interaction.editReply('âšī¸ Musik dihentikan!'); + + } else if (commandName === 'pause') { + const queue = distube.getQueue(interaction.guild); + if (!queue) return interaction.editReply('❌ Tidak ada antrean!'); + distube.pause(interaction.guild); + await interaction.editReply('â¸ī¸ Musik dijeda!'); + + } else if (commandName === 'resume') { + const queue = distube.getQueue(interaction.guild); + if (!queue) return interaction.editReply('❌ Tidak ada antrean!'); + distube.resume(interaction.guild); + await interaction.editReply('â–ļī¸ Musik dilanjutkan!'); + + } else if (commandName === 'queue') { + const queue = distube.getQueue(interaction.guild); + if (!queue) return interaction.editReply('📭 Antrean kosong!'); + const q = queue.songs + .map((song, i) => `${i === 0 ? 'â–ļī¸' : `${i}.`} ${song.name}`) + .join('\n'); + await interaction.editReply(`đŸŽļ **Antrean:**\n${q.slice(0, 1900)}`); + } + } catch (error) { + console.error('Interaction Error:', error); + if (interaction.deferred || interaction.replied) { + await interaction.editReply({ content: `❌ Error: ${error.message}` }); + } } } });