ttt
This commit is contained in:
parent
44e4b520c3
commit
2c5ca6a915
23
bot.log
23
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.<anonymous> (/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.<anonymous> (/home/ubuntu/executor/workspace/index.js:86:13)
|
||||
|
||||
Node.js v22.18.0
|
||||
|
||||
115
index.js
115
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}` });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user