forked from jandoedel-coder/MineflayerAFKbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (37 loc) · 1.32 KB
/
Copy pathindex.js
File metadata and controls
41 lines (37 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const mineflayer = require('mineflayer')
const express = require('express')
const app = express()
const port = 3000
app.get('/addbot', (req, res) => {
try {
const { ip, username, password, port, version, auth } = req.headers;
const commonOptions = { host: ip, username, password, version };
let botOptions;
switch (auth) {
case 'premium':
if (req.header('auth') === 'ms') {
botOptions = { ...commonOptions, port, auth: 'microsoft' };
} else if (req.header('auth') === 'mojang') {
botOptions = { ...commonOptions, port, auth: 'mojang' };
}
break;
case 'cracked':
botOptions = { ...commonOptions };
break;
}
if (botOptions) {
const bot = mineflayer.createBot(botOptions);
bot.on('kicked', console.log);
bot.on('error', console.log);
res.send(`Logged in on ${ip} with username ${username}`);
} else {
throw new Error('Invalid authentication method');
}
} catch (error) {
console.error(error);
res.status(500).send('Internal server error');
}
});
app.listen(port || 3000, () => {
console.log(`🔥 Server online at 127.0.0.1:${port}`)
})