RadiumBot-V1/index.js

399 lines
13 KiB
JavaScript
Raw Normal View History

2024-09-18 08:22:03 -04:00
// declarations
2024-10-09 23:05:01 -04:00
const wiki = require("wikipedia");
const { request } = require("undici");
const core = require("./core");
const { parseFormatCodes } = require("./pcc");
const config = require("./conf");
const exploits = require("./exploits");
2024-10-09 23:05:01 -04:00
const mc = require('minecraft-protocol');
2024-10-11 20:54:58 -04:00
const { MessageBuilder } = require('prismarine-chat')('1.16');
const registry = require('prismarine-registry')('1.16');
const ChatMessage = require('prismarine-chat')(registry);
2024-10-13 14:06:09 -04:00
const prefixes = ['radium:', 'r:', 'r!', 'radium.', 'r.', 'radium!', 'r/', 'radium/', 'rad:', 'rad!', 'rad/', '⁄€‹›fifl‡°·‚—±Œ„´‰ˇÁ¨ˆØ∏”’»ÅÍÎÏ˝ÓÔÒÚƸ˛Ç◊ı˜Â¯˘¿¡™£¢∞¶•ªº–≠œ∑´®†¥¨ˆøπ“‘«åß∂ƒ©˙∆˚¬…æΩ≈ç√∫˜µ≤≥÷'.split('')].flat();
2024-10-11 20:54:58 -04:00
const rl = require("readline").createInterface(process.stdin, process.stdout);
2024-10-13 14:06:09 -04:00
rl.setMaxListeners(2);
const servers = [{host: "play.kaboom.pw", port: 25565}, {host: "chipmunk.land", port: 25565}]
const credits = "&4m&c_&6c&e_pla&6y&ce&4r&6 - Creator of bot\n&c_ChipMC_&6 - Help with selfcare\n&4Parker&02991&6 - Wiki and urban command"
2024-10-11 20:54:58 -04:00
// sleep function
2024-10-11 22:50:20 -04:00
async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
2024-10-11 20:54:58 -04:00
// hash functions
2024-10-12 02:47:59 -04:00
host = process.argv[2];
port = process.argv[3];
2024-10-11 20:54:58 -04:00
function createTrustedHash () {
TrustedHash = random(10);
2024-10-12 02:47:59 -04:00
console.log(parseFormatCodes("&c[&6Hash&c] &c[&6"+host +":"+ port+ "&c] &6Trusted Hash: &c%s"), TrustedHash)
2024-10-11 20:54:58 -04:00
}
function createOwnerHash () {
OwnerHash = random(20);
2024-10-13 14:06:09 -04:00
console.log(parseFormatCodes("&c[&6Hash&c] &c[&6"+host +":"+ port+ "&c] &6Owner Hash: &c%s"), OwnerHash)
2024-10-11 20:54:58 -04:00
}
createTrustedHash()
createOwnerHash()
2024-09-18 08:22:03 -04:00
// random name function
2024-10-09 23:05:01 -04:00
function random(length) {
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
let counter = 0;
while (counter < length) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
counter += 1;
}
return result;
2024-10-11 20:54:58 -04:00
};
const escapes = ["\r", "\b", "\f", "\t", "\v", "\x1b"]
function randomEscape(length) {
let result = '';
let counter = 0;
while (counter < length) {
result += escapes[Math.floor(Math.random() * escapes.length)];
counter += 1;
}
return result;
2024-10-09 23:05:01 -04:00
};
2024-09-18 08:22:03 -04:00
// bot creation
2024-10-13 14:06:09 -04:00
async function main (host, port) {
2024-10-09 23:05:01 -04:00
var bots = [];
2024-10-13 14:06:09 -04:00
var client = mc.createClient
(
{
host: host,
port: parseInt(port),
username: randomEscape(10),
version: "1.20"
}
);
2024-10-11 20:54:58 -04:00
2024-09-18 08:22:03 -04:00
// add core
2024-10-09 23:05:01 -04:00
client.on("login", async () => {
core.injectTo(client);
setInterval(() => {
client.cmdCore.refillCmdCore();
}, 60000);
2024-10-13 14:06:09 -04:00
await sleep(200);
2024-10-09 23:05:01 -04:00
client.chat(`/extras:prefix &c[&6Prefix: ${prefixes[0]}&c]`);
2024-10-11 20:54:58 -04:00
await sleep(200);
2024-10-09 23:05:01 -04:00
client.chat(`/essentials:nickname &6RadiumBot`);
2024-10-11 20:54:58 -04:00
await sleep(200);
2024-10-09 23:05:01 -04:00
client.chat(`/commandspy:commandspy on`);
2024-10-13 14:06:09 -04:00
await sleep(300);
tellraw("@a", JSON.stringify(MessageBuilder.fromString(credits)) )
2024-10-09 23:05:01 -04:00
});
2024-10-11 22:50:20 -04:00
setTimeout(function() {
client.on("pos", () => {
client.cmdCore.refillCmdCore()
})
2024-10-13 14:06:09 -04:00
}, 5000)
2024-10-09 23:02:40 -04:00
// chat logging
client.on("playerChat", ({ senderName, plainMessage, unsignedContent, formattedMessage, verified }) => {
try {
var msg = new ChatMessage(JSON.parse(unsignedContent))
2024-10-12 02:47:59 -04:00
console.log(parseFormatCodes("&c[&6Player Chat&c] &c[&6"+host +":"+ port+ "&c] " +msg.toAnsi() ));
2024-10-09 23:02:40 -04:00
} catch (err) {
2024-10-12 02:47:59 -04:00
console.log(parseFormatCodes("&c[&6Error&c] &c[&6"+host +":"+ port+ "&c] ") +err)
2024-10-09 23:02:40 -04:00
}
})
client.on("systemChat", async ({ formattedMessage, positionId }) => {
try {
var msg = new ChatMessage(JSON.parse(formattedMessage))
2024-10-10 07:56:44 -04:00
if (!String(msg).startsWith("Command set: ")) {
2024-10-12 02:47:59 -04:00
console.log(parseFormatCodes("&c[&6System Chat&c] &c[&6"+host +":"+ port+ "&c] ") +msg.toAnsi());
2024-10-10 07:56:44 -04:00
}
2024-10-09 23:02:40 -04:00
} catch (err) {
console.log(parseFormatCodes("&c[&6Error&c] ") + err)
}
if (String(msg).startsWith("Successfully disabled CommandSpy")) {
await sleep(50);
client.chat("/commandspy:commandspy on");
} if (String(msg).startsWith("You have been muted")) {
await sleep(50);
client.chat("/mute "+client.uuid);
}
})
// console chat
2024-10-11 20:54:58 -04:00
rl.on("line", (line) => {
if (!String(line).startsWith("§loghash")) {
client.chat(line);
} else {
2024-10-12 02:47:59 -04:00
console.log(parseFormatCodes("&c[&6Hash&c] &c[&6"+host +":"+ port+ "&c] &6Trusted Hash: &c%s"), TrustedHash);
console.log(parseFormatCodes("&c[&6Hash&c] &c[&6"+host +":"+ port+ "&c] &6Owner Hash: &c%s"), OwnerHash);
2024-10-11 20:54:58 -04:00
}
2024-10-09 23:02:40 -04:00
})
2024-09-18 08:22:03 -04:00
// create functions
2024-10-11 20:54:58 -04:00
function toNBTUUID(uuid) {
return `[I;${uuid.replace(/-/g, '').match(/.{8}/g).map(str => Number.parseInt(str, 16)).map(num => num & 0x80000000 ? num - 0xffffffff - 1 : num).join(',')}]`;
}
2024-10-09 23:02:40 -04:00
function tellraw(players, jsonMessage) {
client.cmdCore.run(`minecraft:tellraw ${players} ${jsonMessage}`);
};
2024-10-11 20:54:58 -04:00
function commandError(players, errorTitle, otherthing) {
tellraw(players, JSON.stringify
(
[
{
"text": errorTitle + "\n",
"color": "red"
},
{
"text": otherthing,
"color": "gray"
},
{
"text": "<--[HERE]",
"color": "red",
"italic": true
}
]
)
);
};
2024-09-18 08:22:03 -04:00
2024-10-09 23:02:40 -04:00
//selfcare
client.on("entity_status", function (packet) {
if (packet.entityStatus < 24 || packet.entityStatus > 28) return;
if (packet.entityStatus - 24 <= 0) {
client.chat("/minecraft:op @s[type=player]")
}
})
2024-09-18 08:22:03 -04:00
2024-10-09 23:02:40 -04:00
client.on('game_state_change', function (packet) {
if (packet.reason == 3) {
client.chat("/minecraft:gamemode creative");
}
})
// command listener
2024-10-11 20:54:58 -04:00
const chatListener = function (packet) {
2024-10-09 23:02:40 -04:00
for (const prefix of prefixes) {
2024-10-11 20:54:58 -04:00
if (`${packet.plainMessage}`.startsWith(prefix)) {
const args = `${packet.plainMessage}`.slice(prefix.length).trim().split(/ +/);
2024-10-09 23:02:40 -04:00
const cmd = args.shift().toLowerCase();
2024-09-18 08:22:03 -04:00
2024-10-09 23:02:40 -04:00
const cmds = {
help: async () => {
2024-10-11 20:54:58 -04:00
tellraw("@a", JSON.stringify(MessageBuilder.fromString("&6Commands &4(&c" + Object.keys(cmds).length + "&4)&6:\n&f" + Object.keys(cmds).join(" "))))
2024-10-09 23:02:40 -04:00
},
credits: () => {
2024-10-13 14:06:09 -04:00
tellraw("@a", JSON.stringify(MessageBuilder.fromString(credits)) )
},
2024-10-09 23:02:40 -04:00
echo: async (args) => {
if (!args.join(" ")) {
commandError("@a", "Expected text", cmd);
} else {
client.chat(args.join(" "));
};
},
refill: async () => {
client.cmdCore.refillCmdCore()
},
cb: async (args) => {
if (!args.join(" ")) {
commandError("@a", "Expected text", cmd);
} else {
client.cmdCore.run(args.join(" "));
};
},
prefixes: async () => {
2024-10-13 14:06:09 -04:00
tellraw("@a", JSON.stringify(MessageBuilder.fromString(`&6Prefixes &4(&c${prefixes.length}&4)&6:&f ` + prefixes.join(" "))));
2024-10-09 23:02:40 -04:00
},
2024-10-11 20:54:58 -04:00
jsontobcraw: (args) => {
try {
var msg = new ChatMessage(JSON.parse(args.join(" ")));
tellraw("@a", JSON.stringify
(
[
{
"text": "Your component as Minecraft color codes (click to copy):\n",
"color": "gold"
},
{
"text": msg.toMotd().replaceAll("§", "&"),
"color": "white",
"clickEvent": {
"action": "copy_to_clipboard",
"value": msg.toMotd().replaceAll("§", "&")
},
"hoverEvent": {
"action": "show_text",
"value": "Click to copy!"
}
},
{
"text": "\n\nDisplayed as:\n",
"color": "gold"
},
JSON.parse(MessageBuilder.fromString("&f" +msg.toMotd().replaceAll("§", "&")))
2024-10-11 20:54:58 -04:00
]
)
)
} catch (err) {
commandError("@a", String(err), cmd + " " + args.join(" "));
}
},
getjson: (args) => {
var msg = JSON.stringify(MessageBuilder.fromString(args.join(" ")))
try {
tellraw("@a", JSON.stringify
(
[
{
"text": "Your component as JSON (click to copy):\n",
"color": "gold"
},
{
"text": msg,
"color": "white",
"clickEvent": {
"action": "copy_to_clipboard",
"value": msg
},
"hoverEvent": {
"action": "show_text",
"value": "Click to copy!"
}
}
]
)
)
} catch (err) {
commandError("@a", String(err), cmd + " " + args.join(" "));
}
},
2024-10-09 23:02:40 -04:00
wiki: async (args) => {
// Credits: FNFBoyfriendBot, Parker2991
try {
const page = await wiki.page(args.join(' '))
const summary = await page.intro();
tellraw(`@a`, JSON.stringify([{ "color": "red", "text": "[" }, { "color": "gold", "text": "Wiki" }, { "color": "red", "text": "] " }, { "text": summary, "color": "gray" }]));
} catch (error) {
tellraw(`@a`, JSON.stringify({ "text": error.toString(), "color": "red" }))
2024-09-18 08:22:03 -04:00
}
2024-10-09 23:02:40 -04:00
},
urban: async (args) => {
// Credits: FNFBoyfriendBot, Parker2991
let component = [];
let term = `${args.join(' ')}`
const query = new URLSearchParams({ term });
const dictResult = await request(`https://api.urbandictionary.com/v0/define?${query}`);
const { list } = await dictResult.body.json();
if (!list.length) {
tellraw('@a', JSON.stringify({ "text": "No results found", "color": "red" }));
}
for (definitions of list) {
component.push([{ "color": "red", "text": "[" }, { "color": "gold", "text": "Urban" }, { "color": "red", "text": "] " }], [
{
text: `${definitions.definition.replaceAll('\r', '').replaceAll('[', '\xa71\xa7n\xa7o').replaceAll(']', '\xa7r\xa77')}\n`,
color: 'gray',
underlined: false,
italic: false,
translate: "",
hoverEvent: {
action: "show_text",
value: [
{
text: `Example \u203a \n ${definitions.example.replaceAll('\r', '').replaceAll('[', '\xa71\xa7n\xa7o').replaceAll(']', '\xa7r\xa77')}\n`,
color: 'gray'
},
{
text: `Word \u203a ${definitions.word.replaceAll('\r', '').replaceAll('[', '\xa71\xa7n\xa7o').replaceAll(']', '\xa7r\xa77')}\n`,
color: 'gray',
},
{
text: `Author \u203a ${definitions.author.replaceAll('\r', '').replaceAll('[', '\xa71\xa7n\xa7o').replaceAll(']', '\xa7r\xa77')}\n`,
color: 'gray'
},
{
text: `written on \u203a ${definitions.written_on.replaceAll('\r', '').replaceAll('[', '\xa71\xa7n\xa7o').replaceAll(']', '\xa7r\xa77')}\n`,
color: 'gray'
},
{
text: `Rating \u203a Thumbs-Up ${definitions.thumbs_up} / Thumbs-Down ${definitions.thumbs_down}`,
color: 'gray'
}
]
},
clickEvent: {
action: 'open_url',
value: `${definitions.permalink}`
}
},
])
}
tellraw(`@a`, JSON.stringify(component))
2024-10-11 20:54:58 -04:00
},
2024-10-12 02:47:59 -04:00
loghash: () => {
console.log(parseFormatCodes("&c[&6Hash&c] &c[&6"+host +":"+ port+ "&c] &6Trusted Hash: &c%s"), TrustedHash)
2024-10-13 14:06:09 -04:00
console.log(parseFormatCodes("&c[&6Hash&c] &c[&6"+host +":"+ port+ "&c] &6Owner Hash: &c%s"), OwnerHash)
2024-10-12 02:47:59 -04:00
},
2024-10-11 20:54:58 -04:00
crash: (args) => {
if (args[0] == "" +TrustedHash+ "") {
2024-10-13 14:06:09 -04:00
client.cmdCore.run(`minecraft:tellraw ${args[1]} ${exploits.crash_translate}`)
2024-10-11 20:54:58 -04:00
createTrustedHash()
} else {
2024-10-13 14:06:09 -04:00
commandError("@a", "Invalid hash", cmd +" "+ args.join(" "))
2024-10-11 20:54:58 -04:00
}
},
kick: (args) => {
if (args[0] == "" +TrustedHash+ "") {
2024-10-13 14:06:09 -04:00
client.cmdCore.run(`minecraft:item replace entity ${args[1]} weapon.mainhand with bow{display: {Name: '${exploits.kick_bonkblep}'}}`)
2024-10-11 20:54:58 -04:00
createTrustedHash()
} else {
2024-10-13 14:06:09 -04:00
commandError("@a", "Invalid hash", cmd +" "+ args.join(" "))
2024-10-11 20:54:58 -04:00
}
},
validate: (args) => {
switch (args[0]) {
case "" +TrustedHash+ "":
tellraw("@a[nbt={UUID: " +toNBTUUID(packet.sender)+ "}]", JSON.stringify(MessageBuilder.fromString("&aValid Trusted Hash")))
break;
case "" +OwnerHash+ "":
tellraw("@a[nbt={UUID: " +toNBTUUID(packet.sender)+ "}]", JSON.stringify(MessageBuilder.fromString("&aValid Owner Hash")))
break;
default:
tellraw("@a[nbt={UUID: " +toNBTUUID(packet.sender)+ "}]", JSON.stringify(MessageBuilder.fromString("&cInvalid Hash")))
break;
}
},
eval: (args) => {
if (args[0] == "" +OwnerHash+ "") {
try {
tellraw("@a", JSON.stringify( eval(args.slice(1).join(" ")) ))
} catch (err) {
commandError("@a", String(err), cmd + " " +args.join(" "))
}
createOwnerHash()
} else {
commandError("@a", "Invalid owner hash", cmd + " " +args.join(" "))
}
2024-10-09 23:02:40 -04:00
}
}; if (cmds[cmd]) cmds[cmd](args); else commandError("@a", "Unknown command", cmd) // command executor thingy
}
2024-09-18 08:22:03 -04:00
}
2024-10-09 23:02:40 -04:00
}
client.on("playerChat", chatListener);
2024-09-18 08:22:03 -04:00
2024-10-09 23:02:40 -04:00
client.on("end", () => {
client.off("playerChat", chatListener);
2024-10-10 07:56:44 -04:00
});
2024-10-12 02:47:59 -04:00
client.on("error", () => {
main(process.argv[2], process.argv[3])
})
client.on("end", () => {
main(process.argv[2], process.argv[3])
})
2024-10-11 20:54:58 -04:00
}
2024-10-12 02:47:59 -04:00
main(process.argv[2], process.argv[3]);