Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -2,16 +2,32 @@ const mineflayer = require('mineflayer');
|
|
| 2 |
const express = require('express');
|
| 3 |
|
| 4 |
const bot = mineflayer.createBot({
|
| 5 |
-
host:
|
| 6 |
-
port:
|
| 7 |
-
username:
|
| 8 |
-
version: false
|
| 9 |
});
|
| 10 |
|
| 11 |
bot.on('spawn', () => {
|
| 12 |
console.log('✅ Bot đã vào server Minecraft!');
|
|
|
|
| 13 |
});
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
const app = express();
|
| 16 |
-
app.get('/', (req, res) => res.send('Bot đang
|
| 17 |
-
app.listen(7860, () =>
|
|
|
|
|
|
|
|
|
| 2 |
const express = require('express');
|
| 3 |
|
| 4 |
const bot = mineflayer.createBot({
|
| 5 |
+
host: 'movie247.aternos.me',
|
| 6 |
+
port: 33729, // ✅ PORT Aternos chính xác
|
| 7 |
+
username: 'AbcsNoob_AFk_Bot',
|
| 8 |
+
version: false, // để auto detect phiên bản
|
| 9 |
});
|
| 10 |
|
| 11 |
bot.on('spawn', () => {
|
| 12 |
console.log('✅ Bot đã vào server Minecraft!');
|
| 13 |
+
bot.chat('Tôi đã vào server để giữ máy!');
|
| 14 |
});
|
| 15 |
|
| 16 |
+
// Tự động reconnect nếu bị kick hoặc lỗi mạng
|
| 17 |
+
bot.on('end', () => {
|
| 18 |
+
console.log('🔁 Bot bị ngắt, đang reconnect sau 10 giây...');
|
| 19 |
+
setTimeout(() => {
|
| 20 |
+
process.exit(1); // Hugging Face sẽ restart container
|
| 21 |
+
}, 10000);
|
| 22 |
+
});
|
| 23 |
+
|
| 24 |
+
bot.on('error', (err) => {
|
| 25 |
+
console.log('❌ Lỗi bot:', err);
|
| 26 |
+
});
|
| 27 |
+
|
| 28 |
+
// Web để Hugging Face giữ container hoạt động
|
| 29 |
const app = express();
|
| 30 |
+
app.get('/', (req, res) => res.send('Bot đang hoạt động 🚀'));
|
| 31 |
+
app.listen(process.env.PORT || 7860, () => {
|
| 32 |
+
console.log('🌐 Web server đang hoạt động tại port 7860');
|
| 33 |
+
});
|