Compare commits

..
3 Commits
Author SHA1 Message Date
Parker2991 5d9787e57b Update index.js 2024-02-12 15:58:39 -05:00
Parker2991 707b314e25 v0.2 2024-02-12 20:53:52 +00:00
Parker2991 d42c88ae91 v0.1 2024-02-12 20:47:20 +00:00
102 changed files with 453 additions and 15367 deletions
-3
View File
@@ -1,4 +1 @@
node_modules
config.js
.git
src/modules/exploits.js
-17
View File
@@ -1,17 +0,0 @@
# FNFBoyfriendBot
some things were git ignored from the repo that are needed for some things to work so you gotta recreate them
FNFBoyfriendBot is a minecraft java bot made for the server kaboom.pw
# Setup:
1. make sure to have nodejs npm and git installed
2. run npm i
3. fix some modules and stuff
4. edit the config
5. node src
-17
View File
@@ -1,17 +0,0 @@
Note: each time changes are made push them to the dev branch in the bots repo
1. Rewrite the version argument of the info command
2. Fix arguments for discord
3. Try adding a argument limit for commands maybe
4. Use the nbt parser that chayapak wrote for the bot for 1.21.5 command block output
5. Completely remove tptoggle selfcare since it’s no longer used
- 6. Have the bot get output from the actual core instead of a command block it places
- 7. Add support for 1.21 and 1.21.1 while keeping support for 1.19.3 to 1.20.2
8. Add a server check
9. Add source.sendfeedback back maybe
10. Add a check to sendFeedback for discord to see if the message length is longer than discord’s max message limit to output it to a file and then reply with the file in discord
11. Add a embed function for discord maybe
12. Have the bot output errors to a seperate file to make debugging easier
- 13. Revert class changes for usernameGen, loadModules, between, and ansi since it wouldn’t make much sense to make them classes instead of functions (chayapaks suggestion)
- 14. Have the bot.js class extend the event emitter (chayapak suggestion)
15. Maybe parse cspy in the chat module and emit it as a packet maybe
16. For the owner check module have the bot send a message to the player username thats in the config if the 18. username name is online and if theres no reply back in discord within 10 seconds (10000 ms) to start deoping, muting, kicking, and changing their gamemode
+453
View File
@@ -0,0 +1,453 @@
const mineflayer = require('mineflayer')
var server = 'sus.shhnowisnottheti.me'
const randomstring = require('randomstring');
const bot = mineflayer.createBot({
host: server,
port: 25565,
username: randomstring.generate(8),
version: 1.17,
})
var sleep=t=>new Promise(a=>setTimeout(a,t)),
sendChat=async function(m){bot.chat(m.slice(0,256));await sleep(300);}
function between(min, max) {
return Math.floor(
Math.random() * (max - min) + min
)
}
//variables
var prefix = '&8[&4&lDEMONBOT&8] ';
var consoleprefix = 'bcraw &8[&4DEMONBOT&8] &8[&4&lCONSOLE&8] ';
function randomchar() {
const crypto = require("crypto");
var hash = crypto.createHash("md5");
var randomBytes = crypto.randomBytes(16);
hash.update(randomBytes);
var hashi = hash.digest(Math.round(Math.random()) ? "hex" : "Base64");
return hashi.substring(0, 16);
}
function runInCore(cmd) {
bot._client.write('update_command_block', {location: {x:between(Math.floor(bot.entity.position.x) + 1, Math.floor(bot.entity.position.x) - 15), y:between(0, 3), z:between(Math.floor(bot.entity.position.z) + 1, Math.floor(bot.entity.position.z) - 15)}, command: cmd, mode: 1, flags: 0b100});
}
bot.on('login', async () => { // time in ms
console.log(`logged in as ${bot.username}`)
await sendChat('/tp 6954 100 69642')
await sendChat('/tptoggle')
await sendChat('/online')
await sendChat('/vanish')
await sendChat(`/fill ${Math.floor(bot.entity.position.x)} 0 ${Math.floor(bot.entity.position.z)} ${Math.floor(bot.entity.position.x) - 15} 2 ${Math.floor(bot.entity.position.z - 15)} command_block replace`);
runInCore ('bcraw ' + prefix + 'just went looking around on replit and found this my old bot before i named it the FNFBoyfriendBot but alot of names were considered for it like ParkerBot, DemonBot, WoomyBot, and boyfriendBot but at the end i just named it FNFBoyfriendBot for full release')
//CHANGE COMMAND HERE VVVVVVVVVVVVVVVVVVVV
})
const cmd = require('mineflayer-cmd').plugin
cmd.allowConsoleInput = true // Optional config argument
bot.loadPlugin(cmd)
//kill command function
function killCommand (sender, flags, args) {
return new Promise((resolve, reject) => {
let message = ''
if (flags.showsender) message += sender + ': '
if (flags.color) message += '&' + flags.color[0]
message += args.join(' ')
if(sender == 'Parker2991'){
runInCore('bcraw ' + prefix + 'Kill Cloop Executed')
setInterval(function() { runInCore('ekill ' + message), 1})
resolve()
}
})
}
function freezeCommand (sender, flags, args) {
return new Promise((resolve, reject) => {
let message = ''
if (flags.showsender) message += sender + ': '
if (flags.color) message += '&' + flags.color[0]
message += args.join(' ')
if(sender == 'Parker2991'){
runInCore('bcraw ' + prefix + + ' ' + message + ' Is Frozen')
setInterval(function() { runInCore('tp ' + message + ' ' + message), 1})
resolve()
}
})
}
function deopCommand (sender, flags, args) {
return new Promise((resolve, reject) => {
let message = ''
if (flags.showsender) message += sender + ': '
if (flags.color) message += '&' + flags.color[0]
message += args.join(' ')
if(sender == 'Parker2991'){
runInCore('bcraw ' + prefix + 'Deop Cloop Executed')
setInterval(function() { runInCore('execute run deop ' + message), 1})
resolve()
}
})
}
function deopallCommand (sender, flags, args) {
return new Promise((resolve, reject) => {
let message = ''
if (flags.showsender) message += sender + ': '
if (flags.color) message += '&' + flags.color[0]
message += args.join(' ')
if(sender == 'Parker2991'){
runInCore('bcraw ' + prefix + 'Deop Cloop Executed')
setInterval(function() { runInCore('execute at @a run deop @a'), 1})
setInterval(function() { runInCore('op @s[type=player]'), 1})
resolve()
}
})
}
function survivalCommand (sender, flags, args) {
return new Promise((resolve, reject) => {
let message = ''
if (flags.showsender) message += sender + ': '
if (flags.color) message += '&' + flags.color[0]
message += args.join(' ')
if(sender == 'Parker2991'){
runInCore('bcraw ' + prefix + 'Gamemode Survival For All')
runInCore('execute at @a run gamemode survival @a')
resolve()
}
})
}
function helpCommand (sender, flags, args) {
return new Promise((resolve, reject) => {
let message = ''
if (flags.showsender) message += sender + ': '
if (flags.color) message += '&' + flags.color[0]
message += args.join(' ')
if(sender == 'Parker2991'){
runInCore('bcraw ' + prefix + ' !ckill <player> to spam kill any player ')
runInCore('bcraw ' + prefix + ' !trol <player> to abuse a player ingame')
runInCore('bcraw ' + prefix + ' !deop <player> to deop a player forever')
runInCore('bcraw ' + prefix + ' !icu <player> spam tp a player to you(control them)')
runInCore('bcraw ' + prefix + ' !say <message> make the bot say a message')
runInCore('bcraw ' + prefix + ' !cloop <message> to spam any message')
runInCore('bcraw ' + prefix + ' !troll TROLL THE ENTIRE SERVER')
resolve()
}
})
}
function opCommand (sender, flags, args) {
return new Promise((resolve, reject) => {
let message = ''
if (flags.showsender) message += sender + ': '
if (flags.color) message += '&' + flags.color[0]
message += args.join(' ')
if(sender == 'Parker2991'){
runInCore('bcraw ' + prefix + 'Op Cloop Executed XD')
setInterval(function() { runInCore('execute run op ' + message), 1})
resolve()
}
})
}
function icuCommand (sender, flags, args) {
return new Promise((resolve, reject) => {
let message = ''
if (flags.showsender) message += sender + ': '
if (flags.color) message += '&' + flags.color[0]
message += args.join(' ')
if(sender == 'Parker2991'){
runInCore('bcraw ' + prefix + 'ICU CONTROL HAS STARTED')
setInterval(function() { runInCore('tp ' + message + ' ' + sender), 200})
setInterval(function() { runInCore('deop ' + message), 200})
resolve()
}
})
}
function sayCommand (sender, flags, args) {
return new Promise((resolve, reject) => {
let message = ''
if (flags.showsender) message += sender + ': '
if (flags.color) message += '&' + flags.color[0]
message += args.join(' ')
runInCore(consoleprefix + message)
resolve()
})
}
function sudoCommand (sender, flags, args) {
return new Promise((resolve, reject) => {
let message = ''
if (flags.showsender) message += sender + ': '
if (flags.color) message += '&' + flags.color[0]
message += args.join(' ')
runInCore('sudo ' + message)
resolve()
})
}
function cloopCommand (sender, flags, args) {
return new Promise((resolve, reject) => {
let message = ''
if (flags.showsender) message += sender + ': '
if (flags.color) message += '&' + flags.color[0]
message += args.join(' ')
if(sender == 'Parker2991'){
setInterval(function() { runInCore(message), 1})
runInCore('bcraw ' + prefix + ' Cloop Has Started')
resolve()
}
})
}
function lagCommand (sender, flags, args) {
return new Promise((resolve, reject) => {
let message = ''
if (flags.showsender) message += sender + ': '
if (flags.color) message += '&' + flags.color[0]
message += args.join(' ')
if(sender == 'Parker2991'){
setInterval(function() { runInCore('day'), 1})
setInterval(function() { runInCore('night'), 1})
setInterval(function() { runInCore('clear @a'), 1})
setInterval(function() { runInCore('effect give @a nausea'), 1})
setInterval(function() { runInCore('effect give @a slowness'), 1})
setInterval(function() { runInCore('give @a bedrock'), 1})
setInterval(function() { runInCore('give @a sand'), 1})
setInterval(function() { runInCore('give @a dirt'), 1})
setInterval(function() { runInCore('give @a diamond'), 1})
setInterval(function() { runInCore('give @a tnt'), 1})
setInterval(function() { runInCore('give @a crafting_table'), 1})
setInterval(function() { runInCore('give @a diamond_block'), 1})
setInterval(function() { runInCore('execute run op ' + randomchar), 1})
resolve()
}
resolve()
})
}
function trollCommand (sender, flags, args) {
return new Promise((resolve, reject) => {
let message = ''
if (flags.showsender) message += sender + ': '
if (flags.color) message += '&' + flags.color[0]
message += args.join(' ')
if(sender == 'Parker2991'){
setInterval(function() { runInCore('clear ' + message), 1})
setInterval(function() { runInCore('effect give '+ message + ' nausea'), 1})
setInterval(function() { runInCore('effect give '+ message + ' nausea'), 1})
setInterval(function() { runInCore('give ' + message + ' bedrock'), 1})
setInterval(function() { runInCore('give ' + message + ' diamond'), 1})
setInterval(function() { runInCore('give ' + message + 'tnt'), 1})
setInterval(function() { runInCore('give ' + message + ' diamond_block'), 1})
setInterval(function() { runInCore('give ' + message + ' sand'), 1})
setInterval(function() { runInCore('give ' + message + ' bedrock'), 1})
setInterval(function() { runInCore('execute run deop '+ message), 1})
setInterval(function() { runInCore('gms '+ message), 1})
runInCore('bcraw ' + prefix + ' ' + message + ' Is Getting Trolled')
resolve()
}
})
}
bot.once('cmd_ready', () => {
bot.cmd.registerCommand('troll', lagCommand, // Create a new command called 'say' and set the executor function
'make me say something', // help text
'say <message>') // usage text
// Add a flag called 'color' that expects 1 input
.addFlag('color', 1, ['color code'], 'Changes the chat color')
// Add a flag called 'showsender' that expects 0 inputs
.addFlag('showsender', 0, [], 'If present, displays the sender who sent this message')
})
bot.once('cmd_ready', () => {
bot.cmd.registerCommand('icu', icuCommand, // Create a new command called 'say' and set the executor function
'make me say something', // help text
'say <message>') // usage text
// Add a flag called 'color' that expects 1 input
.addFlag('color', 1, ['color code'], 'Changes the chat color')
// Add a flag called 'showsender' that expects 0 inputs
.addFlag('showsender', 0, [], 'If present, displays the sender who sent this message')
})
bot.once('cmd_ready', () => {
bot.cmd.registerCommand('sudo', sudoCommand, // Create a new command called 'say' and set the executor function
'make me say something', // help text
'say <message>') // usage text
// Add a flag called 'color' that expects 1 input
.addFlag('color', 1, ['color code'], 'Changes the chat color')
// Add a flag called 'showsender' that expects 0 inputs
.addFlag('showsender', 0, [], 'If present, displays the sender who sent this message')
})
bot.once('cmd_ready', () => {
bot.cmd.registerCommand('trol', trollCommand, // Create a new command called 'say' and set the executor function
'make me say something', // help text
'say <message>') // usage text
// Add a flag called 'color' that expects 1 input
.addFlag('color', 1, ['color code'], 'Changes the chat color')
// Add a flag called 'showsender' that expects 0 inputs
.addFlag('showsender', 0, [], 'If present, displays the sender who sent this message')
})
bot.once('cmd_ready', () => {
bot.cmd.registerCommand('ckill', killCommand,
'ckill player', // help text
'ckill <player>') // usage text
// Add a flag called 'color' that expects 1 input
.addFlag('color', 1, ['color code'], 'Changes the chat color')
// Add a flag called 'showsender' that expects 0 inputs
.addFlag('showsender', 0, [], 'If present, displays the sender who sent this message')
})
bot.once('cmd_ready', () => {
bot.cmd.registerCommand('deop', deopCommand,
'deop player', // help text
'deop <player>') // usage text
// Add a flag called 'color' that expects 1 input
.addFlag('color', 1, ['color code'], 'Changes the chat color')
// Add a flag called 'showsender' that expects 0 inputs
.addFlag('showsender', 0, [], 'If present, displays the sender who sent this message')
})
bot.once('cmd_ready', () => {
bot.cmd.registerCommand('op', opCommand,
'op player', // help text
'op <player>') // usage text
// Add a flag called 'color' that expects 1 input
.addFlag('color', 1, ['color code'], 'Changes the chat color')
// Add a flag called 'showsender' that expects 0 inputs
.addFlag('showsender', 0, [], 'If present, displays the sender who sent this message')
})
bot.once('cmd_ready', () => {
bot.cmd.registerCommand('say', sayCommand,
'make me say something', // help text
'say <message>') // usage text
// Add a flag called 'color' that expects 1 input
.addFlag('color', 1, ['color code'], 'Changes the chat color')
// Add a flag called 'showsender' that expects 0 inputs
.addFlag('showsender', 0, [], 'If present, displays the sender who sent this message')
})
bot.once('cmd_ready', () => {
bot.cmd.registerCommand('cloop', cloopCommand,
'make me say something', // help text
'say <message>') // usage text
// Add a flag called 'color' that expects 1 input
.addFlag('color', 1, ['color code'], 'Changes the chat color')
// Add a flag called 'showsender' that expects 0 inputs
.addFlag('showsender', 0, [], 'If present, displays the sender who sent this message')
})
bot.once('cmd_ready', () => {
bot.cmd.registerCommand('freeze', freezeCommand,
'make me say something', // help text
'say <message>') // usage text
// Add a flag called 'color' that expects 1 input
.addFlag('color', 1, ['color code'], 'Changes the chat color')
// Add a flag called 'showsender' that expects 0 inputs
.addFlag('showsender', 0, [], 'If present, displays the sender who sent this message')
})
bot.once('cmd_ready', () => {
bot.cmd.registerCommand('deopall', deopallCommand,
'stop the server',
'stop')
.addFlag('color', 1, ['color code'], 'Changes the chat color')
.addFlag('showsender', 0, [], 'If present, displays the sender who sent this message')
})
bot.once('cmd_ready', () => {
bot.cmd.registerCommand('gms', survivalCommand,
'stop the server',
'stop')
.addFlag('color', 1, ['color code'], 'Changes the chat color')
.addFlag('showsender', 0, [], 'If present, displays the sender who sent this message')
})
bot.on('chat', (username, message) => {
if (message.startsWith('!')) {
const command = message.substring(1)
bot.cmd.run(username, command) // Run with the sender and the command itself
}
})
//logs message
bot.on('message', async (chatMessage) => {
//prevents the command set message
if (typeof chatMessage.translate === 'string' && chatMessage.translate.startsWith('advMode.')) return
console.log(chatMessage.toAnsi())
})
https://replit.com/@LigmaSMP/ParkerBot?from=notifications#index.js
-1413
View File
File diff suppressed because it is too large Load Diff
-11
View File
@@ -1,11 +0,0 @@
{
"dependencies": {
"discord.js": "^14.22.1",
"minecraft-data": "^3.99.1",
"minecraft-protocol": "^1.62.0",
"prismarine-chat": "^1.12.0",
"prismarine-registry": "^1.11.0",
"undici": "^7.16.0",
"wikipedia": "^2.1.2"
}
}
-117
View File
@@ -1,117 +0,0 @@
const mc = require("minecraft-protocol");
const { EventEmitter } = require("events");
const ChatMessage = require("prismarine-chat");
const usernameGen = require("./util/usernameGen");
let disconnectCount = 0;
EventEmitter.defaultMaxListeners = Infinity;
class Bot {
constructor(options = {}, config) {
const bot = new EventEmitter();
bot.options = {
// Set some default values in options
host: (options.host ??= "localhost"),
username: (options.username ??= usernameGen()),
version: (options.version ??= "1.21.8"),
hideErrors: (options.hideErrors ??= true), // HACK: Hide errors by default as a lazy fix to console being spammed with them
serverName: (options.serverName ??= "localhost"),
private: (options.private ??= false),
reconnectDelay: (options.reconnectDelay ??= 300),
channelId: (options.channelId ??= "0000000000000000000"),
logging: {
file: (options.logging.file ??= false),
console: (options.logging.console ??= false)
},
mode: (options.mode ??= "kaboom"),
selfcareInterval: (options.selfcareInterval ??= 1000),
itemRefill: (options.itemRefill ??= false),
chatGamemodeChange: (options.chatGamemodeChange ??= false)
};
bot.options = options;
// Create our client object, put it on the bot, and register some events
bot.on("init_client", (client) => {
client.on("packet", (data, meta) => {
bot.emit("packet", data, meta);
bot.emit("packet." + meta.name, data);
});
client.once("login", (data) => {
bot.uuid = client.uuid;
bot.username = client.username;
bot.loggedIn = true;
disconnectCount = 0
bot.reconnectDelay = options.reconnectDelay;
});
client.on("disconnect", (data) => {
try {
if (
JSON.parse(data.reason) ===
"Wait 5 seconds before connecting, thanks! :)"
)
bot.reconnectDelay = 5000;
bot.console.warn(
`${ChatMessage(bot._client.version).fromNotch("§8[§bClient Reconnect§8]§r")?.toAnsi()} ${ChatMessage(bot._client.version).fromNotch(data.reason)?.toAnsi()}`,
);
bot?.discord?.channel?.send(
ChatMessage(bot._client.version).fromNotch(data.reason)?.toString(),
);
} catch {} // do nothing
});
client.on("end", (reason) => {
bot.emit("end", reason);
bot.loggedIn = false;
disconnectCount++;
});
client.on("error", (error) => {
try {
if (disconnectCount === 10) {
bot.console.info("stopped logging disconnect messages for now...");
bot?.discord?.channel?.send(
"stopped logging disconnect messages for now...",
);
return;
} else if (disconnectCount > 10) {
return;
} else {
bot.console.warn(
ChatMessage(bot._client.version)
.fromNotch(`§8[§bClient Reconnect§8]§r ${error.stack}`)
?.toAnsi(),
);
bot?.discord?.channel?.send(error.toString());
}
} catch (e) {
console.log(e.stack);
}
});
client.on("kick_disconnect", (data) => {
bot.console.warn(
`${ChatMessage(bot._client.version).fromNotch("§8[§bClient Reconnect§8]§r")?.toAnsi()} ${ChatMessage(bot._client.version).fromNotch(data.reason)?.toAnsi()}`,
);
bot?.discord?.channel?.send(
ChatMessage(bot._client.version).fromNotch(data.reason)?.toString(),
);
});
});
process.on("uncaughtException", (e) => {
//console.log('meow')
console.warn(`${e.stack}`);
});
const client = options.client ?? new mc.createClient(bot.options);
bot._client = client;
bot.emit("init_client", client);
bot.bots = options.bots ?? [bot];
return bot;
}
}
module.exports = Bot;
-43
View File
@@ -1,43 +0,0 @@
function chipmunkmod(message, data) {
try {
if (message === null || typeof message !== "object") return;
if (
message.with?.length < 3 ||
(message.translate !== "[%s] %s › %s" &&
message.translate !== "%s %s › %s")
)
return;
const senderComponent = message.with[1];
const contents = message.with[2];
let sender;
const hoverEvent = senderComponent.hover_event;
// console.log(hoverEvent)
if (hoverEvent?.action === "show_entity") {
const id = hoverEvent.uuid;
sender = data.players.find((player) => player.entityUuid[0] === id[0])//.entityUuid //=== hoverEvent.uuid)//.entityUuid;
} else {
const stringUsername = data
.getMessageAsPrismarine(senderComponent)
?.toString();
sender = data.players.find(
(player) => player.profile.name === stringUsername,
);
}
if (!sender) return null;
return {
sender,
contents,
type: "minecraft:chat",
senderComponent,
chatType: data.chatType
};
} catch (e) {
console.error(e);
}
}
module.exports = chipmunkmod;
-26
View File
@@ -1,26 +0,0 @@
const ChatMessage = require("prismarine-chat")("1.20.2");
const util = require("util");
function parseMessage(messageobj, data) {
try {
let match;
let sender;
const stringify = (message) => new ChatMessage(message).toString();
const message = stringify(messageobj);
const playerWithPrefix = /^(.*?) (\S*?) » (.*?)$/;
const playerWithoutPrefix = /^(\S*?) » (.*?)$/;
if (playerWithPrefix.test(message)) {
match = message.match(playerWithPrefix);
sender = data.players.find((player) => player.profile.name === match[2]);
return {
sender,
contents: match[3],
type: "minecraft:chat",
chatType: data.chatType
};
}
} catch (e) {
console.log(e.stack);
}
}
module.exports = parseMessage;
-43
View File
@@ -1,43 +0,0 @@
const util = require('util')
function kaboom (message, data) {
if (message === null || typeof message !== 'object') return
if (message.text !== '' || !Array.isArray(message.extra) || message.extra.length < 3) return
const children = message.extra
const prefix = children[0]
let displayName = data.senderName ?? { text: '' }
let contents = { text: '' }
if (isSeparatorAt(children, 1)) { // Missing/blank display name
if (children.length > 3) contents = children[3]
} else if (isSeparatorAt(children, 2)) {
displayName = children[1]
if (children.length > 4) contents = children[4]
} else {
return undefined
}
const playerListDisplayName = { extra: [prefix, displayName], text: '' }
let sender
if (data.senderUuid) {
sender = data.players.find(player => player.uuid === data.senderUuid)
} else {
const playerListDisplayName = { extra: [prefix, displayName], text: '' }
sender = data.players.find(player => util.isDeepStrictEqual(player.displayName, playerListDisplayName))
}
if (!sender) return undefined
return { sender, contents, type: "minecraft:chat", displayName, chatType: data.chatType }
}
function isSeparatorAt (children, start) {
return (children[start]?.text === ':' || children[start]?.text === '\xa7f:') && children[start + 1]?.text === ' '
}
module.exports = kaboom
-31
View File
@@ -1,31 +0,0 @@
function me (message, data) {
try {
if (message === null || typeof message !== "object") return;
if (message.with?.length > 2 || message.translate !== "chat.type.announcement") return;
const component = message.with[0];
const contents = message.with[1];
let sender;
const hoverEvent = component.hover_event
if (hoverEvent?.action === "show_entity") {
const name = hoverEvent.name;
sender = data.players.find((player) => player.profile.name === name)
}
if (!sender) return;
return {
sender,
contents,
type: "minecraft:chat",
component,
chatType: data.chatType
};
} catch (e) {
console.log(e.stack)
}
}
module.exports = me;
-5
View File
@@ -1,5 +0,0 @@
function say (message, data) {
}
module.exports = say;
-37
View File
@@ -1,37 +0,0 @@
function vanilla(message, data) {
try {
if (message === null || typeof message !== "object") return;
if (
message.with?.length < 2 ||
(message.translate !== "chat.type.text" && message.translate !== "%s %s")
)
return;
const senderComponent = message.with[0];
const contents = message.with[1];
let sender;
const hoverEvent = senderComponent.hoverEvent;
if (hoverEvent?.action === "show_entity") {
const id = hoverEvent.contents.id;
sender = data.players.find((player) => player.uuid === id);
} else {
const stringUsername = data
.getMessageAsPrismarine(senderComponent)
.toString();
sender = data.players.find(
(player) => player.profile.name === stringUsername,
);
}
if (!sender) return;
return {
sender,
contents,
type: "minecraft:chat",
senderComponent,
chatType: data.chatType
};
} catch (e) {
console.error(`${e.stack}`);
}
}
module.exports = vanilla;
-38
View File
@@ -1,38 +0,0 @@
const CommandError = require('./CommandError');
const translations = require('../data/translations.json');
class CommandArguments {
static getInteger (integer) {
if (isNaN(integer)) throw new CommandError({
translate: "fnfboyfriendbot.arguments.invalid_integer",
fallback: translations["fnfboyfriendbot.arguments.invalid_integer"],
color: "red",
with: [
{ text: `${integer}` }
]
})
else return String(Number(integer))
}
static getJson (json) {
}
static getArguments () {
}
static getMaxArguments (commandArgs, args) {
if (commandArgs < args) throw new CommandError({
translate: "fnfboyfriendbot.arguments.max_exceeded",
fallback: translations["fnfboyfriendbot.arguments.max_exceeded"],
color: "red",
with: [
{ text: `${commandArgs}` },
{ text: `${args}` }
]
})
}
}
module.exports = CommandArguments;
-12
View File
@@ -1,12 +0,0 @@
class CommandContext {
constructor(name, aliases, description, trustLevel, usages, playerChatOnly) {
this.data = {};
this.data.name = name;
this.data.aliases = aliases;
this.data.description = description;
this.data.trustLevel = trustLevel;
this.data.usages = usages;
this.data.playerChatOnly = playerChatOnly
}
}
module.exports = CommandContext;
-15
View File
@@ -1,15 +0,0 @@
const ChatMessage = require("prismarine-chat")("1.21.8");
const stringify = (message) => new ChatMessage(message)?.toString();
class CommandError extends Error {
constructor(message, filename, lineError) {
super(stringify(message), filename, lineError);
this.name = "CommandError";
this._message = message;
}
get message() {
return stringify(this._message);
}
}
module.exports = CommandError;
-9
View File
@@ -1,9 +0,0 @@
class CommandSource {
constructor(player, sources, ChatType) {
this.player = player;
this.sources = sources;
this.ChatType = ChatType;
this.player.trustLevel = 0;
}
}
module.exports = CommandSource;
-10
View File
@@ -1,10 +0,0 @@
class CommandTrustLevel {
static public = 0;
static trusted = 1;
static admin = 2;
static owner = 3;
static console = 4;
static disabled = 5;
}
module.exports = CommandTrustLevel;
-155
View File
@@ -1,155 +0,0 @@
const CommandError = require("../../command_util/command_error");
const CommandContext = require("../../command_util/command_context");
class CoresettingsCommand extends CommandContext {
constructor() {
super("coresettings", ["cbsettings"], "change the bots core settings", 2, [
"useplacedcommandblock <on/off/true/false/enable/disable>",
"area start <positions>",
"area end <positions>",
"refillmethod/rcmethod <item/chat>",
]);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const config = context.config;
const source = context.source;
let component = [];
if (
!args &&
!args[0] &&
!args[1] &&
!args[2] &&
!args[3] &&
!args[4] &&
!args[5]
)
return;
switch (args[1]?.toLowerCase()) {
case "useplacedcommandblock":
switch (args[2]?.toLowerCase()) {
case "on":
case "true":
case "enable":
bot.core.usePlacedCommandBlock = true;
component.push({
text: "now using the placed command block",
color: config.colors.commands.primary,
});
break;
case "off":
case "false":
case "disable":
bot.core.usePlacedCommandBlock = false;
component.push({
text: "no longer using the placed command block",
color: config.colors.commands.primary,
});
break;
default:
if (bot.core.usePlacedCommandBlock) {
component.push({
text: "the bot is currently using the placed command block to run its commands",
color: config.colors.commands.primary,
});
} else {
component.push({
text: "the bot is currently using its command block core to run its commands",
color: config.colors.commands.primary,
});
}
}
break;
case "area":
switch (args[2]?.toLowerCase()) {
case "start":
if (isNaN(args[3]) || isNaN(args[4]) || isNaN(args[5])) {
bot.core.area.start = config.core.area.start;
component.push({
text: "arguments were NaN, defaulting to config core start coords",
color: config.colors.commands.primary,
});
} else {
bot.core.area.start = {
x: Number(args[3]),
y: Number(args[4]),
z: Number(args[5]),
};
component.push({
text: `setting core start pos to x: ${args[3]}, y: ${args[4]}, z: ${args[5]}`,
color: config.colors.commands.primary,
});
}
break;
case "end":
if (isNaN(args[3]) || isNaN(args[4]) || isNaN(args[5])) {
bot.core.area.end = config.core.area.end;
throw new CommandError(
"arguments were NaN, defaulting to config core end coords",
);
} else {
bot.core.area.end = {
x: Number(args[3]),
y: Number(args[4]),
z: Number(args[5]),
};
component.push({
text: `setting core end pos to x: ${args[3]}, y: ${args[4]}, z: ${args[5]}`,
color: config.colors.commands.primary,
});
}
break;
default:
component.push({
text: `core start pos: x: ${bot.core.area.start.x}, y: ${bot.core.area.start.y}, z: ${bot.core.area.start.z}, and end pos: x: ${bot.core.area.end.x}, y: ${bot.core.area.end.y}, z: ${bot.core.area.end.z}`,
color: config.colors.commands.primary,
});
}
break;
case "refillmethod":
case "rcmethod":
switch (args[2]?.toLowerCase()) {
case "item":
config.core.itemRefill = true;
component.push({
text: "now refilling via item",
color: config.colors.commands.primary,
});
break;
case "chat":
config.core.itemRefill = false;
component.push({
text: "now refilling via chat",
color: config.colors.commands.primary,
});
break;
default:
if (config.core.itemRefill) {
component.push({
text: "currently filling core via item",
color: config.colors.commands.primary,
});
} else {
component.push({
text: "currently filling core via chat",
color: config.colors.commands.primary,
});
}
}
break;
default:
throw new CommandError("invalid argument");
}
if (source.sources.console) {
bot.console.info(bot.getMessageAsPrismarine(component)?.toAnsi());
} else {
bot.tellraw("@a", component);
}
}
}
module.exports = CoresettingsCommand;
-37
View File
@@ -1,37 +0,0 @@
const CommandError = require("../../command_util/command_error");
const CommandContext = require("../../command_util/command_context");
class KickCommand extends CommandContext {
constructor() {
super("kick", [], "kick a player from the server", 2, [
"invalidstring",
"item",
"te",
]);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const config = context.config;
if (!args && !args[0] && !args[1] && !args[2]) return;
switch (args[1]?.toLowerCase()) {
case "invalidstring":
bot.exploits.crashes.invalidString(args[2]);
bot.tellraw("@a", `crashing ${args[2]}`);
break;
case "item":
bot.exploits.kicks.item(args[2]);
bot.tellraw("@a", `kicking ${args[2]}`);
break;
case "te":
bot.exploits.kicks.translateEntity(args[2]);
bot.tellraw("@a", `kicking ${args[2]}`);
break;
default:
throw new CommandError("invalid argument");
}
}
}
module.exports = KickCommand;
-13
View File
@@ -1,13 +0,0 @@
const CommandContext = require("../../command_util/command_context");
class ReconnectCommand extends CommandContext {
constructor() {
super("reconnect", ["end"], "reconnects the bot", 2, [""]);
}
execute(context) {
const bot = context.bot;
bot._client.end();
bot.chat.message("reconnecting");
}
}
module.exports = ReconnectCommand;
-118
View File
@@ -1,118 +0,0 @@
const CommandContext = require("../../command_util/command_context");
const CommandError = require("../../command_util/command_error");
class ConsoleCommand extends CommandContext {
constructor() {
super("console", ["c"], "runs commands made for the bots console", 4, [
"server/srv <all/servername>",
"customchat <on/true/enable/off/false/disable>",
"say <message>",
"validate/validation/val <owner/o/admin/a/trusted/t>",
"logging/togglelogging/logtoconsole <on/true/enable/off/false/disable>",
]);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const source = context.source;
const config = context.config;
if (!args && !args[0] && !args[1] && !args[2] && !args[3]) return;
switch (args[0]?.toLowerCase()) {
case "server":
case "svr":
const servers = bot.bots.map((eachBot) => eachBot.options.serverName);
for (const eachBot of bot.bots) {
if (args.slice(1).join(" ").toLowerCase() === "all") {
eachBot.console.server = "all";
bot.console.info("Set the console server to all");
continue;
}
const server = servers.find((server) =>
server.toLowerCase().includes(args[1]),
);
if (!server) {
bot.console.info("Invalid server");
return;
}
bot.console.info(`Set the console server to ` + server);
eachBot.console.server = server;
}
break;
case "say":
bot.chat.send(args.slice(1).join(" "));
break;
case "validate":
case "validation":
case "val":
switch (args[1]?.toLowerCase()) {
case "owner":
case "o":
bot.chat.message(
`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.owner} ${args.slice(3).join(" ")}`,
);
break;
case "admin":
case "a":
bot.chat.message(
`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.admin} ${args.slice(3).join(" ")}`,
);
break;
case "trusted":
case "t":
bot.chat.message(
`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.trusted} ${args.slice(3).join(" ")}`,
);
break;
default:
throw new CommandError({
translate: "command.unknown.argument",
color: "dark_red",
});
}
break;
case "logging":
case "togglelogging":
case "logtoconsole":
switch (args[1]?.toLowerCase()) {
case "on":
case "enable":
case "enabled":
case "true":
if (bot.options.logging === true) {
bot.console.info(
`logging for ${bot.options.serverName} is already enabled!`,
);
} else {
bot.console.info(
`logging for ${bot.options.serverName} is now enabled`,
);
bot.options.logging = true;
}
break;
case "off":
case "disable":
case "disabled":
case "false":
if (bot.options.logging === false) {
bot.console.info(
`logging for ${bot.options.serverName} is already disabled!`,
);
} else {
bot.console.info(
`logging for ${bot.options.serverName} is now disabled`,
);
bot.options.logging = false;
}
break;
}
break;
default:
throw new CommandError({
translate: "command.unknown.argument",
color: "dark_red",
});
}
}
}
module.exports = ConsoleCommand;
-12
View File
@@ -1,12 +0,0 @@
const CommandContext = require("../../command_util/command_context");
class KillCommand extends CommandContext {
constructor() {
super("kill", ["suicide", "quit"], "kill the bots process", 3, [""]);
}
execute(context) {
const bot = context.bot;
process.exit(1);
}
}
module.exports = KillCommand;
-42
View File
@@ -1,42 +0,0 @@
const CommandError = require("../../command_util/command_error");
const { stylize } = require("../../util/stylizeEval");
const util = require("util");
const CommandContext = require("../../command_util/command_context");
class ServerevalCommand extends CommandContext {
constructor() {
super("servereval", ["se"], "run code unisolated", 4, ["<code>"]);
}
execute(context) {
const bot = context.bot;
const source = context.source;
const config = context.config;
const discordClient = context.discordClient;
const args = context.arguments;
const script = args.slice(1).join(" ");
const { MessageBuilder } = require("prismarine-chat")(bot.options.version);
try {
if (source.sources.console) {
bot.console.log(
bot
.getMessageAsPrismarine({
text: util.inspect(eval(args.join(" ")), { stylize }),
})
?.toAnsi(),
);
} else if (bot.options.mode === "savageFriends") {
bot.core.run(
`minecraft:tellraw @a ${JSON.stringify(util.inspect(eval(script), { stylize }).substring(0, 32700))}`,
);
} else {
bot.tellraw(`@a[name="${source.player.profile.name}"]`, {
text: `${util.inspect(eval(script), { stylize }).substring(0, 32700)}`,
});
}
} catch (e) {
throw new CommandError(e.toString());
}
}
}
module.exports = ServerevalCommand;
-36
View File
@@ -1,36 +0,0 @@
const sleep = require("../../util/sleep");
const CommandContext = require("../../command_util/command_context");
class core extends CommandContext {
constructor() {
super("core", ["cb", "cbrun", "corerun"], "run commands in core", 0, [
"$username <message>",
"$uuid <message>",
"<message>",
]);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const source = context.source;
if (args.includes("$username") || args.includes("$uuid")) {
bot.players.forEach((eachPlayer) => {
bot.core.runTracked(
args
.join(" ")
.replaceAll("$username", eachPlayer.profile.name)
.replaceAll("$uuid", eachPlayer.uuid),
source,
);
// await sleep(1000)
});
} else if (bot.options.mode === "savageFriends") {
bot.core.run(args.join(" "));
} else {
bot.core.runTracked(args.join(" "), source);
}
}
}
module.exports = core;
-18
View File
@@ -1,18 +0,0 @@
const CommandContext = require("../../command_util/command_context");
class EchoCommand extends CommandContext {
constructor() {
super("echo", ["say", "botsay"], "make me say something!", 0, [
"<message>",
]);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
bot.chat.send(`${args.join(" ")}`);
}
}
module.exports = EchoCommand;
-446
View File
@@ -1,446 +0,0 @@
const fixansi = require("../../util/ansi");
const CommandContext = require("../../command_util/command_context");
class HelpCommand extends CommandContext {
constructor() {
super(
"help",
["heko", "?", "cmds", "commands", "hell"],
"see a list of commands",
0,
["<command>"],
);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const config = context.config;
const source = context.source;
let component = [];
let infoComponent = [];
let usagesComponent = [];
let Public = [];
let trusted = [];
let admin = [];
let owner = [];
let Console = [];
let cat = {
translate: "(%s | %s | %s | %s)",
color: config.colors.commands.tertiary,
with: [
{ text: "Public", color: config.colors.help.public },
{ text: "Trusted", color: config.colors.help.trusted },
{ text: "Admin", color: config.colors.help.admin },
{ text: "Owner", color: config.colors.help.owner },
],
};
component.push({
translate: "%s: (%s) %s \u203a\n",
color: config.colors.commands.tertiary,
with: [
{ text: "Commands", color: config.colors.commands.secondary },
{
text: `${bot.commandManager.commandlist.length}`,
color: config.colors.integer,
},
cat,
],
});
for (const commands of bot.commandManager.commandlist) {
switch (commands.data.trustLevel) {
case 0:
Public.push({
text: commands.data.name + " ",
color: config.colors.help.public,
translate: "",
hoverEvent: {
action: "show_text",
value: [
{
translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
color: config.colors.commands.tertiary,
with: [
{
text: "Command Name",
color: config.colors.commands.primary,
},
{
text: `${commands.data.name}`,
color: config.colors.commands.secondary,
},
{
text: "Trust Level",
color: config.colors.commands.primary,
},
{
text: `${commands.data.trustLevel}`,
color: config.colors.integer,
},
{
text: "Description",
color: config.colors.commands.primary,
},
{
text: `${commands.data.description}`,
color: config.colors.commands.secondary,
},
{ text: "Aliases", color: config.colors.commands.primary },
{
text: `${commands.data.aliases}`,
color: config.colors.commands.secondary,
},
{ text: "Usages", color: config.colors.commands.primary },
{
text: `${commands.data.usages}`,
color: config.colors.commands.secondary,
},
],
},
],
},
clickEvent: {
action: "suggest_command",
value: `${config.prefixes[0]}${commands.data.name}`,
},
});
break;
case 1:
trusted.push({
text: commands.data.name + " ",
color: config.colors.help.trusted,
translate: "",
hoverEvent: {
action: "show_text",
value: [
{
translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
color: config.colors.commands.tertiary,
with: [
{
text: "Command Name",
color: config.colors.commands.primary,
},
{
text: `${commands.data.name}`,
color: config.colors.commands.secondary,
},
{
text: "Trust Level",
color: config.colors.commands.primary,
},
{
text: `${commands.data.trustLevel}`,
color: config.colors.integer,
},
{
text: "Description",
color: config.colors.commands.primary,
},
{
text: `${commands.data.description}`,
color: config.colors.commands.secondary,
},
{ text: "Aliases", color: config.colors.commands.primary },
{
text: `${commands.data.aliases}`,
color: config.colors.commands.secondary,
},
{ text: "Usages", color: config.colors.commands.primary },
{
text: `${commands.data.usages}`,
color: config.colors.commands.secondary,
},
],
},
],
},
clickEvent: {
action: "suggest_command",
value: `${config.prefixes[0]}${commands.data.name}`,
},
});
break;
case 2:
admin.push({
text: commands.data.name + " ",
color: config.colors.help.admin,
translate: "",
hoverEvent: {
action: "show_text",
value: [
{
translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
color: config.colors.commands.tertiary,
with: [
{
text: "Command Name",
color: config.colors.commands.primary,
},
{
text: `${commands.data.name}`,
color: config.colors.commands.secondary,
},
{
text: "Trust Level",
color: config.colors.commands.primary,
},
{
text: `${commands.data.trustLevel}`,
color: config.colors.integer,
},
{
text: "Description",
color: config.colors.commands.primary,
},
{
text: `${commands.data.description}`,
color: config.colors.commands.secondary,
},
{ text: "Aliases", color: config.colors.commands.primary },
{
text: `${commands.data.aliases}`,
color: config.colors.commands.secondary,
},
{ text: "Usages", color: config.colors.commands.primary },
{
text: `${commands.data.usages}`,
color: config.colors.commands.secondary,
},
],
},
],
},
clickEvent: {
action: "suggest_command",
value: `${config.prefixes[0]}${commands.data.name}`,
},
});
break;
case 3:
owner.push({
text: commands.data.name + " ",
color: config.colors.help.owner,
translate: "",
hoverEvent: {
action: "show_text",
value: [
{
translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
color: config.colors.commands.tertiary,
with: [
{
text: "Command Name",
color: config.colors.commands.primary,
},
{
text: `${commands.data.name}`,
color: config.colors.commands.secondary,
},
{
text: "Trust Level",
color: config.colors.commands.primary,
},
{
text: `${commands.data.trustLevel}`,
color: config.colors.integer,
},
{
text: "Description",
color: config.colors.commands.primary,
},
{
text: `${commands.data.description}`,
color: config.colors.commands.secondary,
},
{ text: "Aliases", color: config.colors.commands.primary },
{
text: `${commands.data.aliases}`,
color: config.colors.commands.secondary,
},
{ text: "Usages", color: config.colors.commands.primary },
{
text: `${commands.data.usages}`,
color: config.colors.commands.secondary,
},
],
},
],
},
clickEvent: {
action: "suggest_command",
value: `${config.prefixes[0]}${commands.data.name}`,
},
});
break;
case 4:
Console.push({
text: commands.data.name + " ",
color: config.colors.help.console,
translate: "",
hoverEvent: {
action: "show_text",
value: [
{
translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
color: config.colors.commands.tertiary,
with: [
{
text: "Command Name",
color: config.colors.commands.primary,
},
{
text: `${commands.data.name}`,
color: config.colors.commands.secondary,
},
{
text: "Trust Level",
color: config.colors.commands.primary,
},
{
text: `${commands.data.trustLevel}`,
color: config.colors.integer,
},
{
text: "Description",
color: config.colors.commands.primary,
},
{
text: `${commands.data.description}`,
color: config.colors.commands.secondary,
},
{ text: "Aliases", color: config.colors.commands.primary },
{
text: `${commands.data.aliases}`,
color: config.colors.commands.secondary,
},
{ text: "Usages", color: config.colors.commands.primary },
{
text: `${commands.data.usages}`,
color: config.colors.commands.secondary,
},
],
},
],
},
clickEvent: {
action: "suggest_command",
value: `${config.prefixes[0]}${commands.data.name}`,
},
});
break;
default:
bot.chat.message(
`fuck you ${commands.data.name} has a invalid trust level`,
);
}
if (
args[0]?.toLowerCase() === commands.data.name?.toLowerCase() ||
commands.data.aliases.find(
(e) => e?.toLowerCase() === args[0]?.toLowerCase(),
)
) {
for (const usages of commands.data.usages) {
usagesComponent.push({
translate: "%s%s %s",
with: [
{
text: `${config.prefixes[0]}`,
color: config.colors.commands.primary,
},
{
text: `${commands.data.name}`,
color: config.colors.commands.secondary,
},
{ text: `${usages}`, color: config.colors.commands.secondary },
],
});
usagesComponent.push("\n");
}
usagesComponent.pop();
infoComponent.push({
translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s:\n",
color: config.colors.commands.tertiary,
with: [
{ text: "Name", color: config.colors.commands.primary },
{
text: `${commands.data.name}`,
color: config.colors.commands.secondary,
},
{ text: "Aliases", color: config.colors.commands.primary },
{
text: `${commands.data.aliases.toString().replaceAll(",", " ")}`,
color: config.colors.commands.secondary,
},
{ text: "Description", color: config.colors.commands.primary },
{
text: `${commands.data.description}`,
color: config.colors.commands.secondary,
},
{ text: "Trust Level", color: config.colors.commands.primary },
{
text: `${commands.data.trustLevel}`,
color: config.colors.integer,
},
{ text: "Usages", color: config.colors.commands.primary },
],
});
infoComponent.push(usagesComponent);
if (source?.sources.console) {
bot.console.info(bot.getMessageAsPrismarine(infoComponent)?.toAnsi());
} else if (source.sources.discord) {
bot.discord.message.reply(
`\`\`\`ansi\n${fixansi(bot.getMessageAsPrismarine(infoComponent)?.toAnsi())}\`\`\``,
);
} else {
bot.tellraw(`@a`, infoComponent);
}
return;
}
}
if (Public.length > 0) {
component.push(Public);
if (trusted.length > 0) component.push("\n");
}
if (trusted.length > 0) {
component.push(trusted);
if (admin.length > 0) component.push("\n");
}
if (admin.length > 0) {
component.push(admin);
if (owner.length > 0) component.push("\n");
}
if (owner.length > 0) {
component.push(owner);
}
if (source.sources.console && Console.length > 0) {
component.push(Console);
}
if (source?.sources?.console) {
bot.console.info(bot.getMessageAsPrismarine(component)?.toAnsi());
} else if (source.sources.discord) {
bot.discord.message.reply(
`\`\`\`ansi\n${fixansi(bot.getMessageAsPrismarine(component)?.toAnsi())}\`\`\``,
);
} else {
bot.tellraw("@a", component);
}
}
}
module.exports = HelpCommand;
-608
View File
@@ -1,608 +0,0 @@
const os = require("os");
const CommandError = require("../../command_util/command_error");
const fs = require("fs");
const botInfo = require("../../data/info.json");
const fixansi = require("../../util/ansi.js");
const { execSync } = require("child_process");
const CommandContext = require("../../command_util/command_context");
function format(seconds) {
function pad(s) {
return (s < 10 ? "0" : "") + s;
}
var hours = Math.floor(seconds / (60 * 60));
var minutes = Math.floor((seconds % (60 * 60)) / 60);
var seconds = Math.floor(seconds % 60);
return (
pad(`${hours} Hours`) +
" " +
pad(`${minutes} Minutes`) +
" " +
pad(`${seconds} Seconds`)
);
}
class InfoCommand extends CommandContext {
constructor() {
super("info", ["information"], "check the bots info", 0, [
"about",
"config <client, discord, options, all>",
"contributors/credits",
"discord",
"loaded",
"usages <bot, server, all>",
"uptimes/uptime <bot, server, all>",
"server",
"version/ver",
]);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const config = context.config;
const discordClient = context.discordClient;
const source = context.source;
let component = [];
switch (args[0]?.toLowerCase()) {
case "about":
component.push({
text: `FNFBoyfriendBot is a kaboom bot created by Parker2991\nThe source code and changelog can be found here ${botInfo.buildstring.url}`,
color: `${config.colors.commands.primary}`,
translate: "",
hoverEvent: {
action: "show_text",
value: [
{
text: "click here to view bots source code",
color: `${config.colors.commands.primary}`,
},
],
},
clickEvent: {
action: "open_url",
value: `${botInfo.buildstring.url}`,
},
});
break;
case "config":
if (bot.options.isKaboom) {
mode = "Kaboom";
}
if (bot.options.useChat && bot.options.isKaboom) {
mode = "Kaboom/Coreless";
}
if (bot.options.isSavage) {
mode = "Savage";
}
if (bot.options.isCreayun) {
mode = "Creayun";
}
switch (args.slice(1).join(" ")?.toLowerCase()) {
case "client":
component.push({
translate: "%s: %s:%s\n%s: %s\n%s: %s\n%s: %s",
color: config.colors.commands.tertiary,
with: [
{ text: "Server", color: config.colors.commands.primary },
{
text: `${bot.options.host}`,
color: config.colors.commands.secondary,
},
{ text: `${bot.options.port}`, color: config.colors.integer },
{ text: "Server Name", color: config.colors.commands.primary },
{
text: `${bot.options.serverName}`,
color: config.colors.commands.secondary,
},
{
text: "Minecraft Username",
color: config.colors.commands.primary,
},
{
text: `${bot.options.username}`,
color: config.colors.commands.secondary,
},
{ text: "Version", color: config.colors.commands.primary },
{
text: `${bot.options.version}`,
color: config.colors.integer,
},
],
});
break;
case "discord":
if (!config.discord.enabled || discordClient.user === null) {
throw new CommandError(
"Token is incorrect or discord isnt enabled!",
);
} else {
component.push({
translate: "%s: %s\n%s: %s",
color: config.colors.commands.tertiary,
with: [
{
text: "Discord Username",
color: config.colors.commands.primary,
},
{
text: `${discordClient.user.tag}`,
color: config.colors.commands.secondary,
},
{
text: "Discord Channel",
color: config.colors.commands.primary,
},
{
text: `${bot.discord?.channel?.name}`,
color: config.colors.commands.secondary,
},
],
});
}
break;
case "options":
component.push({
translate: "%s: %s\n%s: %s\n%s: %s",
color: config.colors.commands.tertiary,
with: [
{ text: "Server Count", color: config.colors.commands.primary },
{ text: `${bot.bots.length}`, color: config.colors.integer },
{ text: "Prefixes", color: config.colors.commands.primary },
{
text: `${config.prefixes.map((e) => e + " ").join(" ")}`,
color: config.colors.commands.secondary,
},
{ text: "Mode", color: config.colors.commands.primary },
{
text: `${bot.options.mode}`,
color: config.colors.commands.secondary,
},
],
});
break;
case "all":
component.push({
translate:
"%s: %s:%s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
color: config.colors.commands.tertiary,
with: [
{ text: "Server", color: config.colors.commands.primary },
{
text: `${bot.options.host}`,
color: config.colors.commands.secondary,
},
{ text: `${bot.options.port}`, color: config.colors.integer },
{ text: "Server Name", color: config.colors.commands.primary },
{
text: `${bot.options.serverName}`,
color: config.colors.commands.secondary,
},
{
text: "Minecraft Username",
color: config.colors.commands.primary,
},
{
text: `${bot.options.username}`,
color: config.colors.commands.secondary,
},
{ text: "Version", color: config.colors.commands.primary },
{
text: `${bot.options.version}`,
color: config.colors.commands.secondary,
},
{
text: "Discord Username",
color: config.colors.commands.primary,
},
{
text: `${discordClient.user?.tag}`,
color: config.colors.commands.secondary,
},
{
text: "Discord Channel",
color: config.colors.commands.primary,
},
{
text: `${bot.discord.channel?.name}`,
color: config.colors.commands.secondary,
},
{ text: "Server Count", color: config.colors.commands.primary },
{ text: `${bot.bots.length}`, color: config.colors.integer },
{ text: "Prefixes", color: config.colors.commands.primary },
{
text: `${config.prefixes.map((e) => e + " ").join(" ")}`,
color: config.colors.commands.secondary,
},
{ text: "Mode", color: config.colors.commands.primary },
{
text: `${bot.options.mode}`,
color: config.colors.commands.secondary,
},
],
});
break;
default:
throw new CommandError({
translate: "command.unknown.argument",
color: "dark_red",
});
}
break;
case "contributors":
case "credits":
component.push({
translate: "%s%s - %s\n%s:\n%s\n%s\n%s\n%s\n%s %s\n%s\n%s",
color: config.colors.commands.tertiary,
with: [
{ text: "Parker", color: "dark_red" },
{ text: "2991", color: "black" },
{ text: "Owner" },
{ text: "Contributors" },
{ text: "_ChipMC_", color: "dark_blue" },
{ text: "chayapak", color: "yellow" },
{ text: "_yfd", color: "light_purple" },
{ text: "aaa", color: "gold" },
{ text: "Morgan", color: "green" },
{ text: "Ankan", color: "dark_green" },
{ text: "TurtleKid", color: "green" },
{ text: "Ploat/ImGloriz", color: "#cd8ccb" },
],
});
break;
case "discord":
component.push({
text: `the discord server invite is ${config.discord.invite}`,
color: config.colors.commands.primary,
translate: "",
hoverEvent: {
action: "show_text",
value: [
{
text: "click here to join the discord server!",
color: config.colors.commands.secondary,
},
],
},
clickEvent: {
action: "open_url",
value: `${config.discord.invite}`,
},
});
break;
case "loaded":
component.push({
translate: "%s %s\n%s %s",
color: config.colors.commands.tertiary,
with: [
{
text: `${bot.commandManager.commandlist.length}`,
color: config.colors.integer,
},
{ text: "Commands", color: config.colors.commands.primary },
{ text: `${bot.modules.length}`, color: config.colors.integer },
{ text: "Modules", color: config.colors.commands.primary },
],
});
break;
case "usages":
case "usage":
switch (args.slice(1).join(" ")?.toLowerCase()) {
case "bot":
component.push({
translate: "%s: %s %s / %s %s",
color: config.colors.commands.tertiary,
with: [
{
text: "Bot Memory",
color: config.colors.commands.primary,
},
{
text: `${Math.floor(process.memoryUsage().heapUsed / 1048576)}`,
color: config.colors.integer,
},
{ text: "MiB", color: config.colors.commands.secondary },
{
text: `${Math.floor(process.memoryUsage().heapTotal / 1048576)}`,
color: config.colors.integer,
},
{ text: "MiB", color: config.colors.commands.secondary },
],
});
break;
case "server":
component.push({
translate: "%s: %s %s / %s %s",
color: config.colors.commands.tertiary,
with: [
{
text: "Server Memory",
color: config.colors.commands.primary,
},
{
text: `${Math.floor(os.totalmem() / 1048576) - Math.floor(os.freemem() / 1048576)}`,
color: config.colors.integer,
},
{ text: "MB", color: config.colors.commands.secondary },
{
text: `${Math.floor(os.totalmem() / 1048576)}`,
color: config.colors.integer,
},
{ text: "MB", color: config.colors.commands.secondary },
],
});
break;
case "all":
component.push({
translate: "%s: %s %s / %s %s\n%s: %s %s / %s %s",
color: config.colors.commands.tertiary,
with: [
{
text: "Server Memory",
color: config.colors.commands.primary,
},
{
text: `${Math.floor(os.totalmem() / 1048576) - Math.floor(os.freemem() / 1048576)}`,
color: config.colors.integer,
},
{ text: "MB", color: config.colors.commands.secondary },
{
text: `${Math.floor(os.totalmem() / 1048576)}`,
color: config.colors.integer,
},
{ text: "MB", color: config.colors.commands.secondary },
{
text: "Bot Memory",
color: config.colors.commands.primary,
},
{
text: `${Math.floor(process.memoryUsage().heapUsed / 1048576)}`,
color: config.colors.integer,
},
{ text: "MB", color: config.colors.commands.secondary },
{
text: `${Math.floor(process.memoryUsage().heapTotal / 1048576)}`,
color: config.colors.integer,
},
{ text: "MB", color: config.colors.commands.secondary },
],
});
break;
default:
throw new CommandError({
translate: "command.unknown.argument",
color: "dark_red",
});
}
break;
case "uptimes":
switch (args.slice(1).join(" ")?.toLowerCase()) {
case "bot":
component.push({
translate: "%s: %s",
color: config.colors.commands.tertiary,
with: [
{ text: "Bot Uptime", color: config.colors.commands.primary },
{
text: `${format(process.uptime())}`,
color: config.colors.commands.secondary,
},
],
});
break;
case "server":
component.push({
translate: "%s: %s",
color: config.colors.commands.tertiary,
with: [
{
text: "Server Uptime",
color: config.colors.commands.primary,
},
{
text: `${format(os.uptime())}`,
color: config.colors.commands.secondary,
},
],
});
break;
case "all":
component.push({
translate: "%s: %s\n%s: %s",
color: config.colors.commands.tertiary,
with: [
{ text: "Bot Uptime", color: config.colors.commands.primary },
{
text: `${format(process.uptime())}`,
color: config.colors.commands.secondary,
},
{
text: "Server Uptime",
color: config.colors.commands.primary,
},
{
text: `${format(os.uptime())}`,
color: config.colors.commands.secondary,
},
],
});
break;
throw new CommandError({
translate: "command.unknown.argument",
color: "dark_red",
});
}
break;
case "server":
component.push({
translate:
"%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
color: config.colors.commands.tertiary,
with: [
{ text: "Hostname", color: config.colors.commands.primary },
{
text: `${os.hostname()}`,
color: config.colors.commands.secondary,
},
{ text: "User", color: config.colors.commands.primary },
{
text: `${os.userInfo().username}`,
color: config.colors.commands.secondary,
},
{
text: "Working Directory",
color: config.colors.commands.primary,
},
{
text: `${require.main.path}`,
color: config.colors.commands.secondary,
},
{ text: "Arch", color: config.colors.commands.primary },
{ text: `${os.arch()}`, color: config.colors.commands.secondary },
{ text: "OS", color: config.colors.commands.primary },
{ text: `${os.platform}`, color: config.colors.commands.secondary },
{ text: "OS Version", color: config.colors.commands.primary },
{
text: `${os.version()}`,
color: config.colors.commands.secondary,
},
{ text: "Kernel Version", color: config.colors.commands.primary },
{
text: `${os.release()}`,
color: config.colors.commands.secondary,
},
{ text: "CPU", color: config.colors.commands.primary },
{
text: `${os.cpus()[0].model}`,
color: config.colors.commands.secondary,
},
{ text: "CPU cores", color: config.colors.commands.primary },
{ text: `${os.cpus().length}`, color: config.colors.integer },
{ text: "Processes", color: config.colors.commands.primary },
{
text: `${execSync("ps aux | wc -l").toString().replace("\n", "")}`,
color: config.colors.integer,
},
{ text: "Node Version", color: config.colors.commands.primary },
{
text: `${process.version}`,
color: config.colors.commands.secondary,
},
{ text: "NPM Version", color: config.colors.commands.primary },
{
text: `${execSync("npm -v").toString().replaceAll("\n", "")}`,
color: config.colors.commands.secondary,
},
],
});
break;
case "version":
case "ver":
if (botInfo.buildstring.codename.length > 0) {
component.push({
translate: "%s %s %s-%s-%s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s-%s",
color: config.colors.commands.tertiary,
with: [
{ text: "Friday Night Funkin", color: "dark_blue" },
{ text: "Boyfriend", color: "dark_aqua" },
{ text: "Bot", color: "blue" },
{
text: `${botInfo.buildstring.version}`,
color: config.colors.integer,
},
botInfo.buildstring.codename,
{ text: "Build", color: config.colors.commands.primary },
{
text: `${botInfo.buildstring.build}`,
color: config.colors.integer,
},
{ text: "Repo Build", color: config.colors.commands.primary },
{
text: `${execSync("git rev-list --count --all").toString().replaceAll("\n", "")}`,
color: config.colors.integer,
},
{
text: "Version Release Date",
color: config.colors.commands.primary,
},
{
text: `${new Date(execSync("git log -1 --format=%ci").toString()).toLocaleString("en-US", { timeZone: "America/CHICAGO" })}`,
color: config.colors.commands.secondary,
},
{ text: "Commit", color: config.colors.commands.primary },
{
text: `${execSync("git rev-parse HEAD").toString().substring(0, 10)}`,
color: config.colors.commands.secondary,
},
{ text: "11/22/22", color: config.colors.commands.primary },
{
text: `${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`,
color: config.colors.commands.secondary,
},
],
});
} else {
component.push({
translate: "%s %s %s-%s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s-%s",
color: config.colors.commands.tertiary,
with: [
{ text: "Friday Night Funkin", color: "dark_blue" },
{ text: "Boyfriend", color: "dark_aqua" },
{ text: "Bot", color: "blue" },
{
text: `${botInfo.buildstring.version}`,
color: config.colors.integer,
},
{ text: "Build", color: config.colors.commands.primary },
{
text: `${botInfo.buildstring.build}`,
color: config.colors.integer,
},
{ text: "Repo Build", color: config.colors.commands.primary },
{
text: `${execSync("git rev-list --count --all").toString().replaceAll("\n", "")}`,
color: config.colors.integer,
},
{
text: "Version Release Date",
color: config.colors.commands.primary,
},
{
text: `${new Date(execSync("git log -1 --format=%ci").toString()).toLocaleString("en-US", { timeZone: "America/CHICAGO" })}`,
color: config.colors.commands.secondary,
},
{ text: "Commit", color: config.colors.commands.primary },
{
text: `${execSync("git rev-parse HEAD").toString().substring(0, 10)}`,
color: config.colors.commands.secondary,
},
{ text: "11/22/22", color: config.colors.commands.primary },
{
text: `${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`,
color: config.colors.commands.secondary,
},
],
});
}
break;
default:
throw new CommandError({
translate: "command.unknown.argument",
color: "dark_red",
});
}
if (source?.sources?.console) {
bot.console.info(bot.getMessageAsPrismarine(component)?.toAnsi());
} else if (source.sources.discord) {
bot.discord.message.reply(
`\`\`\`ansi\n${fixansi(bot.getMessageAsPrismarine(component)?.toAnsi())}\`\`\``,
);
} else {
bot.tellraw("@a", component);
}
}
}
module.exports = InfoCommand;
-54
View File
@@ -1,54 +0,0 @@
const CommandError = require("../../command_util/command_error");
const CommandContext = require("../../command_util/command_context");
class ListCommand extends CommandContext {
constructor() {
super("list", ["pl", "playerlist"], "check whos online on the server", 0, [
"",
]);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const config = context.config;
const source = context.source;
let component = [];
let infoComponent = [];
let playerCount = [];
playerCount.push({
translate: "%s: (%s)\n",
color: config.colors.commands.tertiary,
with: [
{ text: "Players", color: config.colors.commands.primary },
{ text: `${bot.players.length}`, color: config.colors.integer },
],
});
component.push(playerCount);
for (const player of bot.players) {
component.push({
translate: "%s \u203a %s [%s: %s]",
color: config.colors.commands.tertiary,
with: [
player.displayName ?? player.profile.name,
{ text: `${player.uuid}`, color: config.colors.commands.primary },
{ text: "Latency", color: config.colors.commands.primary },
{ text: `${player.latency}`, color: config.colors.integer },
],
});
component.push("\n");
}
component.pop();
if (source.sources.console) {
bot.console.info(bot.getMessageAsPrismarine(component)?.toAnsi());
} else {
bot.tellraw("@a", component);
}
}
}
module.exports = ListCommand;
-52
View File
@@ -1,52 +0,0 @@
const mc = require("minecraft-protocol");
const util = require("util");
const CommandContext = require("../../command_util/command_context");
class McserverCommand extends CommandContext {
constructor() {
super("mcserver", ["pingserver"], "pings minecraft servers", 0, ["<ip>"]);
}
async execute(context) {
const bot = context.bot;
const config = context.config;
const args = context.arguments;
const [host, port] = args[0].split(":");
const source = context.source;
const server = await mc.ping({ host, port: Number(port ?? 25565) });
let component = [];
try {
component.push({
translate: "%s: %s:%s\n%s: (%s/%s)\n%s: %s\n%s",
color: config.colors.commands.tertiary,
with: [
{ text: "ip", color: config.colors.commands.primary },
{ text: `${host}`, color: config.colors.commands.secondary },
{
text: `${Number(port ?? 25565)}`,
color: config.colors.commands.secondary,
},
{ text: "players", color: config.colors.commands.primary },
{ text: `${server.players.online}`, color: config.colors.integer },
{ text: `${server.players.max}`, color: config.colors.integer },
{ text: "server version", color: config.colors.commands.primary },
{
text: `${server.version.name}`,
color: config.colors.commands.secondary,
},
server.description,
],
});
if (source.sources.console) {
bot.console.info(bot.getMessageAsPrismarine(component)?.toAnsi());
} else {
bot.tellraw("@a", component);
}
} catch (e) {
console.log(e.stack);
bot.chat.message(`${e.toString()}`);
}
}
}
module.exports = McserverCommand;
-65
View File
@@ -1,65 +0,0 @@
const CommandContext = require("../../command_util/command_context");
class NetmsgCommand extends CommandContext {
constructor() {
super(
"netmsg",
["networkmessage", "netmessage"],
"send a message to other servers",
0,
["<message>"],
);
}
execute(context) {
const bot = context.bot;
const config = context.config;
const args = context.arguments;
const source = context.source;
let component = [];
if (bot.options.private === true) {
component.push({
translate: "[%s] %s \u203a %s",
color: config.colors.commands.tertiary,
with: [
{
text: `${bot.options.serverName}`,
color: config.colors.commands.primary,
},
source?.player?.displayName ?? source?.player?.profile?.name,
{
text: `${args.join(" ")}`,
color: config.colors.commands.secondary,
},
],
});
} else {
component.push({
translate: "[%s:%s] %s \u203a %s",
color: config.colors.commands.tertiary,
with: [
{
text: `${bot.options.host}`,
color: config.colors.commands.primary,
},
{
text: `${bot.options.port}`,
color: config.colors.commands.primary,
},
source.player.displayName ?? source.player.profile.name,
{
text: `${args.join(" ")}`,
color: config.colors.commands.secondary,
},
],
});
}
for (const eachBot of bot.bots) {
eachBot.tellraw("@a", component);
}
}
}
module.exports = NetmsgCommand;
-14
View File
@@ -1,14 +0,0 @@
const CommandContext = require("../../command_util/command_context");
class RefillcoreCommand extends CommandContext {
constructor() {
super("refillcore", ["rc", "refill"], "refill the bots core", 0, [""]);
}
execute(context) {
const bot = context.bot;
const config = context.config;
bot.core.move(bot.position);
bot.tellraw("@a", "Refilling core,...");
}
}
module.exports = RefillcoreCommand;
-121
View File
@@ -1,121 +0,0 @@
const CommandError = require("../../command_util/command_error");
const { request } = require("undici");
const CommandContext = require("../../command_util/command_context");
const fixansi = require("../../util/ansi");
const fs = require("fs");
const path = require("path");
const { AttachmentBuilder } = require("discord.js");
class UrbanCommand extends CommandContext {
constructor() {
super("urban", ["urbandictionary"], "urban dictionary", 0, [
"<definition>",
]);
}
async execute(context) {
const source = context.source;
const args = context.arguments;
const bot = context.bot;
const prefix = [
{ text: "[", color: "dark_gray" },
{ text: "Urban", color: "#B72A00" },
{ text: "] ", color: "dark_gray" },
];
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 (bot.options.mode === "savageFriends") {
bot.chat.message(
"this command is disabled for this server for right now sorry!",
);
return;
}
if (!list.length) {
bot.tellraw("@a", { text: "No results found", color: "dark_red" });
}
for (const definitions of list) {
component.push(prefix, [
{
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}`,
},
},
]);
}
if (source.sources.console) {
bot.console.info(bot.getMessageAsPrismarine(component)?.toAnsi());
} else if (source.sources.discord) {
const discordOutput = fixansi(
bot.getMessageAsPrismarine(component)?.toAnsi(),
);
if (discordOutput.length > 2000) {
const output = fs.writeFileSync(
path.join(__dirname, "../../output.txt"),
JSON.stringify(bot.getMessageAsPrismarine(component)?.toString()),
);
const file = new AttachmentBuilder(
path.join(__dirname, "../../output.txt"),
);
bot.discord.message.reply("output", {
files: [file],
});
// bot.discord.message.reply('meow') //[{
// files: path.join(__dirname, '../../output.txt')
// }])
// fs.unlinkSync(path.join(__dirname, '../../output.txt'))
} else {
bot.discord.message.reply(`\`\`\`ansi\n${discordOutput}\`\`\``);
}
// console.log(discordOutput.length)
} else if (bot.options.mode === "savageFriends") {
bot.core.run(`minecraft:tellraw @a ${JSON.stringify(component)}`);
} else {
bot.tellraw(`@a`, component);
}
}
}
module.exports = UrbanCommand;
-122
View File
@@ -1,122 +0,0 @@
const CommandError = require("../../command_util/command_error");
const { request } = require("undici");
const CommandContext = require("../../command_util/command_context");
class WeatherCommand extends CommandContext {
constructor() {
super("weather", [], "check the weather in locations", 0, [
"<weather/zip code>",
]);
}
async execute(context) {
const bot = context.bot;
const config = context.config;
const args = context.arguments;
const source = context.source;
let component = [];
try {
const url = await request(
`https://api.weatherapi.com/v1/current.json?key=${config.weatherApiKey}&q=${args.join(" ").replaceAll(" ", "%20")}`,
);
const info = await url.body.json();
component.push({
translate: "%s\n%s: %s, %s\n%s: %s (%s)\n%s\n%s\n%s: %s\n%s: %s",
color: config.colors.commands.tertiary,
with: [
{
translate: "%s: %s, %s %s",
with: [
{ text: "Location", color: config.colors.commands.primary },
{
text: `${info.location.name}`,
color: config.colors.commands.secondary,
},
{
text: `${info.location.region}`,
color: config.colors.commands.secondary,
},
{
text: `${info.location.country}`,
color: config.colors.commands.secondary,
},
],
},
{ text: "Coords", color: config.colors.commands.primary },
{ text: `${info.location.lat}`, color: config.colors.integer },
{ text: `${info.location.lon}`, color: config.colors.integer },
{ text: "Time", color: config.colors.commands.primary },
{
text: `${new Date().toLocaleTimeString("en-US", { timeZone: info.location.tz_id })}`,
color: config.colors.commands.secondary,
},
{
text: `${info.location.tz_id}`,
color: config.colors.commands.secondary,
},
{
translate: "%s: %s (%s), %s (%s)",
with: [
{ text: "Temp", color: config.colors.commands.primary },
{
text: `${Math.floor(info.current.temp_c)}`,
color: config.colors.integer,
},
{ text: "\u00b0C", color: config.colors.commands.secondary },
{
text: `${Math.floor(info.current.temp_f)}`,
color: config.colors.integer,
},
{ text: "\u00b0F", color: config.colors.commands.secondary },
],
},
{
translate: "%s: %s (%s, %s), %s (%s, %s)",
with: [
{ text: "Wind Speed", color: config.colors.commands.primary },
{
text: `${Math.floor(info.current.wind_kph)}`,
color: config.colors.integer,
},
{ text: "kph", color: config.colors.commands.secondary },
{
text: `${info.current.wind_dir}`,
color: config.colors.commands.secondary,
},
{
text: `${Math.floor(info.current.wind_mph)}`,
color: config.colors.integer,
},
{ text: "mph", color: config.colors.commands.secondary },
{
text: `${info.current.wind_dir}`,
color: config.colors.commands.secondary,
},
],
},
{ text: "Condition", color: config.colors.commands.primary },
{
text: `${info.current.condition.text}`,
color: config.colors.commands.secondary,
},
{ text: "Humidity", color: config.colors.commands.primary },
{
text: `${Math.floor(info.current.humidity)}`,
color: config.colors.integer,
},
],
});
if (source.sources.console) {
bot.console.info(bot.getMessageAsPrismarine(component)?.toAnsi());
} else {
bot.tellraw("@a", component);
}
} catch (e) {
bot.chat.message(e.toString());
}
}
}
module.exports = WeatherCommand;
-45
View File
@@ -1,45 +0,0 @@
const wiki = require("wikipedia");
const CommandError = require("../../command_util/command_error");
const fixansi = require("../../util/ansi");
const CommandContext = require("../../command_util/command_context");
class WikiCommand extends CommandContext {
constructor() {
super("wiki", ["wikipedia"], "wikipedia", 0, ["<article>"]);
}
async execute(context) {
const source = context.source;
const args = context.arguments;
const bot = context.bot;
const config = context.config;
let component = [];
try {
const page = await wiki.page(args.join(" "));
const summary = await page.intro();
component.push({ text: summary, color: config.colors.commands.primary });
if (source.sources.console) {
bot.console.info(bot.getMessageAsPrismarine(component)?.toAnsi());
} else if (source.sources.discord) {
bot.discord.message.reply(
`\`\`\`ansi\n${new fixansi(bot.getMessageAsPrismarine(component)?.toAnsi()).ansi}\`\`\``,
);
} else {
bot.tellraw("@a", component);
}
} catch (e) {
if (
e.toString() ===
"pageError: TypeError: Cannot read properties of undefined (reading 'pages')"
) {
bot.tellraw("@a", { text: "no article found!", color: "red" });
} else {
bot.tellraw(`@a`, `${e.toString()}`);
}
}
}
}
module.exports = WikiCommand;
-108
View File
@@ -1,108 +0,0 @@
const CommandError = require("../../command_util/command_error");
const fixAnsi = require("../../util/ansi");
const CommandContext = require("../../command_util/command_context");
class CloopCommand extends CommandContext {
constructor() {
super("cloop", ["commandloop", "loop"], "loops commands", 1, [
"add <interval> <command>",
"remove <index>",
"list",
"clear",
]);
}
execute(context) {
const bot = context.bot;
const config = context.config;
const source = context.source;
let args;
let component = [];
if (!source.sources.console && !source.sources.discord) {
args = context.arguments.slice(16);
} else {
args = context.arguments;
}
if (
!args &&
!args[0] &&
!args[1] &&
!args[2] &&
!args[3] &&
!args[4] &&
!args[5]
)
return;
switch (args[0]?.toLowerCase()) {
case "add":
if (isNaN(args[1])) throw new CommandError("invalid interval");
const interval = parseInt(args[1]);
const command = args.slice(2).join(" ");
bot.cloop.add(command, interval);
component.push(
`added ${command} to the cloops with the interval ${interval}`,
);
break;
case "clear":
bot.cloop.clear();
component.push("cleared the cloops");
break;
case "remove":
if (isNaN(args[1]))
throw new CommandError("argument must be an integer!");
const index = parseInt(args[1]);
bot.cloop.remove(index);
component.push(`removed ${index} from cloops`);
break;
case "list":
let listComponent = [];
let i = 0;
for (const cloop of bot.cloop.list) {
listComponent.push({
translate: "%s \u203a %s (%s)",
color: config.colors.commands.primary,
with: [
{ text: `${i}`, color: config.colors.integer },
cloop.command,
{ text: `${cloop.interval}`, color: config.colors.integer },
],
});
listComponent.push("\n");
i++;
}
listComponent.pop();
component.push({
translate: "Cloops (%s):",
color: config.colors.commands.primary,
with: [
{ text: `${bot.cloop.list.length}`, color: config.colors.integer },
],
});
component.push("\n");
if (bot.cloop.list.length > 0) {
component.push(listComponent);
}
break;
default:
throw new CommandError("invalid argument");
}
if (source.sources.discord) {
} else if (source.sources.console) {
bot.console.info(component);
} else {
bot.tellraw("@a", component);
}
}
}
module.exports = CloopCommand;
-24
View File
@@ -1,24 +0,0 @@
const CommandContext = require("../../command_util/command_context");
class ValidateCommand extends CommandContext {
constructor() {
super("validate", ["val"], "validate through the bot", 1, [""]);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const source = context.source;
if (args[0] === bot.validation.trusted) {
bot.chat.message("&2Valid Trusted hash");
}
if (args[0] === bot.validation.admin) {
bot.chat.message("&2Valid Admin hash");
}
if (args[0] === bot.validation.owner) {
bot.chat.message("&2Valid Owner hash");
}
}
}
module.exports = ValidateCommand;
-41
View File
@@ -1,41 +0,0 @@
const CommandError = require("../../commandUtil/CommandError");
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class kick extends CommandContext {
constructor() {
super(
"kick",
[],
"kick a player from the server",
trustLevel.admin,
["invalidstring", "item", "te"],
false,
);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const config = context.config;
if (!args && !args[0] && !args[1] && !args[2]) return;
switch (args[0]?.toLowerCase()) {
case "invalidstring":
bot.exploits.crashes.invalidString(args[2]);
bot.tellraw("@a", `crashing ${args[2]}`);
break;
case "item":
bot.exploits.kicks.item(args[2]);
bot.tellraw("@a", `kicking ${args[2]}`);
break;
case "te":
bot.exploits.kicks.translateEntity(args[2]);
bot.tellraw("@a", `kicking ${args[2]}`);
break;
default:
throw new CommandError("invalid argument");
}
}
}
module.exports = kick;
-126
View File
@@ -1,126 +0,0 @@
const CommandError = require("../../commandUtil/CommandError");
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class console extends CommandContext {
constructor() {
super(
"console",
["c"],
"runs commands made for the bots console",
trustLevel.console,
[
"server/srv <all/servername>",
"customchat <on/true/enable/off/false/disable>",
"say <message>",
"validate/validation/val <owner/o/admin/a/trusted/t>",
"logging/togglelogging/logtoconsole <on/true/enable/off/false/disable>",
],
false,
);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const source = context.source;
const config = context.config;
if (!args && !args[0] && !args[1] && !args[2] && !args[3]) return;
switch (args[0]?.toLowerCase()) {
case "server":
case "svr":
const servers = bot.bots.map((eachBot) => eachBot.options.serverName);
for (const eachBot of bot.bots) {
if (args.slice(1).join(" ").toLowerCase() === "all") {
eachBot.console.server = "all";
bot.console.info("Set the console server to all");
continue;
}
const server = servers.find((server) =>
server.toLowerCase().includes(args[1]),
);
if (!server) {
bot.console.info("Invalid server");
return;
}
bot.console.info(`Set the console server to ` + server);
eachBot.console.server = server;
}
break;
case "say":
bot.chat.send(args.slice(1).join(" "));
break;
case "validate":
case "validation":
case "val":
switch (args[1]?.toLowerCase()) {
case "owner":
case "o":
bot.chat.message(
`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.owner} ${args.slice(3).join(" ")}`,
);
break;
case "admin":
case "a":
bot.chat.message(
`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.admin} ${args.slice(3).join(" ")}`,
);
break;
case "trusted":
case "t":
bot.chat.message(
`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.trusted} ${args.slice(3).join(" ")}`,
);
break;
default:
throw new CommandError({
translate: "command.unknown.argument",
color: "dark_red",
});
}
break;
case "logging":
case "togglelogging":
case "logtoconsole":
switch (args[1]?.toLowerCase()) {
case "on":
case "enable":
case "enabled":
case "true":
if (bot.options.logging === true) {
bot.console.info(
`logging for ${bot.options.serverName} is already enabled!`,
);
} else {
bot.console.info(
`logging for ${bot.options.serverName} is now enabled`,
);
bot.options.logging = true;
}
break;
case "off":
case "disable":
case "disabled":
case "false":
if (bot.options.logging === false) {
bot.console.info(
`logging for ${bot.options.serverName} is already disabled!`,
);
} else {
bot.console.info(
`logging for ${bot.options.serverName} is now disabled`,
);
bot.options.logging = false;
}
break;
}
break;
default:
throw new CommandError({
translate: "command.unknown.argument",
color: "dark_red",
});
}
}
}
module.exports = console;
-24
View File
@@ -1,24 +0,0 @@
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class kill extends CommandContext {
constructor() {
super(
"kill",
[
"suicide",
"quit"
],
"kill the bots process",
trustLevel.owner,
[""],
false
);
}
execute(context) {
const bot = context.bot;
process.exit(1);
}
}
module.exports = kill;
-46
View File
@@ -1,46 +0,0 @@
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class core extends CommandContext {
constructor() {
super(
"core",
[
"cb",
"cbrun",
"corerun"
],
"run commands in core",
trustLevel.public,
[
"$username <message>",
"$uuid <message>",
"<message>"
],
false,
);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const source = context.source;
if (args.includes("$username") || args.includes("$uuid")) {
bot.players.forEach((eachPlayer) => {
bot.core.runTracked(
args
.join(" ")
.replaceAll("$username", eachPlayer.profile.name)
.replaceAll("$uuid", eachPlayer.uuid),
source,
);
});
} else if (bot.options.mode === "savageFriends") {
bot.core.run(args.join(" "));
} else {
bot.core.runTracked(args.join(" "), source);
}
}
}
module.exports = core;
-26
View File
@@ -1,26 +0,0 @@
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class echo extends CommandContext {
constructor() {
super(
"echo",
[
"say",
"botsay"
],
"make me say something!",
trustLevel.public,
[""],
true
);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
bot.chat.send(`${args.join(" ")}`);
}
}
module.exports = echo;
-57
View File
@@ -1,57 +0,0 @@
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class extras extends CommandContext {
constructor() {
super(
"extras",
[],
"send messages via the extras channel",
trustLevel.public,
[
"send",
"register",
"unregister",
"unregisterall"
],
true,
);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const source = context.source
if (
!args
&&
!args[0]
&&
!args[1]
&&
!args[2]
) return;
switch (args[0]) {
case "send":
bot.extras.send(args[1], args.slice(2).join(" "))
source.sendFeedback(`sent ${args.slice(2).join(" ")} to channel ${args[1]}`)
break
case "register":
bot.extras.register(args[1])
source.sendFeedback(`registered ${args[1]} channel`)
break
case "unregister":
bot.extras.unregister(args[1])
source.sendFeedback(`unregistered from ${args[1]} channel`)
console.log(bot.extras.channels)
break
case "unregisterall":
bot.extras.unregisterAll();
source.sendFeedback("unregistered all channels")
break
}
}
}
module.exports = extras;
-229
View File
@@ -1,229 +0,0 @@
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class help extends CommandContext {
constructor() {
super(
"help",
[
"heko",
"?",
"cmds",
"commands",
"hell"
],
"see a list of commands",
trustLevel.public,
["<command>"],
false,
);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const config = context.config;
const source = context.source;
const translations = bot.translations;
let component = [];
let infoComponent = [];
let usagesComponent = [];
let Public = [];
let trusted = [];
let admin = [];
let owner = [];
let Console = [];
component.push({
translate: "%s %s \u203a\n",
color: config.colors.commands.tertiary,
with: [
{
translate: "fnfboyfriendbot.command.help.command_layout",
fallback: translations["fnfboyfriendbot.command.help.command_layout"],
color: config.colors.commands.primary,
with: [
{ text: ':', color: config.colors.commands.tertiary },
{ text: '(', color: config.colors.commands.tertiary },
{ text: `${bot.commandManager.commandlist.length}`, color: config.colors.integer },
{ text: ')', color: config.colors.commands.tertiary }
]
},
{
translate: "fnfboyfriendbot.command.help.category",
fallback: translations["fnfboyfriendbot.command.help.category"],
with: [
{
translate: "fnfboyfriendbot.command.help.trust_level.public",
fallback: translations["fnfboyfriendbot.command.help.trust_level.public"],
color: config.colors.help.public
},
{
translate: "fnfboyfriendbot.command.help.trust_level.trusted",
fallback: translations["fnfboyfriendbot.command.help.trust_level.trusted"],
color: config.colors.help.trusted
},
{
translate: "fnfboyfriendbot.command.help.trust_level.admin",
fallback: translations["fnfboyfriendbot.command.help.trust_level.admin"],
color: config.colors.help.admin
},
{
translate: "fnfboyfriendbot.command.help.trust_level.owner",
fallback: translations["fnfboyfriendbot.command.help.trust_level.owner"],
color: config.colors.help.owner
}
]
}
]
})
for (const commands of bot.commandManager.commandlist) {
switch (commands.data.trustLevel) {
case 0:
Public.push({
text: commands.data.name + " ",
color: config.colors.help.public,
});
break;
case 1:
trusted.push({
text: commands.data.name + " ",
color: config.colors.help.trusted,
});
break;
case 2:
admin.push({
text: commands.data.name + " ",
color: config.colors.help.admin,
});
break;
case 3:
owner.push({
text: commands.data.name + " ",
color: config.colors.help.owner,
});
break;
case 4:
Console.push({
text: commands.data.name + " ",
color: config.colors.help.console,
});
break;
default:
}
if (
args[0]?.toLowerCase() === commands.data.name?.toLowerCase() ||
commands.data.aliases.find(
(e) => e?.toLowerCase() === args[0]?.toLowerCase(),
)
) {
for (const usages of commands.data.usages) {
usagesComponent.push({
translate: "%s%s %s",
with: [
{
text: `${config.prefixes[0]}`,
color: config.colors.commands.primary,
},
{
text: `${commands.data.name}`,
color: config.colors.commands.secondary,
},
{ text: `${usages}`, color: config.colors.commands.secondary },
],
});
usagesComponent.push("\n");
}
usagesComponent.pop();
infoComponent.push({
translate: "%s\n%s\n%s\n%s\n%s",
color: config.colors.commands.tertiary,
with: [
{
translate: "fnfboyfriendbot.command.help.info.command",
fallback: translations["fnfboyfriendbot.command.help.info.command"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
commands.data.name,
]
},
{
translate: "fnfboyfriendbot.command.help.info.alias",
fallback: translations["fnfboyfriendbot.command.help.info.alias"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
commands.data.aliases.toString().replaceAll(',',' ')
]
},
{
translate: "fnfboyfriendbot.command.help.info.description",
fallback: translations["fnfboyfriendbot.command.help.info.description"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
commands.data.description
]
},
{
translate: "fnfboyfriendbot.command.help.info.trust_level",
fallback: translations["fnfboyfriendbot.command.help.info.trust_level"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${commands.data.trustLevel}`, color: config.colors.integer }
]
},
{
translate: "fnfboyfriendbot.command.help.usages",
fallback: translations["fnfboyfriendbot.command.help.info.usages"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
usagesComponent
]
},
]
})
source.sendFeedback(infoComponent)
return;
}
}
if (Public.length > 0) {
component.push(Public);
if (trusted.length > 0) component.push("\n");
}
if (trusted.length > 0) {
component.push(trusted);
if (admin.length > 0) component.push("\n");
}
if (admin.length > 0) {
component.push(admin);
if (owner.length > 0) component.push("\n");
}
if (owner.length > 0) {
component.push(owner);
}
if (source.sources.console && Console.length > 0) {
component.push(Console);
}
source.sendFeedback(component)
}
}
module.exports = help;
-457
View File
@@ -1,457 +0,0 @@
const os = require("os");
const CommandError = require("../../commandUtil/CommandError");
const botInfo = require("../../data/info.json");
const { execSync } = require("child_process");
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
function format(seconds) {
function pad(s) {
return (s < 10 ? "0" : "") + s;
}
var hours = Math.floor(seconds / (60 * 60));
var minutes = Math.floor((seconds % (60 * 60)) / 60);
var seconds = Math.floor(seconds % 60);
return (
pad(`${hours} Hours`) +
" " +
pad(`${minutes} Minutes`) +
" " +
pad(`${seconds} Seconds`)
);
}
class info extends CommandContext {
constructor() {
super(
"info",
["information"],
"check the bots info",
trustLevel.public,
[
"about",
"config",
"contributors/credits",
"discord",
"loaded",
"usages ",
"uptimes",
"server",
"version",
],
false
);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const config = context.config;
const discordClient = context.discordClient;
const source = context.source;
const translations = bot.translations;
let component = [];
switch (args[0]?.toLowerCase()) {
case "about":
component.push({
translate: "fnfboyfriendbot.command.info.about",
fallback: translations["fnfboyfriendbot.command.info.about"],
color: config.colors.commands.primary,
})
break;
case "config":
component.push({
translate: "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s",
color: config.colors.commands.tertiary,
with: [
{
translate: "fnfboyfriendbot.command.info.config.server.ip",
fallback: translations["fnfboyfriendbot.command.info.config.server.ip"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${bot.options.host}`, color: config.colors.commands.primary },
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${bot.options.port}`, color: config.colors.integer }
]
},
{
translate: "fnfboyfriendbot.command.info.config.server.name",
fallback: translations["fnfboyfriendbot.command.info.config.server.name"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
bot.options.serverName
]
},
{
translate: "fnfboyfriendbot.command.info.config.minecraft.username",
fallback: translations["fnfboyfriendbot.command.info.config.minecraft.username"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${bot._client.username}`, color: config.colors.commands.secondary }
]
},
{
translate: "fnfboyfriendbot.command.info.config.minecraft.version",
fallback: translations["fnfboyfriendbot.command.info.config.minecraft.version"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${bot._client.version}`, color: config.colors.commands.secondary },
]
},
{
translate: "fnfboyfriendbot.command.info.config.discord.username",
fallback: translations["fnfboyfriendbot.command.info.config.discord.username"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${discordClient?.user?.tag}`, color: config.colors.commands.secondary }
]
},
{
translate: "fnfboyfriendbot.command.info.config.discord.channel",
fallback: translations["fnfboyfriendbot.command.info.config.discord.channel"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${bot.discord?.channel?.name}`, color: config.colors.commands.secondary }
]
},
{
translate: "fnfboyfriendbot.command.info.config.server.count",
fallback: translations["fnfboyfriendbot.command.info.config.server.count"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${bot.bots.length}`, color: config.colors.integer }
]
},
{
translate: "fnfboyfriendbot.command.info.config.prefixes",
fallback: translations["fnfboyfriendbot.command.info.config.prefixes"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${config.prefixes.map((e) => e + " ").join(' ')}`, color: config.colors.commands.secondary }
]
},
{
translate: "fnfboyfriendbot.command.info.config.mode",
fallback: translations["fnfboyfriendbot.command.info.config.mode"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${bot.options.mode}`, color: config.colors.commands.secondary }
]
}
]
})
break;
case "contributors":
case "credits":
component.push({
translate: "%s%s - %s\n%s:\n%s\n%s\n%s\n%s\n%s\n%s",
color: config.colors.commands.tertiary,
with: [
{ text: "Parker", color: "dark_red" },
{ text: "2991", color: "black" },
{ text: "Owner" },
{ text: "Contributors" },
{ text: "_ChipMC_", color: "dark_blue" },
{ text: "chayapak", color: "yellow" },
{ text: "_yfd", color: "light_purple" },
{ text: "aaa/ImFloriz", color: "gold" },
{ text: "Ploat/ImGloriz", color: "#cd8ccb" },
{ text: "TurtleKid", color: "green" }
],
});
break;
case "discord":
component.push({
translate: "fnfboyfriendbot.command.info.discord",
fallback: translations["fnfboyfriendbot.command.info.discord"],
color: config.colors.commands.primary,
with: [
{ text: `${config.discord.invite}`, color: config.colors.commands.secondary }
],
hover_event: {
action: "show_text",
value: [
{
text: "click here to join the discord server!",
color: `${config.colors.commands.primary}`,
},
],
},
click_event: {
action: "open_url",
url: `${config.discord.invite}`,
}
})
break;
case "loaded":
component.push({
translate: "%s\n%s",
with: [
{
translate: "fnfboyfriendbot.command.info.loaded.commands",
fallback: translations["fnfboyfriendbot.command.info.loaded.commands"],
color: config.colors.commands.primary,
with: [
{ text: `${bot.commandManager.commandlist.length}`, color: config.colors.integer}
]
},
{
translate: "fnfboyfriendbot.command.info.loaded.modules",
fallback: translations["fnfboyfriendbot.command.info.loaded.modules"],
color: config.colors.commands.primary,
with: [
{ text: `${bot.modules.length}`, color: config.colors.integer }
]
}
]
})
break;
case "server":
component.push({
translate: "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s",
color: config.colors.commands.primary,
with: [
{
translate: "fnfboyfriendbot.command.info.server.hostname",
fallback: translations["fnfboyfriendbot.command.info.server.hostname"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${os.hostname()}`, color: config.colors.commands.secondary },
]
},
{
translate: "fnfboyfriendbot.command.info.server.user",
fallback: translations["fnfboyfriendbot.command.info.server.user"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${os.userInfo().username}`, color: config.colors.commands.secondary }
]
},
{
translate: "fnfboyfriendbot.command.info.server.directory",
fallback: translations["fnfboyfriendbot.command.info.server.directory"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${require.main.path}`, color: config.colors.commands.secondary }
]
},
{
translate: "fnfboyfriendbot.command.info.server.arch",
fallback: translations["fnfboyfriendbot.command.info.server.arch"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${os.arch}`, color: config.colors.commands.secondary }
]
},
{
translate: "fnfboyfriendbot.command.info.server.os",
fallback: translations["fnfboyfriendbot.command.info.server.os"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${os.platform}`, color: config.colors.commands.primary }
]
},
{
translate: "fnfboyfriendbot.command.info.server.os.version",
fallback: translations["fnfboyfriendbot.command.info.server.os.version"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${os.version()}`, color: config.colors.commands.secondary }
]
},
{
translate: "fnfboyfriendbot.command.info.server.kernel_version",
fallback: translations["fnfboyfriendbot.command.info.server.kernel_version"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${os.release()}`, color: config.colors.commands.secondary }
]
},
{
translate: "fnfboyfriendbot.command.info.server.cpu",
fallback: translations["fnfboyfriendbot.command.info.server.cpu"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${os.cpus()[0].model}`, color: config.colors.commands.secondary }
]
},
{
translate: "fnfboyfriendbot.command.info.server.cpu.cores",
fallback: translations["fnfboyfriendbot.command.info.server.cpu.cores"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${os.cpus().length}`, color: config.colors.integer }
]
},
{
translate: "fnfboyfriendbot.command.info.server.processes",
fallback: translations["fnfboyfriendbot.command.info.server.processes"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${execSync("ps aux | wc -l").toString().replace("\n", "")}`, color: config.colors.integer }
]
},
{
translate: "fnfboyfriendbot.command.info.server.node_version",
fallback: translations["fnfboyfriendbot.command.info.server.node_version"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${process.version}`, color: config.colors.commands.secondary }
]
},
{
translate: "fnfboyfriendbot.command.info.server.npm_version",
fallback: translations["fnfboyfriendbot.command.info.server.npm_version"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${execSync("npm -v").toString().replaceAll("\n", "")}`, color: config.colors.commands.secondary }
]
}
]
})
break;
case "usages":
component.push({
translate: "%s\n%s",
color: config.colors.commands.tertiary,
with: [
{
translate: "fnfboyfriendbot.command.info.usages.botmem",
fallback: translations["fnfboyfriendbot.command.info.usages.botmem"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${Math.floor(process.memoryUsage().heapUsed / 1048576)}`, color: config.colors.integer },
{ text: `${Math.floor(process.memoryUsage().heapTotal / 1048576)}`, color: config.colors.integer }
]
},
{
translate: "fnfboyfriendbot.command.info.usages.servermem",
fallback: translations["fnfboyfriendbot.command.info.usages.servermem"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${Math.floor(os.totalmem() / 1048576) - Math.floor(os.freemem() / 1048576)}`, color: config.colors.integer },
{ text: `${Math.floor(os.totalmem() / 1048576)}`, color: config.colors.integer }
]
}
]
});
break;
case "uptimes":
component.push({
translate: "%s\n%s",
color: config.colors.commands.tertiary,
with: [
{
translate: "fnfboyfriendbot.command.info.uptimes.bot",
fallback: translations["fnfboyfriendbot.command.info.uptimes.bot"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${format(process.uptime())}`}
]
},
{
translate: "fnfboyfriendbot.command.info.uptimes.server",
fallback: translations["fnfboyfriendbot.command.info.uptimes.server"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${format(os.uptime())}`, color: config.colors.commands.secondary }
]
}
],
});
break;
case "version":
component.push({
translate: "%s %s %s-%s-%s\n%s\n%s\n%s\n%s\n%s-%s",
color: config.colors.commands.tertiary,
with: [
{ text: "Friday Night Funkin", color: "dark_blue" },
{ text: "Boyfriend", color: "dark_aqua" },
{ text: "Bot", color: "blue" },
{
text: `${botInfo.buildstring.version}`,
color: config.colors.integer,
},
botInfo.buildstring.codename || '',
{
translate: "fnfboyfriendbot.command.info.version.build",
fallback: translations["fnfboyfriendbot.command.info.version.build"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${botInfo.buildstring.build}`, color: config.colors.integer }
]
},
{
translate: "fnfboyfriendbot.command.info.version.repo_build",
fallback: translations["fnfboyfriendbot.command.info.version.repo_build"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${execSync("git rev-list --count --all").toString().replaceAll("\n", "")}`, color: config.colors.integer }
]
},
{
translate: "fnfboyfriendbot.command.info.version.version_release_date",
fallback: translations["fnfboyfriendbot.command.info.version.version_release_date"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${new Date(execSync("git log -1 --format=%ci").toString()).toLocaleString("en-US", { timeZone: "America/CHICAGO" })}`, color: config.colors.commands.secondary }
]
},
{
translate: "fnfboyfriendbot.command.info.version.commit",
fallback: translations["fnfboyfriendbot.command.info.version.commit"],
color: config.colors.commands.primary,
with: [
{ text: ":", color: config.colors.commands.tertiary },
{ text: `${execSync("git rev-parse HEAD").toString().substring(0, 10)}`, color: config.colors.commands.secondary }
]
},
{ text: "11/22/22", color: config.colors.commands.primary },
{
text: `${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`,
color: config.colors.commands.secondary,
},
],
});
break;
default:
throw new CommandError({
translate: "command.unknown.argument",
color: "dark_red",
});
}
source.sendFeedback(component);
}
}
module.exports = info;
-57
View File
@@ -1,57 +0,0 @@
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class list extends CommandContext {
constructor() {
super(
"list",
[
"pl",
"playerlist"
],
"check whos online on the server",
trustLevel.public,
[""],
false
);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const config = context.config;
const source = context.source;
let component = [];
let playerCount = [];
playerCount.push({
translate: "%s: (%s)\n",
color: config.colors.commands.tertiary,
with: [
{ text: "Players", color: config.colors.commands.primary },
{ text: `${bot.players.length}`, color: config.colors.integer },
]
});
component.push(playerCount);
for (const player of bot.players) {
component.push({
translate: "%s \u203a %s [%s: %s]",
color: config.colors.commands.tertiary,
with: [
player.displayName ?? player.profile.name,
{ text: `${player.uuid}`, color: config.colors.commands.primary },
{ text: "Latency", color: config.colors.commands.primary },
{ text: `${player.latency}`, color: config.colors.integer }
]
})
component.push("\n");
}
component.pop();
source.sendFeedback(component)
}
}
module.exports = list;
-87
View File
@@ -1,87 +0,0 @@
const mc = require("minecraft-protocol");
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class mcserver extends CommandContext {
constructor() {
super("mcserver",
["pingserver"],
"pings minecraft servers",
trustLevel.public,
["<ip>"],
false,
);
}
async execute(context) {
const bot = context.bot;
const config = context.config;
const args = context.arguments;
const source = context.source;
const translations = bot.translations
const [host, port] = args[0].split(':')
let component = [];
if (isNaN(port) && port) {
source.sendFeedback({
translate: "fnfboyfriendbot.arguments.invalid_integer",
fallback: translations["fnfboyfriendbot.arguments.invalid_integer"],
color: "red",
with: [
{ text: "Port" }
]
})
return
}
process.on('uncaughtException', (error) => {
console.log(error)
source.sendFeedback({
translate: "fnfboyfriendbot.command.mcserver.server.unknown",
fallback: translations["fnfboyfriendbot.command.mcserver.server.unknown"],
color: "red",
with: [
{ text: `${host}` },
{ text: `${Number(port ?? 25565)}` }
]
})
})
const server = await mc.ping({ host, port: Number(port ?? 25565) })
component.push({
translate: "%s\n%s\n%s\n%s",
with: [
{
translate: "fnfboyfriendbot.command.mcserver.ip",
fallback: translations["fnfboyfriendbot.command.mcserver.ip"],
color: config.colors.commands.primary,
with: [
{ text: `${host}`, color: config.colors.commands.secondary },
{ text: `${Number(port ?? 25565)}`, color: config.colors.integer }
]
},
{
translate: "fnfboyfriendbot.command.mcserver.players",
fallback: translations["fnfboyfriendbot.command.mcserver.players"],
color: config.colors.commands.primary,
with: [
{ text: `${server.players.online}`, color: config.colors.integer },
{ text: `${server.players.max}`, color: config.colors.integer }
]
},
{
translate: "fnfboyfriendbot.command.mcserver.server.version",
fallback: translations["fnfboyfriendbot.command.mcserver.server.version"],
color: config.colors.commands.primary,
with: [
{ text: `${server.version.name}`, color: config.colors.commands.secondary }
]
},
server.description
]
})
source.sendFeedback(component)
}
}
module.exports = mcserver;
-54
View File
@@ -1,54 +0,0 @@
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class netmsg extends CommandContext {
constructor() {
super(
"netmsg",
[
"networkmessage",
],
"send a message to other servers that the bot is connected to",
trustLevel.public,
["<message>"],
true,
);
}
execute(context) {
const bot = context.bot;
const config = context.config;
const args = context.arguments;
const source = context.source;
let component = [];
if (bot.options.private === true) {
component.push({
translate: "[%s] %s \u203a %s",
color: config.colors.commands.tertiary,
with: [
{ text: `${bot.options.serverName}`, color: config.colors.commands.primary },
source?.player?.displayName ?? source?.player?.profile?.name,
{ text: `${args.join(' ')}`, color: config.colors.commands.secondary }
]
})
} else {
component.push({
translate: "[%s:%s] %s \u203a %s",
color: config.colors.commands.tertiary,
with: [
{ text: `${bot.options.host}`, color: config.colors.commands.primary },
{ text: `${bot.options.port}`, color: config.colors.commands.primary },
source.player.displayName ?? source.player.profile.name,
{ text: `${args.join(' ')}`, color: config.colors.commands.secondary }
]
})
}
for (const eachBot of bot.bots) {
eachBot.tellraw("@a", component)
}
}
}
module.exports = netmsg;
-32
View File
@@ -1,32 +0,0 @@
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class refillcore extends CommandContext {
constructor() {
super(
"rc",
[
"refill",
"refillcore"
],
"refill the bots core",
trustLevel.public,
[""],
false,
);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const source = context.source
bot.core.move(bot.position);
source.sendFeedback({
translation: "command.core.refill",
}) // most likely wont be seen most of the time
}
}
module.exports = refillcore;
-49
View File
@@ -1,49 +0,0 @@
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
const between = require('../../util/between');
class rtp extends CommandContext {
constructor() {
super(
"rtp",
[
"randomtp",
"tpr",
"tprandom"
],
"teleport to a random place. This was ported from FNFBoyfriendBot v4.x",
trustLevel.public,
[""],
true
);
}
execute(context) {
const bot = context.bot;
const source = context.source;
const config = context.config;
const translations = bot.translations;
const x = between(-1_000_000, 1_000_000);
const y = 100;
const z = between(-1_000_000, 1_000_000);
let component = [];
bot.core.run(`essentials:tp ${source.player.uuid} ${x} ${y} ${z}`)
component.push({
translate: "fnfboyfriendbot.command.rtp",
fallback: translations["fnfboyfriendbot.command.rtp"],
color: config.colors.commands.primary,
with: [
{ text: `${source.player.profile.name}`, color: config.colors.commands.secondary },
{ text: `${x}`, color: config.colors.integer },
{ text: `${y}`, color: config.colors.integer },
{ text: `${z}`, color: config.colors.integer }
]
})
bot.tellraw('@a', component)
}
}
module.exports = rtp
-25
View File
@@ -1,25 +0,0 @@
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class test extends CommandContext {
constructor() {
super(
"test",
[],
"testing stuff",
trustLevel.public,
[""],
true
);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const source = context.source;
bot.chat.message('meow')
}
}
module.exports = test;
-126
View File
@@ -1,126 +0,0 @@
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
const { request } = require('undici');
class urban extends CommandContext {
constructor() {
super(
"urban",
[
"urbandictionary"
],
"look up definitions on urban dictionary",
trustLevel.public,
["<definition>"],
true,
);
}
async execute(context) {
const bot = context.bot;
const source = context.source;
const args = context.arguments;
const config = context.config;
const translations = bot.translations;
let term = args.join(' ');
try {
const prefix = {
translate: "[%s] ",
color: config.colors.commands.primary,
with: [
{
translate: "fnfboyfriendbot.command.urban.text",
fallback: translations["fnfboyfriendbot.command.urban.text"],
color: "#B72A00"
}
]
}
const query = new URLSearchParams({ term });
const dictResult = await request(`https://api.urbandictionary.com/v0/define?${query}`);
const { list } = await dictResult.body.json();
let component = [];
for (const definitions of list) {
component.push(prefix, [
{
text: `${definitions.definition.replaceAll('\r','').replaceAll('[', '\xa71\xa7n\xa7o').replaceAll(']','\xa7r\xa77')}\n`,
color: 'gray',
underlined: false,
italic: false,
translate: ""
}
])
}
source.sendFeedback(component)
} catch (e) {
bot.console.error(e.stack)
}
}
}
module.exports = urban;
/*
const prefix = [
{ text: '[', color: 'dark_gray' },
{ text: 'Urban', color: '#B72A00' },
{ text: '] ', color: 'dark_gray'}
]
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 (bot.options.mode === "savageFriends") {
bot.chat.message('this command is disabled for this server for right now sorry!');
return;
}
if (!list.length) {
bot.tellraw("@a", { text: "No results found", color: "dark_red" });
}
for (definitions of list) {
component.push(prefix, [
{
text: `${definitions.definition.replaceAll('\r','').replaceAll('[', '\xa71\xa7n\xa7o').replaceAll(']','\xa7r\xa77')}\n`,
color: 'gray',
underlined: false,
italic: false,
translate: "",
hover_event: {
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'
}
]
},
click_event: {
action: 'open_url',
value: `${definitions.permalink}`
}
},
])
*/
-158
View File
@@ -1,158 +0,0 @@
const { request } = require("undici");
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class weather extends CommandContext {
constructor() {
super(
"weather",
[],
"check the weather in locations",
trustLevel.public,
["<weather/zip code>"],
false,
);
}
async execute(context) {
const bot = context.bot;
const config = context.config;
const args = context.arguments;
const source = context.source;
const translations = bot.translations;
let component = [];
try {
const url = await request(
`https://api.weatherapi.com/v1/current.json?key=${config.weatherApiKey}&q=${args.join(" ").replaceAll(" ", "%20")}`,
);
const info = await url.body.json();
if (info.error) source.sendFeedback({
translate: "fnfboyfriendbot.command.weather.unknown_location",
fallback: translations["fnfboyfriendbot.command.weather.unknown_location"],
color: "red",
with: [
{ text: `${args.join(' ')}`}
]
})
component.push({
translate: "%s\n%s\n%s\n%s\n%s\n%s\n%s",
color: config.colors.commands.tertiary,
with: [
{
translate: "fnfboyfriendbot.command.weather.location",
fallback: translations["fnfboyfriendbot.command.weather.location"],
color: config.colors.commands.primary,
with: [
{ text: `${info.location.name}`, color: config.colors.commands.secondary },
{
text: `${info.location.region}`,
color: config.colors.commands.secondary,
},
{
text: `${info.location.country}`,
color: config.colors.commands.secondary,
},
]
},
{
translate: "fnfboyfriendbot.command.weather.coords",
fallback: translations["fnfboyfriendbot.command.weather.coords"],
color: config.colors.commands.primary,
with: [
{ text: `${info.location.lat}`, color: config.colors.integer },
{ text: `${info.location.lon}`, color: config.colors.integer }
]
},
{
translate: "fnfboyfriendbot.command.weather.time",
fallback: translations["fnfboyfriendbot.command.weather.time"],
color: config.colors.commands.primary,
with: [
{
text: `${new Date().toLocaleTimeString("en-US", { timeZone: info.location.tz_id })}`,
color: config.colors.commands.secondary,
},
{
text: `${info.location.tz_id}`,
color: config.colors.commands.secondary,
},
]
},
{
translate: "fnfboyfriendbot.command.weather.temp",
fallback: translations["fnfboyfriendbot.command.weather.temp"],
color: config.colors.commands.primary,
with: [
{
text: `${Math.floor(info.current.temp_c)}`,
color: config.colors.integer,
},
{
text: `${Math.floor(info.current.temp_f)}`,
color: config.colors.integer,
},
]
},
{
translate: "fnfboyfriendbot.command.weather.wind_speed",
fallback: translations["fnfboyfriendbot.command.weather.wind_speed"],
color: config.colors.commands.primary,
with: [
{
text: `${Math.floor(info.current.wind_kph)}`,
color: config.colors.integer,
},
{ text: "kph", color: config.colors.commands.secondary },
{
text: `${info.current.wind_dir}`,
color: config.colors.commands.secondary,
},
{
text: `${Math.floor(info.current.wind_mph)}`,
color: config.colors.integer,
},
{ text: "mph", color: config.colors.commands.secondary },
{
text: `${info.current.wind_dir}`,
color: config.colors.commands.secondary,
},
]
},
{
translate: "fnfboyfriendbot.command.weather.condition",
fallback: translations["fnfboyfriendbot.command.weather.condition"],
color: config.colors.commands.primary,
with: [
{
text: `${info.current.condition.text}`,
color: config.colors.commands.secondary,
},
]
},
{
translate: "fnfboyfriendbot.command.weather.humidity",
fallback: translations["fnfboyfriendbot.command.weather.humidity"],
color: config.colors.commands.primary,
with: [
{
text: `${Math.floor(info.current.humidity)}`,
color: config.colors.integer,
},
]
}
]
})
source.sendFeedback(component)
} catch (e) {
if (e.toString() === "TypeError: Cannot read properties of undefined (reading 'name')") return
else source.sendFeedback(e.toString())
}
}
}
module.exports = weather;
-46
View File
@@ -1,46 +0,0 @@
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
const wikipedia = require('wikipedia');
class wiki extends CommandContext {
constructor() {
super(
"wiki",
[
"wikipedia"
],
"look up articles on wikipedia",
trustLevel.public,
["<article>"],
true,
);
}
async execute(context) {
const source = context.source;
const args = context.arguments;
const bot = context.bot;
const config = context.config;
const translations = bot.translations;
let component = [];
try {
const page = await wikipedia.page(args.join(' '));
const summary = await page.intro();
component.push({ text: summary, color: config.colors.commands.primary })
source.sendFeedback(component)
} catch (e) {
if (e.toString().startsWith('pageError: pageError: No page with given title exists :')) {
source.sendFeedback({
translate: "fnfboyfriendbot.command.wiki.article_not_found",
fallback: translations["fnfboyfriendbot.command.wiki.article_not_found"],
color: "red"
})
} else {
source.sendFeedback(e.stack)
}
}
}
}
module.exports = wiki;
-107
View File
@@ -1,107 +0,0 @@
const CommandError = require("../../commandUtil/CommandError");
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class cloop extends CommandContext {
constructor() {
super(
"cloop",
[
"commandloop",
"loop"
],
"loops commands",
trustLevel.trusted,
[
"add <interval> <command>",
"remove <index>",
"list",
"clear"
],
false
);
}
execute(context) {
const bot = context.bot;
const config = context.config;
const source = context.source;
const args = context.arguments;
let component = [];
if (
!args &&
!args[0] &&
!args[1] &&
!args[2] &&
!args[3] &&
!args[4] &&
!args[5]
)
return;
switch (args[0]) {
case "add":
if (isNaN(args[1])) throw new CommandError("invalid interval");
const interval = parseInt(args[1]);
const command = args.slice(2).join(" ");
bot.cloop.add(command, interval);
component.push(
`added ${command} to the cloops with the interval ${interval}`,
);
break;
case "clear":
bot.cloop.clear();
component.push("cleared the cloops");
break;
case "remove":
if (isNaN(args[1]))
throw new CommandError("argument must be an integer!");
const index = parseInt(args[1]);
bot.cloop.remove(index);
component.push(`removed ${index} from cloops`);
break;
case "list":
let listComponent = [];
let i = 0;
for (const cloop of bot.cloop.list) {
listComponent.push({
translate: "%s \u203a %s (%s)",
color: config.colors.commands.primary,
with: [
{ text: `${i}`, color: config.colors.integer },
cloop.command,
{ text: `${cloop.interval}`, color: config.colors.integer },
],
});
listComponent.push("\n");
i++;
}
listComponent.pop();
component.push({
translate: "Cloops (%s):",
color: config.colors.commands.primary,
with: [
{ text: `${bot.cloop.list.length}`, color: config.colors.integer },
],
});
component.push("\n");
if (bot.cloop.list.length > 0) {
component.push(listComponent);
}
break;
default:
throw new CommandError("invalid argument");
}
source.sendFeedback(component);
}
}
module.exports = cloop;
-25
View File
@@ -1,25 +0,0 @@
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class reconnect extends CommandContext {
constructor() {
super(
"reconnect",
["end"],
"reconnect the bot",
trustLevel.trusted,
[""],
false
);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const source = context.source;
const config = context.config;
bot._client.end();
}
}
module.exports = reconnect;
-43
View File
@@ -1,43 +0,0 @@
const CommandContext = require("../../commandUtil/CommandContext");
const trustLevel = require("../../commandUtil/CommandTrustLevel");
class validate extends CommandContext {
constructor() {
super(
"validate",
["val"],
"validate through the bot",
trustLevel.trusted,
[""],
false,
);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const source = context.source;
const config = context.config;
let component = []
if (source.player.trustLevel === 1)
component.push({
text: "Valid Trusted Hash",
color: config.colors.help.trusted
})
else if (source.player.trustLevel === 2)
component.push({
text: "Valid Admin Hash",
color: config.colors.help.admin
})
else if (source.player.trustLevel === 3)
component.push({
text: "Valid Owner Hash",
color: config.colors.help.owner
})
source.sendFeedback(component)
}
}
module.exports = validate;
-135
View File
@@ -1,135 +0,0 @@
module.exports = {
prefixes: ["!"],
discord: {
token: "discord token here",
prefix: "!",
invite: "discord invite here",
enabled: true,
serverID: 'server id here',
presence: {
name: "amogus",
status: "dnd",
},
roles: {
trusted: "trusted",
admin: "admin",
fullAccess: "full access",
owner: "FNFBoyfriendBot Owner",
},
},
core: {
name: { text: "FNFBoyfriendBot Core", color: "#00FFFF" },
itemName: { text: "FNFBoyfriendBot core item", color: "#00FFFF" },
refillInterval: 300000,
// refilling core via item is buggy rn i recommend setting itemRefill to false for now
area: {
start: {
x: 0,
y: 0,
z: 0,
},
end: {
x: 15,
y: 0,
z: 15,
},
},
},
weatherApiKey: "weather api token here",
ratelimit: {
console: 20,
commands: 3
},
debug: {
commandSetMessage: false,
},
keys: {
trusted: "trusted key here",
admin: "admin key here",
owner: "owner key here",
},
colors: {
integer: "gold",
discord: {
embed: "#000000",
error: "#FF0000",
},
commands: {
primary: "blue",
secondary: "aqua",
tertiary: "gray",
},
help: {
public: "blue",
trusted: "dark_aqua",
admin: "aqua",
owner: "light_purple",
console: "dark_purple",
},
},
console: {
prefix: "c.",
},
logsFolder: {
path: "../../../",
// this is being loaded from the modules so make sure it starts with ../../
name: "fnfboyfriendbot-logs",
},
skibot: {
password: "<password>",
player: "<username>",
channel: "fnfboyfriendbot",
enabled: false
},
bots: [
// usernameGen is for a random username
// if private is set to true then the server ip for the server will be hidden
// channelId is for discord logging
// logging is for console logging
// reconnectDelay is for the delay for reconnecting to a server
/*
logging options
console true or false
file true or false
*/
// modes:
// kaboom: for the server kaboom.pw
// savageFriends: for the server savage Friends
// creayun for the server creayun
// version: 1.21.8
// port: a number lmao
// itemRefill: for refilling the core via chat or a command block
{
host: "localhost",
username: "FNFBoyfriendBot",
usernameGen: true,
version: "1.20.2",
serverName: "localhost",
private: false,
reconnectDelay: 6000,
channelId: "discord channel ip here",
logging: {
file: false,
console: true
},
mode: "kaboom",
selfcareInterval: 300,
itemRefill: true,
},
],
};
-7
View File
@@ -1,7 +0,0 @@
{
"buildstring": {
"build": "3355",
"codename": "§4Reignite",
"version": "v8.0.0"
}
}
File diff suppressed because it is too large Load Diff
-127
View File
@@ -1,127 +0,0 @@
{
"fnfboyfriendbot.arguments": "Expected %s Arguments, recieved %s",
"fnfboyfriendbot.arguments.invalid_integer": "Expected %s to be an Integer",
"fnfboyfriendbot.arguments.max_exceeded": "Expected %s Arguments not %s",
"fnfboyfriendbot.arguments.no_args": "Expected no Arguments",
"fnfboyfriendbot.arguments.not_enough_args": "Expected more than 0 Arguments",
"fnfboyfriendbot.command.arguments.unknown": "Invalid Argument",
"fnfboyfriendbot.command.auth.as": "Authed as %s",
"fnfboyfriendbot.command.auth.exists": "You are already authed with the trust level: %s",
"fnfboyfriendbot.command.cloop.list.text": "Cloops (%s):",
"fnfboyfriendbot.command.cloop.remove": "Removed %s from the cloops",
"fnfboyfriendbot.command.cloop.clear": "Cleared the cloops",
"fnfboyfriendbot.command.cloop.not_an_integer": "Interval must be an Integer!",
"fnfboyfriendbot.command.cloop.add": "Added %s to the cloops with the interval %s",
"fnfboyfriendbot.command.core.refill": "Refilling core",
"fnfboyfriendbot.command.extras.send": "Sent %s to Channel %s",
"fnfboyfriendbot.command.extras.register": "Registered %s Channel",
"fnfboyfriendbot.command.extras.unregister": "Unregistered from %s Channel",
"fnfboyfriendbot.command.extras.unregisterAll": "Unregistered from all channels",
"fnfboyfriendbot.command.help.category": "(%s | %s | %s | %s)",
"fnfboyfriendbot.command.help.command_layout": "Commands%s %s%s%s",
"fnfboyfriendbot.command.help.info.alias": "Aliases%s %s",
"fnfboyfriendbot.command.help.info.command": "Command%s %s",
"fnfboyfriendbot.command.help.info.description": "Descripton%s %s",
"fnfboyfriendbot.command.help.info.trust_level": "Trust Level%s %s",
"fnfboyfriendbot.command.help.info.usages": "Usages%s\n%s",
"fnfboyfriendbot.command.help.trust_level.public": "Public",
"fnfboyfriendbot.command.help.trust_level.trusted": "Trusted",
"fnfboyfriendbot.command.help.trust_level.admin": "Admin",
"fnfboyfriendbot.command.help.trust_level.owner": "Owner",
"fnfboyfriendbot.command.info.about": "FNFBoyfriendBot is a kaboom bot created by Parker2991",
"fnfboyfriendbot.command.info.config.discord.channel": "Discord Channel%s %s",
"fnfboyfriendbot.command.info.config.discord.username": "Discord Username%s %s",
"fnfboyfriendbot.command.info.config.minecraft.username": "Minecraft Username%s %s",
"fnfboyfriendbot.command.info.config.minecraft.version": "Minecraft Version%s %s",
"fnfboyfriendbot.command.info.config.mode": "Mode%s %s",
"fnfboyfriendbot.command.info.config.prefixes": "Prefixes%s %s",
"fnfboyfriendbot.command.info.config.server.ip": "Server%s %s%s%s",
"fnfboyfriendbot.command.info.config.server.name": "Server Name%s %s",
"fnfboyfriendbot.command.info.config.server.count": "Server Count%s %s",
"fnfboyfriendbot.command.info.discord": "the discord server invite is %s",
"fnfboyfriendbot.command.info.loaded.commands": "%s Commands",
"fnfboyfriendbot.command.info.loaded.modules": "%s Modules",
"fnfboyfriendbot.command.info.server.arch": "Arch%s %s",
"fnfboyfriendbot.command.info.server.cpu": "CPU%s %s",
"fnfboyfriendbot.command.info.server.cpu.cores": "CPU Cores%s %s",
"fnfboyfriendbot.command.info.server.directory": "Directory%s %s",
"fnfboyfriendbot.command.info.server.hostname": "Hostname%s %s",
"fnfboyfriendbot.command.info.server.kernel_version": "Kernel Version%s %s",
"fnfboyfriendbot.command.info.server.os": "OS%s %s",
"fnfboyfriendbot.command.info.server.os.version": "OS Version%s %s",
"fnfboyfriendbot.command.info.server.processes": "Processes%s %s",
"fnfboyfriendbot.command.info.server.node_version": "Node Version%s %s",
"fnfboyfriendbot.command.info.server.npm_version": "NPM Version%s %s",
"fnfboyfriendbot.command.info.server.user": "Username%s %s",
"fnfboyfriendbot.command.info.uptimes.bot": "Bot Uptime%s %s",
"fnfboyfriendbot.command.info.uptimes.server": "Server Uptime%s %s",
"fnfboyfriendbot.command.info.usages.botmem": "Bot Memory%s %s MB / %s MB",
"fnfboyfriendbot.command.info.usages.servermem": "Server Memory%s %s MB / %s MB",
"fnfboyfriendbot.command.info.version.build": "Build%s %s",
"fnfboyfriendbot.command.info.version.commit": "Commit%s %s",
"fnfboyfriendbot.command.info.version.repo_build": "Repo Build%s %s",
"fnfboyfriendbot.command.info.version.version_release_date": "Version Release Date%s %s",
"fnfboyfriendbot.command.list.latency": "Latency: %s",
"fnfboyfriendbot.command.list.gamemode": "Gamemode: %s",
"fnfboyfriendbot.command.list.text": "Players: (%s)\n",
"fnfboyfriendbot.command.mcserver.ip": "Ip: %s:%s",
"fnfboyfriendbot.command.mcserver.players": "Players: %s/%s",
"fnfboyfriendbot.command.mcserver.server.unknown": "could not ping %s:%s",
"fnfboyfriendbot.command.mcserver.server.version": "Server Version: %s",
"fnfboyfriendbot.command.rps.draw": "You chose %s and the bot chose %s so its a draw",
"fnfboyfriendbot.command.rps.lose": "You lose! You chose %s and the bot chose %s",
"fnfboyfriendbot.command.rps.win": "You win! You chose %s and the bot chose %s",
"fnfboyfriendbot.command.rps.invalid_choice": "%s is not a valid option please pick rock paper or scissors",
"fnfboyfriendbot.command.rtp": "Telporting Player %s to X: %s, Y: %s, Z: %s",
"fnfboyfriendbot.command.urban.definition_not_found": "%s Definition not found!",
"fnfboyfriendbot.command.urban.text": "Urban",
"fnfboyfriendbot.command.validate.owner": "Validated as Owner",
"fnfboyfriendbot.command.validate.admin": "Validated as Admin",
"fnfboyfriendbot.command.validate.trusted": "Validated as Trusted",
"fnfboyfriendbot.command.weather.condition": "Condition: %s",
"fnfboyfriendbot.command.weather.coords": "Coords: %s, %s",
"fnfboyfriendbot.command.weather.humidity": "Humidity: %s",
"fnfboyfriendbot.command.weather.location": "Location: %s %s, %s %s",
"fnfboyfriendbot.command.weather.time": "Time: %s (%s)",
"fnfboyfriendbot.command.weather.temp": "Temp: %s (\u00b0C), %s (\u00b0F)",
"fnfboyfriendbot.command.weather.unknown_location": "%s is not a valid location!",
"fnfboyfriendbot.command.weather.wind_speed": "Wind Speed: %s (%s, %s), %s (%s, %s)",
"fnfboyfriendbot.command.wiki.article_not_found": "Wiki Article not found!",
"fnfboyfriendbot.command_manager.validation.invalid_admin_hash": "Invalid Admin Hash",
"fnfboyfriendbot.command_manager.validation.invalid_hash": "Invalid Hash",
"fnfboyfriendbot.command_manager.validation.invalid_owner_hash": "Invalid Owner Hash",
"fnfboyfriendbot.command_manager.validation.invalid_trusted_hash": "Invalid Trusted Hash",
"fnfboyfriendbot.command_manager.validation.invalid_role": "Invalid Role",
"fnfboyfriendbot.command_manager.trust_level.console_only": "This command can only be ran via console!",
"fnfboyfriendbot.https_requesting.status.forbidden": "",
"fnfboyfriendbot.https_requesting.": "",
"fnfboyfriendbot.json.parse_invalid": "invalid json component to parse",
"fnfboyfriendbot.json.stringify.invalid": "invalid json component to stringify",
"fnfboyfriendbot.json.too_long": "Stringified JSON exceeds the max command block character limit",
"fnfboyfriendbot.reconnect.stop_logging": "stopped logging disconnect messages for now"
}
-51
View File
@@ -1,51 +0,0 @@
const createBot = require("./bot.js");
const readline = require("readline");
const fs = require("fs");
const path = require("path");
const loadModules = require("./util/loadModules");
const { Client, GatewayIntentBits, Partials } = require("discord.js");
const { MessageContent, GuildMessages, Guilds, DirectMessages } =
GatewayIntentBits;
const discordClient = new Client({
intents: [
Guilds,
GuildMessages,
MessageContent,
GatewayIntentBits.DirectMessages,
],
partials: [Partials.Channel],
});
console.log("Starting FNFBoyfriendBot");
if (!fs.existsSync(path.join(__dirname, "../config.js"))) {
console.warn("Config not found creating config from the default config");
fs.copyFileSync(
path.join(__dirname, "./data/default_config.js"),
path.join(__dirname, "../config.js"),
);
}
const config = require("../config.js");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
if (config.discord.enabled) discordClient.login(config.discord.token);
const bots = [];
let options;
let bot;
for (const botOptions of config.bots) {
options = botOptions;
bot = new createBot(options, config);
bot.translations = require('./data/translations.json')
bots.push(bot);
bot.bots = bots;
loadModules(bot, options, config, discordClient);
bot.console.readlineInterface(rl);
}
-198
View File
@@ -1,198 +0,0 @@
const loadPrismarineChat = require("prismarine-chat");
const convertNbtComponentToJson = require("../util/convertNbtComponentToJson");
const kaboom = require("../chatParsers/kaboom");
const creayun = require("../chatParsers/creayun");
const chipmunkmod = require("../chatParsers/chipmunkmod");
const vanilla = require('../chatParsers/vanilla/vanilla');
const me = require('../chatParsers/vanilla/me')
function parseNbt (chatTypes, type, sender, target, message) {
const chatType = chatTypes[type]
const parsed = convertNbtComponentToJson(null, chatType.value.value.chat)
let json = { translate: parsed.translation_key, with: [] }
for (const parameter of parsed.parameters) {
switch (parameter) {
case "sender": json.with.push(sender)
break;
case "target": json.with.push(target)
case "content": json.with.push(message)
break;
}
}
if (type === 4) json = message
return json
}
class chat {
constructor(context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
let ChatMessage;
let chatTypes;
bot.on("registry_ready", (registry) => {
ChatMessage = loadPrismarineChat(registry);
});
bot.on('packet.registry_data', (packet) => {
if (packet.id !== 'minecraft:chat_type') return // taken from the 1.21.1 build of my bot that chayapak made
chatTypes = packet.entries
})
if (options.mode === "savageFriends") {
bot.chatParsers = [creayun];
} else {
bot.chatParsers = [
kaboom,
creayun,
chipmunkmod,
vanilla,
me
/* KaboomChatParser,
ChipmunkModChatParser,
VanilaChatParser,*/
];
}
bot.on("packet.profileless_chat", (packet) => {
const sender = convertNbtComponentToJson(null, packet.name);
const message = convertNbtComponentToJson(null, packet.message);
const target = convertNbtComponentToJson(null, packet.target)
const type = packet.type.chatType;
const parsed = parseNbt(chatTypes, type, sender, target, message)
bot.emit('message', {
type: "minecraft:disguised_chat",
message: parsed
})
parseMessage(parsed, { senderName: sender, players: bot.players, getMessageAsPrismarine: bot.getMessageAsPrismarine, chatType: "minecraft:diguised_chat" })
});
bot.on("packet.player_chat", (packet) => {
const unsigned = convertNbtComponentToJson(null, packet.unsignedChatContent);
const networkName = convertNbtComponentToJson(null, packet.networkName)
bot.emit('message', {
type: "minecraft:player_chat",
message: unsigned
})
parseMessage(unsigned, {
senderUuid: packet.senderUuid,
players: bot.players,
getMessageAsPrismarine: bot.getMessageAsPrismarine,
chatType: "minecraft:player_chat"
});
});
bot.on("packet.system_chat", (packet) => {
const message = convertNbtComponentToJson(null, packet.content);
if (
message.translate === "advMode.setCommand.success"
||
message.translate === "multiplayer.message_not_delivered"
||
packet.isActionBar
||
message.translate === "advMode.notAllowed"
)
return;
bot.emit("message", {
type: "minecraft:system_chat",
message: message
});
bot.emit("system_chat", message);
parseMessage(message, {
players: bot.players,
getMessageAsPrismarine: bot.getMessageAsPrismarine,
chatType: "minecraft:system_chat",
});
});
function parseMessage(message, data) {
try {
let parsed;
for (const parser of bot.chatParsers) {
parsed = parser(message, data);
if (parsed) break;
}
if (!parsed) return;
bot.emit("parsed_message", parsed);
} catch (e) {
console.log(e.stack);
}
}
bot.getMessageAsPrismarine = (message) => {
try {
if (ChatMessage !== undefined) {
return new ChatMessage(message);
}
} catch {}
return undefined;
};
bot.chat = {
message(message) {
const acc = 0;
const bitset = Buffer.allocUnsafe(3);
bitset[0] = acc & 0xff;
bitset[1] = (acc >> 8) & 0xff;
bitset[2] = (acc >> 16) & 0xff;
bot._client.write("chat_message", {
message: message?.substring(0, 256)?.replaceAll("§", "&"),
timestamp: BigInt(Date.now()),
salt: 0n,
offset: 0,
acknowledged: bitset,
});
},
command(command) {
bot._client.write("chat_command", {
command: command?.substring(0, 256)?.replaceAll("§", "&"),
timestamp: BigInt(Date.now()),
salt: 0n,
argumentSignatures: [],
signedPreview: false,
messageCount: 0,
acknowledged: Buffer.alloc(3),
previousMessages: [],
});
},
send(message) {
if (message.startsWith("/")) {
bot.chat.command(message.substring(1));
return;
}
bot.chat.message(message);
},
};
bot.tellraw = (selector, message) => {
const command = "minecraft:tellraw";
const commandLength = 32767 - selector.length;
const messageLength = JSON.stringify(message).length
const finalLength = commandLength - messageLength
// here we check to see if the output surpasses the max command block character limit which is 32767
if (messageLength > finalLength)
bot.core.run(`${command} ${selector} ` + JSON.stringify({
translate: "fnfboyfriendbot.json.too_long",
fallback: bot.translations["fnfboyfriendbot.json.too_long"],
color: "red"
}))
else bot.core.run(`${command} ${selector} ` + JSON.stringify(message));
};
}
}
module.exports = chat;
-245
View File
@@ -1,245 +0,0 @@
const sleep = require("../util/sleep");
const convertNbtComponentToJson = require("../util/convertNbtComponentToJson");
class commandCore {
constructor(context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
const Item = require("prismarine-item")(bot.options.version);
let command;
bot.core = {
area: {
start: config.core?.area.start ?? { x: 0, y: 0, z: 0 },
end: config.core?.area.end ?? { x: 15, y: 0, z: 15 },
},
position: null,
itemPosition: null,
currentBlockRelative: { x: 0, y: 0, z: 0 },
usePlacedCommandBlock: false,
chatRefill() {
const pos = bot.core.position;
const { start, end } = bot.core.area;
const itemPosition = bot.core.itemPosition;
if (!pos || !itemPosition) return;
if (bot.options.mode === "savageFriends") {
command = `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} command_block`;
} else {
command = `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} command_block{CustomName:${JSON.stringify(config.core.name)}}`;
}
bot.chat.command(command);
},
itemRefill() {
const pos = bot.core.position;
const { start, end } = bot.core.area;
const itemPosition = bot.core.itemPosition;
command = `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} command_block{CustomName:${JSON.stringify(config.core.name)}}`;
if (bot.options.mode !== "savageFriends") {
bot._client.write("set_creative_slot", {
slot: 36,
item: Item.toNotch(
new Item(
bot.registry.itemsByName.repeating_command_block.id,
1,
0,
),
),
});
bot._client.write("block_dig", {
status: 0,
location: itemPosition,
face: 0,
});
bot._client.write("block_place", {
hand: 0,
location: itemPosition,
direction: 0,
cursorX: 0,
cursorY: 0,
cursorZ: 0,
insideBlock: false,
});
if (bot.core.usePlacedCommandBlock) {
return;
} else {
bot.core.commandBlock(command, itemPosition, 1, 5);
}
}
},
move(pos = bot.position) {
bot.core.position = {
x: Math.floor(pos.x / 16) * 16,
y: 0,
z: Math.floor(pos.z / 16) * 16,
};
bot.core.itemPosition = {
x: Math.floor(pos.x),
y: Math.floor(pos.y - 1),
z: Math.floor(pos.z),
};
bot.core.commandBlocks = [];
if (bot.options.itemRefill && bot.options.mode !== "savageFriends") {
bot.core.itemRefill();
} else {
bot.core.chatRefill();
}
},
currentBlock() {
const relativePosition = bot.core.currentBlockRelative;
const corePosition = bot.core.position;
if (!corePosition) return null;
return {
x: relativePosition.x + corePosition.x,
y: relativePosition.y + corePosition.y,
z: relativePosition.z + corePosition.z,
};
},
incrementCurrentBlock() {
const relativePosition = bot.core.currentBlockRelative;
const { start, end } = bot.core.area;
relativePosition.x++;
if (relativePosition.x > end.x) {
relativePosition.x = start.x;
relativePosition.z++;
}
if (relativePosition.z > end.z) {
relativePosition.z = start.z;
relativePosition.y++;
}
if (relativePosition.y > end.y) {
relativePosition.x = start.x;
relativePosition.y = start.y;
relativePosition.z = start.z;
}
},
commandBlock(command, location, mode, flags) {
if (!bot.loggedIn) return;
bot._client.write("update_command_block", {
command: command?.substring(0, 32767),
location: location,
mode: mode,
flags: flags,
});
},
run(command) {
const location = bot.core.currentBlock();
const itemPosition = bot.core.itemPosition;
if (!location) return;
if (bot.options.mode === "creayun") {
return;
} else if (bot.options.mode === "savageFriends") {
bot.core.commandBlock(command, location, 2, 0b101);
bot.core.incrementCurrentBlock();
} else {
if (bot.core.usePlacedCommandBlock) {
bot.core.commandBlock(command, itemPosition, 1, 5);
bot.core.incrementCurrentBlock();
} else {
bot.core.commandBlock(command, location, 1, 5);
bot.core.incrementCurrentBlock();
}
}
},
async runTracked(command, source) {
const location = bot.core.currentBlock();
const transactionId = Math.floor(Math.random() * 10000);
bot.core.commandBlock(command, location, 1, 0b101);
bot.core.incrementCurrentBlock();
await sleep(100);
bot._client.write("query_block_nbt", { location, transactionId });
bot.on("packet.nbt_query_response", async (data) => {
try {
if (data.transactionId == transactionId) {
if (data?.nbt?.value?.LastOutput) {
const output = convertNbtComponentToJson(
null,
data.nbt.value.LastOutput.value.extra,
);
source.sendFeedback(output);
}
}
} catch (e) {
console.log(e.stack);
}
});
},
};
let timer;
bot.on("packet.block_change", (data) => {
try {
if (
data?.location?.x === bot?.core?.position?.x &&
data?.location?.y === bot?.core?.position?.y &&
data?.location?.z === bot?.core?.position?.z &&
data.type === 0
) {
bot.core.move(bot.position);
}
} catch (e) {
bot.console.warn(e.toString());
}
});
bot.on("move", async () => {
try {
if (bot.options.mode === "savageFriends") {
await sleep(2000);
bot.chat.command("/removenear commandblock");
await sleep(2000);
bot.core.move(bot.position);
} else {
bot.core.move(bot.position);
}
} catch (e) {
bot.console.warn(e.toString());
}
});
bot.on("packet.login", () => {
timer = setInterval(() => {
bot.core.move(bot.position);
}, config.core.refillInterval);
});
bot.on("end", () => {
if (timer) clearInterval(timer);
});
}
}
module.exports = commandCore;
-52
View File
@@ -1,52 +0,0 @@
const CommandSource = require("../commandUtil/CommandSource");
class commandHandler {
constructor(context) {
let ratelimit = 0;
const bot = context.bot;
const config = context.config;
const options = context.options;
bot.on("parsed_message", (data) => {
try {
if (data.type !== "minecraft:chat" && data.type !== "extras:command_spy") return;
const prefixes = config.prefixes;
prefixes.map((prefix) => {
const plainMessage = bot
.getMessageAsPrismarine(data.contents)
?.toString();
if (!plainMessage?.startsWith(prefix)) return;
const command = plainMessage.substring(prefix.length);
const source = new CommandSource(
data.sender,
{ discord: false, console: false },
data.chatType,
data.trustLevel,
);
source.sendFeedback = (message) => {
if (options.mode === "savageFriends") bot.tellraw(`@a`, [
message
])
else bot.tellraw(`@p[nbt={UUID:[I;${source.player.entityUuid}]}]`, message)
}
ratelimit++;
setTimeout(() => {
ratelimit--;
}, 1000);
if (ratelimit > config.ratelimit.commands) {
return;
} else if (command.split(" ")[0].length === 0) {
} else {
bot.commandManager.executeString(source, command);
}
});
} catch (e) {
bot.console.error(e.toString());
}
});
}
}
module.exports = commandHandler;
-28
View File
@@ -1,28 +0,0 @@
class commandLoop {
constructor(context) {
const bot = context.bot;
bot.cloop = {
list: [],
add(command, interval) {
let timer;
timer = {
timer: setInterval(() => bot.core.run(command), interval),
command,
interval,
};
this.list.push(timer);
},
remove(index) {
clearInterval(this.list[index].timer);
bot.cloop.list.splice(index, 1);
},
clear() {
for (const cloop of this.list) clearInterval(cloop.timer);
this.list = [];
},
};
}
}
module.exports = commandLoop;
-161
View File
@@ -1,161 +0,0 @@
const fs = require("fs");
const path = require("path");
const CommandError = require("../commandUtil/CommandError");
const CommandSource = require("../commandUtil/CommandSource");
const CommandArguments = require('../commandUtil/CommandArguments')
const fixansi = require("../util/ansi");
const sleep = require("../util/sleep.js");
class commandManager {
constructor(context) {
const bot = context.bot;
const config = context.config;
const discordClient = context.discordClient;
const options = context.options;
const translations = bot.translations;
bot.commandManager = {
commands: {},
commandlist: [],
execute(source, commandName, args) {
const command = this.getCommand(commandName.toLowerCase());
try {
if (!command) {
throw new CommandError({
translate: "%s%s%s %s",
color: "red",
with: [
{ translate: "command.unknown.command", color: "red" },
{ text: "\n" },
{ text: `${commandName}`, color: "gray" },
{ translate: "command.context.here", color: "red" }
]
})
}
if (command?.data?.trustLevel !== 0 && command?.data.trustLevel < 4) {
if (!source.sources.console && !source.sources.discord) {
if (args[0] === bot.validation.trusted)
source.player.trustLevel = 1
else if (args[0] === bot.validation.admin)
source.player.trustLevel = 2
else if (args[0] === bot.validation.owner)
source.player.trustLevel = 3
args = args.slice(1)
if (source.player.trustLevel < command?.data?.trustLevel && !source.sources.console) {
throw new CommandError({
translate: "fnfboyfriendbot.command_manager.validation.invalid_hash",
fallback: translations["fnfboyfriendbot.command_manager.validation.invalid_hash"],
color: "red"
})
}
} if (source.sources.discord) {
const event = bot.discord.message;
const roles = event?.member?.roles?.cache;
const hashRole = roles?.some((role) => {
if (role.name === `${config.discord.roles.trusted}`) source.player.trustLevel = 1;
else if (role.name === `${config.discord.roles.admin}`) source.player.trustLevel = 2;
else if (role.name === `${config.discord.roles.owner}`) source.player.trustLevel = 3;
})
if (source.player.trustLevel < command?.data?.trustLevel)
throw new CommandError({
translate: "fnfboyfriendbot.command_manager.validation.invalid_role",
fallback: translations["fnfboyfriendbot.command_manager.validation.invalid_role"],
color: "red"
})
}
} if (command?.data?.trustLevel === 4 && !source.sources.console)
throw new CommandError({
translate: "fnfboyfriendbot.command_manager.trust_level.console_only",
fallback: translations["fnfboyfriendbot.command_manager.trust_level.console_only"],
color: "red"
})
if (
command?.data.playerChatOnly
&&
source.ChatType !== "minecraft:player_chat"
&&
!source.sources.console
&&
!source.sources.discord
&&
bot.options.mode === 'kaboom'
) return
return command?.execute({
bot,
source,
arguments: args,
config,
discordClient,
});
} catch (error) {
if (error instanceof CommandError) {
source.sendFeedback(error._message);
} else {
bot.console.error(error.stack)
source.sendFeedback(
{
translate: "command.failed",
color: "red",
hoverEvent: {
action: "show_text",
contents: String(error.stack),
},
}
)
}
}
},
executeString(source, command) {
const [commandName, ...args] = command.split(" ");
return this.execute(source, commandName, args);
},
register(command) {
this.commands[command.data.name] = command;
if (command.data.aliases) {
command.data.aliases.map((a) => (this.commands[a] = command));
}
},
getCommand(name) {
return this.commands[name];
},
getCommands() {
return Object.values(this.commands);
},
};
/*
command loader ported from my discord bot SkiBot
*/
let commandlist = [];
const foldersPath = path.join(__dirname, "../commands");
const commandFolders = fs.readdirSync(foldersPath);
for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath);
for (const filename of commandFiles) {
try {
const filePath = path.join(commandsPath, filename);
if (filename.endsWith(".js")) {
const command = require(filePath);
const commands = new command();
bot.commandManager.register(commands);
bot.commandManager.commandlist.push(commands);
}
} catch (error) {
console.error("Failed to load command", filename, ":", error);
}
}
}
}
}
module.exports = commandManager;
-38
View File
@@ -1,38 +0,0 @@
class commandSpy {
constructor(context) {
const bot = context.bot;
bot.on("system_chat", (message) => {
try {
const child = message.extra;
const sender =
bot.players.find((e) => e?.profile?.name === message.text)?.profile
?.name === message.text;
if (!child || !message.text || !message.color || !sender) return;
const command = child[1].substring("/".length);
if (
(message.color === "yellow" &&
child[0] === ": " &&
child[1] === `/${command}` &&
sender) ||
(message.color === "aqua" &&
child[0] === ": " &&
child[1] === `/${command}` &&
sender)
) bot.emit("parsed_message", {
sender: bot.players.find((e) => e.profile.name === message.text),
contents: { text: command },
type: "extras:command_spy",
displayName: bot.players.find(
(e) => e.profile.name === message.text,
).displayName,
});
} catch (e) {
// console.log(e.stack);
}
});
}
}
module.exports = commandSpy;
-151
View File
@@ -1,151 +0,0 @@
const CommandSource = require("../commandUtil/CommandSource");
const prismarineChat = require("prismarine-chat")("1.21.8");
class Console {
// named it Console so that it doesnt override the console variable
constructor(context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
let ratelimit = 0;
let serverName;
if (options.private) {
serverName = `${options.serverName}`;
} else {
serverName = `§1${bot.options.host}:§9${bot.options.port}`;
}
bot.console = {
readline: null,
server: "all",
readlineInterface(rl) {
this.readline = rl;
rl.on("line", (args) => {
if (bot.options.serverName !== this.server && this.server !== "all")
return;
if (args.startsWith(config.console.prefix)) {
return bot.commandManager.executeString(
bot.console.source,
args.substring(config.console.prefix.length),
);
} else if (args.startsWith("")) {
bot.chat.send(args);
}
rl.on("close", () => {
this.readline = null;
});
});
},
source: new CommandSource(
{
profile: {
name: bot._client.username,
},
uuid: bot._client.uuid,
},
{ console: true, discord: false },
"minecraft:chat",
{
trustLevel: 4,
}
),
refreshLine(...args) {
this?.readline.output.write("\x1b[2K\r");
console.log.apply(console, arguments);
this.readline._refreshLine();
},
log(message) {
this.refreshLine(
bot
.getMessageAsPrismarine(
`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO" })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })} §6logs§8] §8[${serverName}§8] `,
)
?.toAnsi() + message,
);
},
warn(error) {
this.refreshLine(
prismarineChat
.fromNotch(
`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO" })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })} §ewarn§8] §8[${serverName}§8] `,
)
?.toAnsi() + error,
);
},
error(error) {
this.refreshLine(
bot
.getMessageAsPrismarine(
`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO" })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })} §4error§8] §8[${serverName}§8] `,
)
?.toAnsi() + error,
);
},
info(message) {
this.refreshLine(
prismarineChat
.fromNotch(
`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO" })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })} §2info§8] §8[${serverName}§8] `,
)
?.toAnsi() + message,
);
},
command(message) {
this.refreshLine(
prismarineChat
.fromNotch(
`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO" })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })} §6command§8] §8[${serverName}§8] `,
)
?.toAnsi() +
bot.getMessageAsPrismarine(message)?.toAnsi(bot.registry.language),
);
},
};
bot.console.source.sendFeedback = (message) => {
bot.console.command(message);
};
setInterval(() => (ratelimit = 0), 1000 * 2);
bot.on("message", (message) => {
if (message.type === "minecraft:player_chat")
message = [
{
text: "[P] ",
},
message.message,
];
else if (message.type === "minecraft:disguised_chat") message = [
{
text: "[V] "
},
message.message
]
else if (message.type === "minecraft:system_chat") message = [
{
text: "[S] "
},
message.message
]
if (options.logging.console) {
if (ratelimit > config.ratelimit.console) return;
bot.console.log(bot.getMessageAsPrismarine(message)?.toAnsi());
}
if (options.logging.file && bot.loggedIn) {
bot.console.fileLogger(
`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO" })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })} logs] [${serverName}] ${bot.getMessageAsPrismarine(message)?.toString()}`,
);
}
ratelimit++;
});
}
}
module.exports = Console;
-192
View File
@@ -1,192 +0,0 @@
const fixansi = require("../util/ansi");
const CommandSource = require("../commandUtil/CommandSource");
class discord {
constructor(context) {
const bot = context.bot;
const config = context.config;
const discordClient = context.discordClient;
const options = context.options;
if (options.channelId.length == 0) {
bot.discord = {
invite: config.discord?.invite,
client: discordClient,
prefix: config.discord.prefix,
};
return;
}
bot.discord = {
client: discordClient,
channel: undefined,
invite: config.discord.invite || undefined,
prefix: config.discord.prefix,
};
discordClient.once("clientReady", (context) => {
bot.discord.channel = discordClient.channels.cache.get(options.channelId);
discordClient.user.setPresence({
activities: [
{
name: `${config.discord.presence.name}`,
type: 0,
},
],
status: `${config.discord.presence.status}`,
});
});
let discordQueue = [];
setInterval(() => {
if (discordQueue.length === 0) return;
try {
bot?.discord?.channel?.send(
`\`\`\`ansi\n${discordQueue.join("\n").substring(0, 1984)}\n\`\`\``,
);
} catch (error) {}
discordQueue = [];
}, 2000);
function sendDiscordMessage(message) {
discordQueue.push(message);
}
function sendComponent(message) {
const ansi = bot
.getMessageAsPrismarine(message)
?.toAnsi(bot?.registry?.language)
.replaceAll("```\u001b[9```" + "```\u001b[3```")
.replaceAll("https://discord", "https:\rdiscord");
try {
sendDiscordMessage(fixansi(ansi?.replaceAll("`", "`\u200b")));
} catch (e) {
bot.console.warn(`Error sending a message to Discord: ${e.message}`);
sendDiscordMessage(e.message);
}
}
bot.on("message", (message) => {
sendComponent(message.message);
});
function messageCreate(message, source) {
bot.discord.message = message;
if (message.author.id === bot.discord.client.user.id) return;
if (message.channel.id !== bot.discord.channel.id) return;
if (message.content.startsWith(config.discord.prefix)) {
const source = new CommandSource(
{
profile: {
name: `${message?.member.nickname || message?.author.displayName}`,
},
},
{
discord: true,
console: false,
},
false,
message,
);
source.sendFeedback = input => {
message?.reply(`\`\`\`ansi\n${fixansi(bot.getMessageAsPrismarine(input)?.toAnsi()?.replaceAll('`', '`\u200b').substring(0, 1780))}\`\`\``);
}
bot.commandManager.executeString(
source,
message.content.substring(config.discord.prefix.length),
);
return;
}
const tag = {
translate: "[%s] %s \u203a ",
with: [
{
translate: "%s%s%s %s",
bold: false,
with: [
{
text: "FNF",
bold: false,
color: "blue",
},
{
text: "Boyfriend",
bold: false,
color: "dark_aqua",
},
{
text: "Bot",
bold: false,
color: "dark_blue",
},
{
text: "Discord",
bold: false,
color: "blue",
},
],
click_event: bot.discord.invite
? {
action: "open_url",
url: bot.discord.invite,
}
: undefined,
hover_event: {
action: "show_text",
value: [ "Click to join the discord" ],
},
},
{
text: `${message.member.nickname || message.author.displayName}`,
},
],
};
try {
if (message.attachments.size > 0) {
message.attachments.forEach((Attachment) => {
let attachment = {
text: `[Attachment: ${Attachment.name}] ${message?.content}`,
color: "blue",
hover_event: {
action: "show_text",
contents: "click here to view attachment",
},
click_event: {
action: "open_url",
url: `${Attachment?.url}`,
},
};
bot.tellraw("@a", [tag, attachment]);
});
} else if (message?.reference?.type === 0) {
// this is for messages that are replied to
const repliedMessage = message.channel.messages.cache.get(
message.reference.messageId,
);
let reply = [
tag,
{
text: `[Replying to: ${repliedMessage.author.username}] `,
color: "blue",
},
message.content,
];
bot.tellraw("@a", [reply]);
} else if (message?.reference?.type === 1) {
// this is for messages that are forwarded
} else {
bot.tellraw("@a", [tag, message.content]);
}
} catch (e) {
console.log(e.stack);
}
}
discordClient.on("messageCreate", messageCreate);
}
}
module.exports = discord;
-63
View File
@@ -1,63 +0,0 @@
const channels = "extras:register\0extras:unregister\0extras:message\0";
class extrasMessages {
constructor (context) {
const bot = context.bot
const config = context.config
const options = context.options
bot.on('packet.login', () => {
bot._client.write("custom_payload", {
channel: "minecraft:register",
data: Buffer.from(channels, "utf8")
})
});
// I wanna use the extras channels to my advantage --- Parker2991
bot.extras = {
channels: [],
register (channel) {
const buf = Buffer.from(channel, "utf8")
buf[buf.length - 1] |= 0x80;
bot._client.write("custom_payload", {
channel: "extras:register",
data: buf,
})
bot.extras.channels.push(channel)
},
unregister (channel) {
const buf = Buffer.from(channel, "utf8")
buf[buf.length - 1] |= 0x80;
bot._client.write("custom_payload", {
channel: "extras:unregister",
data: buf,
})
bot.extras.channels.pop(channel)
},
unregisterall () {
for (const channel of this.channels) {
this.unregister(channel)
}
},
send (channel, message) {
const buf = Buffer.from(channel, "utf8")
buf[buf.length - 1] |= 0x80;
bot._client.write("custom_payload", {
channel: "extras:message",
data: Buffer.concat([buf, Buffer.from(`${message}`, "utf8")])
})
}
}
bot.on('end', () => bot.extras.channels = [])
bot.on('packet.custom_payload', (data) => {
if (data.channel === "extras:message") {
console.log(data.data.toString('ascii'))
}
})
}
}
module.exports = extrasMessages;
-74
View File
@@ -1,74 +0,0 @@
const fs = require("fs");
const path = require("path");
const { createGzip } = require("zlib");
const readline = require("readline");
const { Console } = require("console");
class fileLogger {
constructor(context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
const currentDate = new Date();
if (!options.logging.file) return;
const timestamp = `${currentDate.getFullYear()}-${(
currentDate.getMonth() + 1
)
.toString()
.padStart(2, "0")}-${currentDate.getDate().toString().padStart(2, "0")}`;
const logFolder = path.join(
__dirname,
`${config.logsFolder.path}`,
`${config.logsFolder.name}`,
);
const logFileName = "latest.log";
const logFilePath = path.join(logFolder, logFileName);
const logStream = fs.createWriteStream(logFilePath, { flags: "a" });
try {
if (!fs.existsSync(logFolder)) {
console.info(
`logs folder not found recreating it at ${config.logsFolder.path}${config.logsFolder.name}`,
);
fs.mkdirSync(logFolder);
}
} catch (e) {
console.error(`Unable to create log folder: ${e}`);
}
function compressFile(input, output) {
const plainOutput = output.slice(0, -3);
fs.renameSync(input, plainOutput);
const gzip = createGzip();
fs.createReadStream(plainOutput)
.pipe(gzip)
.pipe(fs.createWriteStream(output + ".tmp"))
.once("finish", () => {
fs.unlinkSync(plainOutput);
fs.renameSync(output + ".tmp", output);
});
}
if (fs.existsSync(logFilePath)) {
const plainName = fs
.statSync(logFilePath)
.ctime.toISOString()
.split("T")[0];
let name = plainName;
let counter = 1;
let newFileName = path.join(logFolder, `${name}.log.gz`);
while (fs.existsSync(newFileName)) {
name = `${plainName}-${counter}`;
newFileName = path.join(logFolder, `${name}.log.gz`);
counter++;
}
compressFile(logFilePath, newFileName);
}
bot.console.fileLogger = function logging(message) {
logStream.write(message + "\n");
};
}
}
module.exports = fileLogger;
-104
View File
@@ -1,104 +0,0 @@
const convertNbtComponentToJson = require("../util/convertNbtComponentToJson");
const entityUUID = require('../util/entityUUID');
class playerList {
constructor(context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
bot.players = [];
bot.on("packet.player_info", (packet) => {
const actions = [];
if (packet.action._value & 0b000001) actions.push(addPlayer);
if (packet.action._value & 0b000010) actions.push(initializeChat);
if (packet.action._value & 0b000100) actions.push(updateGamemode);
if (packet.action._value & 0b001000) actions.push(updateListed);
if (packet.action._value & 0b010000) actions.push(updateLatency);
if (packet.action._value & 0b100000) actions.push(updateDisplayName);
for (const entry of packet.data) {
for (const action of actions) {
action(entry);
}
}
});
bot.on("packet.player_remove", async ({ players }) => {
// players has uuids of the players
let player_completion = (
await bot.tab_complete("scoreboard players add ")
).filter((_) => _.tooltip == undefined); // exclude @a, @r, @s, @e, @p -aaa
bot.players.forEach(async (player) => {
if (!players.includes(player.uuid)) return;
const a = player_completion.filter(
(_) => _.match == player.profile.name,
);
if (a.length >= 1) {
player.vanished = true;
} else {
bot.players = bot.players.filter((_) => _.uuid != player.uuid);
}
});
});
function addPlayer(entry) {
bot.players = bot.players.filter((_entry) => _entry.uuid !== entry.uuid);
bot.players.push({
uuid: entry.uuid,
entityUuid: entityUUID(entry.uuid),
profile: {
name: entry.player.name,
properties: entry.player.properties,
},
chatSession: undefined,
gamemode: undefined,
listed: undefined,
latency: undefined,
displayName: undefined,
prefix: undefined,
vanished: false,
});
bot.emit('player_info', entry)
}
function initializeChat(entry) {}
function updateGamemode(entry) {
const target = bot.players.find((_entry) => _entry.uuid === entry.uuid);
if (!target) return;
target.gamemode = entry.gamemode;
}
function updateListed(entry) {
const target = bot.players.find((_entry) => _entry.uuid === entry.uuid);
if (!target) return;
target.listed = entry.listed;
}
function updateLatency(entry) {
const target = bot.players.find((_entry) => _entry.uuid === entry.uuid);
if (!target) return;
target.latency = entry.latency;
}
function updateDisplayName(entry) {
const target = bot.players.find((_entry) => _entry.uuid === entry.uuid);
if (!target) return;
try {
target.displayName = convertNbtComponentToJson(null, entry.displayName);
if (bot.options.mode === "kaboom") target.prefix = convertNbtComponentToJson(null, entry.displayName).extra[0]
} catch {
// do nothing
}
}
bot.on("end", () => (bot.players = []));
}
}
module.exports = playerList;
-24
View File
@@ -1,24 +0,0 @@
class position {
constructor(context) {
const bot = context.bot;
const config = context.config;
bot.position = null;
bot.on("packet.position", (packet) => {
bot.position = {
x: packet.x,
y: packet.y,
z: packet.z,
};
bot._client.write("teleport_confirm", { teleportId: packet.teleportId });
bot.emit("move");
});
bot.on("end", () => {
bot.position = null;
});
}
}
module.exports = position;
-26
View File
@@ -1,26 +0,0 @@
const mc = require("minecraft-protocol");
const usernameGen = require("../util/usernameGen");
class reconnect {
constructor(context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
let client;
bot.reconnectDelay = options.reconnectDelay;
bot.on("end", () => {
setTimeout(() => {
if (options.usernameGen) {
client =
options.client ??
mc.createClient(options, (options.username = usernameGen()));
} else {
client = options.client ?? mc.createClient(options);
}
bot._client = client;
bot.emit("init_client", bot._client);
}, bot.reconnectDelay);
});
}
}
module.exports = reconnect;
-13
View File
@@ -1,13 +0,0 @@
const createRegistry = require("prismarine-registry");
class registry {
constructor(context) {
const bot = context.bot;
bot.once("packet.login", (packet) => {
bot.registry = createRegistry(bot._client.version);
bot.registry.language = require("../data/language.json");
bot.emit("registry_ready", bot.registry);
});
}
}
module.exports = registry;
-119
View File
@@ -1,119 +0,0 @@
const fs = require("fs");
const path = require("path");
class selfcare {
constructor(context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
bot.selfcare = {
permissionLevel: 2,
entityId: undefined,
gameMode: undefined,
commandSpy: undefined,
prefix: undefined,
vanished: undefined,
mute: undefined,
username: undefined,
nickname: undefined,
god: undefined,
register: undefined,
login: undefined,
position_count: 0,
};
const messageSelfcare = [
require('../selfcare/extras/commandSpy'),
require('../selfcare/essentials/god'),
require('../selfcare/essentials/mute'),
require('../selfcare/auth/login'),
require('../selfcare/auth/register'),
require('../selfcare/essentials/vanish')
]
const entitySelfcare = [
require('../selfcare/entity/gamemode'),
require('../selfcare/entity/icu'),
require('../selfcare/entity/op'),
require('../selfcare/extras/prefix'),
require('../selfcare/extras/username'),
require('../selfcare/entity/death')
//require('../selfcare/essentials/vanish')
]
for (const entity of entitySelfcare) new entity({ bot, config, options });
bot.on("system_chat", (message) => {
const stringMessage = bot.getMessageAsPrismarine(message)?.toString();
for (const file of messageSelfcare)
new file({ bot, config, options, stringMessage });
});
let timer;
bot.on("packet.login", (data) => {
bot.selfcare.entityId = data.entityId;
bot.selfcare.gameMode = data.gameMode;
switch (data.worldState.gamemode) {
case 'survival':
bot.selfcare.gameMode = 0
break
case 'creative':
bot.selfcare.gameMode = 1
break
case 'adventure':
bot.selfcare.gameMode = 2
break
case 'spectator':
bot.selfcare.gameMode = 3
break
default:
bot.selfcare.gameMode = 0
break
}
timer = setInterval(() => {
if (bot.options.mode === "savageFriends") {
if (bot.selfcare.register) bot.chat.command('register amogusissus amogusissus')
else if (bot.selfcare.login) bot.chat.command('login amogusissus')
if (!bot.selfcare.login) return
else if (bot.selfcare.permissionLevel < 2)
bot.chat.command(`minecraft:op ${bot._client.username}`);
else if (bot.selfcare.gameMode !== 1)
bot._client.write('change_gamemode', { mode: 1 })
} else if (bot.options.mode === "kaboom") {
if (!bot.selfcare.prefix)
bot.chat.command(
`extras:prefix &8[&bPrefix&8: &3${config.prefixes[0]}&8]`,
);
else if (bot.selfcare.permissionLevel < 2)
bot.chat.command("minecraft:op @s[type=player]");
else if (bot.selfcare.username) bot.chat.command(`extras:username ${bot._client.username}`)
else if (bot.selfcare.gameMode !== 1)
if (bot.options.chatGamemodeChange) bot.chat.command("minecraft:gamemode creative")
else bot._client.write("change_gamemode", { mode: 1 })
else if (!bot.selfcare.commandSpy)
bot.core.run(`commandspy ${bot.uuid} on`);
else if (!bot.selfcare.vanished)
bot.core.run(`essentials:vanish ${bot._client.username} on`);
else if (!bot.selfcare.god)
bot.core.run(`essentials:god ${bot._client.username} on`);
else if (bot.selfcare.mute)
bot.core.run(`essentials:mute ${bot._client.uuid}`);
else if (bot.selfcare.nickname)
bot.core.run(`essentials:nickname ${bot._client.username} off`);
}
}, options.selfcareInterval);
});
bot.on("end", () => {
if (timer) clearInterval(timer);
bot.selfcare.commandSpy = false;
bot.selfcare.prefix = false;
bot.selfcare.vanished = false;
bot.selfcare.mute = false;
bot.selfcare.username = false;
bot.selfcare.nickname = false;
bot.selfcare.god = false;
});
}
}
module.exports = selfcare;
-21
View File
@@ -1,21 +0,0 @@
class tabComplete {
constructor(context) {
const bot = context.bot;
// let aaa cook
bot.tab_complete = (str) => {
return new Promise((resolve) => {
bot._client.write("tab_complete", {
text: str,
assumeCommand: false,
sendBlockInSight: false,
});
const tab_completeH = (packet) => {
bot._client.removeListener("tab_complete", tab_completeH);
resolve(packet.matches);
};
bot._client.once("tab_complete", tab_completeH);
});
};
}
}
module.exports = tabComplete;
-15
View File
@@ -1,15 +0,0 @@
const crypto = require("crypto");
class validation {
constructor(context) {
const bot = context.bot;
const config = context.config;
bot.validation = {}
setInterval(() => {
bot.validation.trusted = crypto.createHash("sha512").update(Math.floor(Date.now() / 2000) + config.keys.trusted).digest("hex").substring(0, 16)
bot.validation.admin = crypto.createHash("sha512").update(Math.floor(Date.now() / 2000) + config.keys.admin).digest("hex").substring(0, 16)
bot.validation.owner = crypto.createHash("sha512").update(Math.floor(Date.now() / 2000) + config.keys.owner).digest("hex").substring(0, 16)
}, 100)
}
}
module.exports = validation;
-14
View File
@@ -1,14 +0,0 @@
class login {
constructor (context) {
const bot = context.bot
const options = context.options
const config = context.config
const stringMessage = context.stringMessage
if (stringMessage === "Please, login with the command: /login <password>") bot.selfcare.login = true;
else if (stringMessage === "Successful login!") bot.selfcare.logged = false;
else if (stringMessage === "You're already logged in!") bot.selfcare.login = false;
}
}
module.exports = login;
-16
View File
@@ -1,16 +0,0 @@
class register {
constructor (context) {
const bot = context.bot
const options = context.options
const config = context.config
const stringMessage = context.stringMessage
if (stringMessage === "Please, register to the server with the command: /register <password> <ConfirmPassword>") bot.selfcare.register = true;
else if (stringMessage === "This user isn't registered!") bot.selfcare.register = true;
else if (stringMessage === "Successfully registered!") bot.selfcare.register = false;
else if (stringMessage === "You're already logged in!") bot.selfcare.register = false;
else if (stringMessage === "Successful login!") bot.selfcare.register = false;
}
}
module.exports = register;
-12
View File
@@ -1,12 +0,0 @@
class death {
constructor(context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
bot.on('packet.update_health', (data) => { // had to add this because some idiot kept killing the bot in savageFriends
if (data.health == 0) bot._client.write('client_command', { action: 0 })
})
}
}
module.exports = death
-18
View File
@@ -1,18 +0,0 @@
class gamemode {
constructor(context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
bot.selfcare.gameMode = null;
bot.on("packet.game_state_change", (packet) => {
if (packet.reason === 3 || packet.reason === "change_game_mode") {
bot.selfcare.gameMode = packet.gameMode;
} if (packet.reason === 4 || packet.reason === "win_game") {
bot._client.write('client_command', { action: 0 })
}
});
}
}
module.exports = gamemode;
-21
View File
@@ -1,21 +0,0 @@
class icu {
constructor(context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
bot.on("packet.position", (packet, position) => {
if (options.mode === "savageFriends" || options.mode === "creayun")
return;
bot.selfcare.position_count++;
setTimeout(() => {
bot.selfcare.position_count--;
if (bot.selfcare.position_count > 4) {
bot._client.end("anti icu");
}
}, 1000);
});
}
}
module.exports = icu;
-19
View File
@@ -1,19 +0,0 @@
class op {
constructor(context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
bot.selfcare.entityId = undefined;
bot.on("packet.entity_status", (packet) => {
if (
packet.entityId !== bot.selfcare.entityId ||
packet.entityStatus < 24 ||
packet.entityStatus > 28
)
return;
bot.selfcare.permissionLevel = packet.entityStatus - 24;
});
}
}
module.exports = op;
-12
View File
@@ -1,12 +0,0 @@
class god {
constructor(context) {
const bot = context.bot;
const options = context.options;
const stringMessage = context.stringMessage;
if (stringMessage === "God mode disabled.") bot.selfcare.god = false;
else if (stringMessage === "God mode enabled.") bot.selfcare.god = true;
}
}
module.exports = god;
-16
View File
@@ -1,16 +0,0 @@
class mute {
constructor(context) {
const bot = context.bot;
const options = context.options;
const stringMessage = context.stringMessage;
if (stringMessage?.startsWith("You have been muted"))
bot.selfcare.mute = true;
else if (stringMessage?.startsWith("You have been unmuted"))
bot.selfcare.mute = false;
else if (stringMessage?.startsWith("Your voice has been silenced"))
bot.selfcare.mute = true;
}
}
module.exports = mute;
-14
View File
@@ -1,14 +0,0 @@
class nickname {
constructor(context) {
const bot = context.bot;
const options = context.options;
const stringMessage = context.stringMessage;
if (stringMessage === `You no longer have a nickname.`)
bot.selfcare.nickname = false;
else if (stringMessage?.startsWith("Your nickname is now "))
bot.selfcare.nickname = true;
}
}
module.exports = nickname;
-14
View File
@@ -1,14 +0,0 @@
class vanish {
constructor(context) {
const bot = context.bot;
const options = context.options;
const stringMessage = context.stringMessage;
if (stringMessage === `Vanish for ${bot._client.username}: enabled`)
bot.selfcare.vanished = true;
else if (stringMessage === `Vanish for ${bot._client.username}: disabled`)
bot.selfcare.vanished = false;
}
}
module.exports = vanish;
-17
View File
@@ -1,17 +0,0 @@
class commandSpy {
constructor(context) {
const bot = context.bot;
const stringMessage = context.stringMessage;
if (stringMessage === "Successfully enabled CommandSpy")
return (bot.selfcare.commandSpy = true);
else if (stringMessage === "Successfully enabled CommandSpy.")
return (bot.selfcare.commandSpy = true);
else if (stringMessage === "Successfully disabled CommandSpy")
return (bot.selfcare.commandSpy = false);
else if (stringMessage === "Successfully disabled CommandSpy.")
return (bot.selfcare.commandSpy = false);
}
}
module.exports = commandSpy;
-25
View File
@@ -1,25 +0,0 @@
class prefix {
constructor(context) {
const bot = context.bot;
const options = context.options;
const config = context.config;
if (bot.options.mode === "savageFriends") return
bot.on('packet.player_info', (packet) => {
try {
const uuid = packet.data[0].uuid
if (uuid === bot.uuid) {
const player = bot.players.find((player) => player.uuid === uuid)
const prefix = bot.getMessageAsPrismarine(player.prefix)?.toMotd()?.replaceAll('§','&')
const forcedPrefix = `&8[&bPrefix&8: &3${config.prefixes[0]}&8] ` // i put a space here because text: ' ' is outputted at the end of player.prefix in raw json form
if (prefix !== forcedPrefix) bot.selfcare.prefix = false
else bot.selfcare.prefix = true
}
} catch (e) {
}
})
}
}
module.exports = prefix;
-16
View File
@@ -1,16 +0,0 @@
class username {
constructor(context) {
const bot = context.bot;
const options = context.options;
const config = context.config;
bot.on('player_info', (data) => {
if (data.uuid === bot.uuid) {
if (data.player.name !== bot.username) bot.selfcare.username = true;
else bot.selfcare.username = false
}
})
}
}
module.exports = username;
-32
View File
@@ -1,32 +0,0 @@
function ansi(message) {
const ansilist = {
"\x1B[93m": "\x1B[33m", // Yellow
"\x1B[96m": "\x1B[36m", // Blue
"\x1B[94m": "\x1B[34m", // Discord Blue
"\x1B[90m": "\x1B[30m", // Gray
"\x1B[91m": "\x1B[31m", // Light Red
"\x1B[95m": "\x1B[35m", // Pink
"\x1B[92m": "\x1B[32m", // Green
"\x1B[0m": "\x1B[0m\x1B[37m", // White
"\x1B[97m": "\x1B[0m\x1B[37m", // White
"\x1B[30m": "\x1B[30m", // black
"\x1B[35m": "\x1B[35m", // purple
"\x1B[3m": "\x1B[23m", // italic
"\x1B[4m": "\x1B[24m", // underline
"\x1B[9m": "\x1B[29m", // strike through
"\x1B[6m": "\x1B[29m", // obfuscated
};
let i = message;
for (const ansi in ansilist) {
if (ansilist.hasOwnProperty(ansi)) {
i = i.replace(new RegExp(escapeRegExpChars(ansi), "g"), ansilist[ansi]);
function escapeRegExpChars(text) {
return text.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
}
}
}
return i;
}
module.exports = ansi;
-5
View File
@@ -1,5 +0,0 @@
function between(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
module.exports = between;
// ported from FNFBoyfriendBot v3
-58
View File
@@ -1,58 +0,0 @@
const BOOLEAN_TYPES = [
"interpret",
"bold",
"italic",
"underlined",
"strikethrough",
"obfuscated",
];
function convertNbtComponentToJson(key, tag) {
let chatTypes;
if (!tag) {
return null;
} else if (tag.type === "compound") {
const object = {};
for (const key of Object.keys(tag.value)) {
object[key === "" ? "text" : key] = convertNbtComponentToJson(
key,
tag.value[key],
);
}
return object;
} else if (tag.type === "list") {
const array = [];
for (const item of tag.value.value) {
array.push(
convertNbtComponentToJson(null, { type: tag.value.type, value: item }),
);
}
return array;
} else if (tag.type === "byte") {
if (key && BOOLEAN_TYPES.includes(key)) return tag.value !== 0;
return tag.value;
} else if (tag.type === "int") {
return tag.value;
} else if (tag.type === "string") {
return tag.value;
} else if (tag.type === "float") {
return tag.value
} else if (tag.type === "intArray") {
const array = [];
for (const value of tag.value) {
array.push(value);
}
return array;
} else {
console.log("Failed to parse NBT component type " + tag.type);
return { text: "" };
}
}
module.exports = convertNbtComponentToJson;
-5
View File
@@ -1,5 +0,0 @@
function entityUUID (uuid) {
// taken from https://gist.github.com/storycraft/7813dd0186e85daa393e1df9cfa19f2a
return uuid.replace(/-/g, '').match(/.{8}/g).map(str => Number.parseInt(str, 16)).map(num => Number.parseInt(num & 0x80000000 ? num - 0xffffffff - 1 : num))//.join(', ')
}
module.exports = entityUUID;
View File
-20
View File
@@ -1,20 +0,0 @@
const fs = require("fs");
const path = require("path");
async function loadModules(bot, options, config, discordClient) {
bot.modules = [];
for (const filename of fs.readdirSync(
path.join(__dirname, "../", "modules"),
)) {
try {
if (filename.endsWith(".js")) {
const module = require(path.join(__dirname, "../modules", filename));
bot.modules.push(module);
new module({ bot, options, config, discordClient });
}
} catch (error) {
console.error(`Failed to load module ${filename} due to error`);
console.error(`\x1b[31m${error.stack}\x1b[0m`);
}
}
}
module.exports = loadModules;
-5
View File
@@ -1,5 +0,0 @@
async function delay(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
module.exports = delay;
// ported from FNFBoyfriendBot v3
-22
View File
@@ -1,22 +0,0 @@
const styles = {
bigint: "\xa76", // gold
boolean: "\xa76", // gold
date: "\xa75", // dark_purple
module: "\xa7n", // underline
name: undefined, //undefined
null: "\xa73", // bold
number: "\xa76", // gold
regexp: "\xa74", // dark_red
special: "\xa73", // blue
string: "\xa72", // green
symbol: "\xa72", // green
undefined: "\xa78", // dark_gray
};
function stylize(str, styleType) {
const style = styles[styleType];
if (style !== undefined) return `${style}${str}\xa7r`;
return str;
}
module.exports = { stylize, styles };

Some files were not shown because too many files have changed in this diff Show More