2024-09-18 08:22:03 -04:00
|
|
|
// declarations
|
2024-10-09 23:02:40 -04:00
|
|
|
const wiki = require("wikipedia");
|
|
|
|
const { request } = require("undici");
|
|
|
|
const core = require("./core");
|
|
|
|
const { parseFormatCodes } = require("./pcc");
|
|
|
|
const config = require("./conf");
|
|
|
|
const mc = require('minecraft-protocol');
|
|
|
|
const prefixes = ['radium:', 'r!', 'radium!', 'r/', 'radium/', '⁄€‹›fifl‡°·‚—±Œ„´‰ˇÁ¨ˆØ∏”’»ÅÍÎÏ˝ÓÔÒÚƸ˛Ç◊ı˜Â¯˘¿¡™£¢∞¶•ªº–≠œ∑´®†¥¨ˆøπ“‘«åß∂ƒ©˙∆˚¬…æΩ≈ç√∫˜µ≤≥÷'.split('')].flat();
|
2024-09-18 08:22:03 -04:00
|
|
|
|
|
|
|
// random name function
|
2024-10-09 23:02:40 -04:00
|
|
|
function random(length) {
|
2024-09-18 08:22:03 -04:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
// bot creation
|
2024-10-09 23:02:40 -04:00
|
|
|
var bots = []
|
|
|
|
var client = mc.createClient
|
|
|
|
(
|
|
|
|
{
|
|
|
|
host: "chipmunk.land",
|
|
|
|
port: 25565,
|
|
|
|
username: "§§§§§§§§§§§§§§§§",
|
|
|
|
version: "1.20"
|
|
|
|
}
|
|
|
|
);
|
2024-09-18 08:22:03 -04:00
|
|
|
// add core
|
2024-10-09 23:02:40 -04:00
|
|
|
client.on("login", async () => {
|
2024-09-18 08:22:03 -04:00
|
|
|
core.injectTo(client)
|
|
|
|
setInterval(() => {
|
|
|
|
client.cmdCore.refillCmdCore()
|
|
|
|
}, 60000);
|
2024-10-09 23:02:40 -04:00
|
|
|
client.chat(`/extras:prefix &c[&6Prefix: ${prefixes[0]}&c]`)
|
|
|
|
await sleep(150);
|
|
|
|
client.chat(`/essentials:nickname &6RadiumBot`)
|
|
|
|
await sleep(150);
|
|
|
|
client.chat(`/commandspy:commandspy on`)
|
2024-09-19 09:54:55 -04:00
|
|
|
});
|
2024-09-18 08:22:03 -04:00
|
|
|
|
2024-10-09 23:02:40 -04:00
|
|
|
// sleep function
|
|
|
|
async function sleep(ms) {
|
|
|
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
|
|
}
|
|
|
|
|
|
|
|
// chat logging
|
|
|
|
const registry = require('prismarine-registry')('1.16')
|
|
|
|
const ChatMessage = require('prismarine-chat')(registry)
|
|
|
|
client.on("playerChat", ({ senderName, plainMessage, unsignedContent, formattedMessage, verified }) => {
|
|
|
|
try {
|
|
|
|
var msg = new ChatMessage(JSON.parse(unsignedContent))
|
|
|
|
console.log(parseFormatCodes("&c[&6Player Chat&c] ") + msg.toAnsi());
|
|
|
|
} catch (err) {
|
|
|
|
console.log(parseFormatCodes("&c[&6Error&c] ") + err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
client.on("systemChat", async ({ formattedMessage, positionId }) => {
|
|
|
|
try {
|
|
|
|
var msg = new ChatMessage(JSON.parse(formattedMessage))
|
|
|
|
console.log(parseFormatCodes("&c[&6System Chat&c] ") + msg.toAnsi());
|
|
|
|
} 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
|
|
|
|
require("readline").createInterface(process.stdin, process.stdout).on("line", (line) => {
|
|
|
|
client.chat(line);
|
|
|
|
})
|
|
|
|
|
2024-09-18 08:22:03 -04:00
|
|
|
// create functions
|
2024-10-09 23:02:40 -04:00
|
|
|
function tellraw(players, jsonMessage) {
|
|
|
|
client.cmdCore.run(`minecraft:tellraw ${players} ${jsonMessage}`);
|
|
|
|
};
|
2024-09-18 08:22:03 -04:00
|
|
|
|
2024-10-09 23:02:40 -04:00
|
|
|
function commandError(players, errorTitle, otherthing) {
|
|
|
|
tellraw(players, JSON.stringify
|
2024-09-18 08:22:03 -04:00
|
|
|
(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"text": errorTitle + "\n",
|
|
|
|
"color": "red"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"text": otherthing,
|
|
|
|
"color": "gray"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"text": "<--[HERE]",
|
|
|
|
"color": "red",
|
|
|
|
"italic": true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
)
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
const chatListener = function ({ senderName, plainMessage, unsignedContent, formattedMessage, verified }) {
|
|
|
|
for (const prefix of prefixes) {
|
|
|
|
if (`${plainMessage}`.startsWith(prefix)) {
|
|
|
|
const args = `${plainMessage}`.slice(prefix.length).trim().split(/ +/);
|
|
|
|
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 () => {
|
|
|
|
tellraw("@a", JSON.stringify
|
|
|
|
(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"text": "Radium » List of commands (" + Object.keys(cmds).length + "):\n" + Object.keys(cmds).join(" | ")
|
|
|
|
}
|
|
|
|
]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
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 () => {
|
|
|
|
tellraw("@a", JSON.stringify(`Prefixes (${prefixes.length}): ` + prefixes.join(" | ")));
|
|
|
|
},
|
|
|
|
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))
|
|
|
|
}
|
|
|
|
}; 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);
|
|
|
|
}); // idfk what this does
|