Compare commits

...

3 commits
main ... main

68 changed files with 518 additions and 220 deletions

11
package-lock.json generated
View file

@ -1,11 +1,14 @@
{ {
"name": "FridayNightFunkinBoyfriendBot", "name": "FridayNightFunkinBoyfriendBot",
"version": "v6.1.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"build": "1145", "buildstring": {
"codename": "", "version": "v6.1.2",
"url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot", "build": "1200",
"releaseDate": "11/22/24",
"codename": "§eHazardous §4Massacre",
"url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot"
},
"packages": { "packages": {
"": { "": {
"dependencies": { "dependencies": {

View file

@ -0,0 +1,2 @@
this folder is for removed / scrapped concepts just in case people want to reimplement them

View file

@ -0,0 +1,114 @@
const trustedPlayers = require('../data/trustedPlayers.json');
module.exports = (bot, options, config) => {
let component;
trustedPlayers.map((trusted) => {
/*component.push({
translate: "%s",
color: config.colors.commands.tertiary,
with: [
{ text: "ea" }
]
})*/
bot.on('message', (data) => {
try {
let stringMessage = bot.getMessageAsPrismarine(data)?.toString();
// console.log(JSON.stringify(data))
// console.log(data?.with[0]?.clickEvent);
// console.log(data.color);
// for (const players of bot.players) {
if (
/*
stringMessage.startsWith(`${trusted.player}`) &&
data.translate === "multiplayer.player.joined" &&
data.color === "yellow" &&
data.with.insertion === `${trusted.player}` &&
data?.with[0]?.clickEvent === `{action:'suggest_command',value:'/tell ${trusted.player} '}` &&*/
JSON.stringify(data) ===
JSON.stringify({
color:'yellow',
translate:'multiplayer.player.joined',
with:[{insertion:`${trusted.player}`,
clickEvent:{
action:'suggest_command',
value:`/tell ${trusted.player} `
},
hoverEvent:{
action:'show_entity',
contents:{
type:'minecraft:player',
id:`${bot.players.find((player) => player.profile.name === trusted.player)?.uuid}`,
name:{
text:`${trusted.player}`
}
}
},
text:`${trusted.player}`
}]
})
) {
if (bot.players.map((e) => { e.profile.name === trusted.player })) {
bot.tellraw(`@a[name="${trusted.player}"]`, "e");
component = "e";
}
}
// bot.tellraw(`@a[name="${bot.players.find((player) => player.profile.name === trusted.player).profile.name}"]`, component);
/* for (const players of bot.players) {
// console.log(players);
if (players.profile.name === trusted.player) {
let e = players.profile.name === trusted.player;
for (const eachBot of bot.bots) {
eachBot.tellraw(`@a[name="${trusted.player}"]`, "e");
}
}*/
// }
//if (bot.players.find((player) => player.profile.name !== trusted.player)) return
//for (const eachBot of bot.bots) {
// if (bot.players.find((player) => player.profile.name === trusted.player)) {
// bot.tellraw(`@a[name="${bot.players.find((player) => player.profile.name === trusted.player).profile.name}"]`, "e");
// }
//}
// bot.chat.message(`${trusted.player} joined the game`);
// }
// }
} catch (e) {
console.log(e.stack);
}
})
})
/* bot.on('packet.login', (data) => {
console.log(bot.players.find((players) => players.profile.name === trusted.player))
console.log(bot.players)
if (bot.players.find((player) => player.profile.name === trusted.player)) {
bot.chat.message('player joined the game')
}
})
multiplayer.player.joined
[{"insertion":"Parker2991","clickEvent":{"action":"suggest_command",
"value":"/tell Parker2991 "},"hoverEvent":{"action":"show_entity",
"contents":{"type":"minecraft:player",
"id":"85f5b68d-a567-3877-9701-3cd7404bc9d9",
"name":{"text":"Parker2991"}}},"text":"Parker2991"}]
[
{
insertion: 'Parker2991',
clickEvent: { action: 'suggest_command', value: '/tell Parker2991 ' },
hoverEvent: { action: 'show_entity', contents: [Object] },
text: 'Parker2991'
}
]
yellow
*/
/*for (const trusted in trustedPlayers) {
component.push({
translate: '%s',
color: config.colors.commands.tertiary,
with: [
{ text: 'e' }
]
})
// console.log(component)
}*/
// bot.tellraw("@a", component)
}

View file

@ -14,11 +14,10 @@ module.exports = {
"<command>", "<command>",
], ],
}, },
async execute (context) { execute (context) {
const bot = context.bot const bot = context.bot
const message = context.arguments.join(' '); const message = context.arguments.join(' ');
bot.core.run(message); bot.core.runTracked(message);
await sleep(45);
/* bot.on('commandBlockOutput', (packet) => { /* bot.on('commandBlockOutput', (packet) => {
bot.tellraw("@a", require('util').inspect(packet)); bot.tellraw("@a", require('util').inspect(packet));
console.log(packet); console.log(packet);

View file

@ -46,7 +46,7 @@ module.exports = {
switch (args[0]?.toLowerCase()) { switch (args[0]?.toLowerCase()) {
case "about": case "about":
component.push({ component.push({
text: `FNFBoyfriendBot is a kaboom bot created by Parker2991\nThe source code and changelog can be found here ${botInfo.url}`, 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}`, color: `${config.colors.commands.primary}`,
translate: "", translate: "",
hoverEvent: { hoverEvent: {
@ -57,7 +57,7 @@ module.exports = {
}, },
clickEvent: { clickEvent: {
action: "open_url", action: "open_url",
value: `${botInfo.url}` value: `${botInfo.buildstring.url}`
} }
}) })
break; break;
@ -153,7 +153,7 @@ module.exports = {
case "contributors": case "contributors":
case "credits": case "credits":
component.push({ component.push({
translate: "%s%s - %s\n%s:\n%s\n%s\n%s\n%s\n%s %s\n%s", 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, color: config.colors.commands.tertiary,
with: [ with: [
{ text: "Parker", color: "dark_red" }, { text: "Parker", color: "dark_red" },
@ -166,7 +166,8 @@ module.exports = {
{ text: "aaa", color: "gold" }, { text: "aaa", color: "gold" },
{ text: "Morgan", color: "green" }, { text: "Morgan", color: "green" },
{ text: "Ankan", color: "dark_green" }, { text: "Ankan", color: "dark_green" },
{ text: "TurtleKid", color: "green" } { text: "TurtleKid", color: "green" },
{ text: "Ploat/ImGloriz", color: "#cd8ccb" },
] ]
}) })
break; break;
@ -191,6 +192,7 @@ module.exports = {
}) })
break; break;
case "usages": case "usages":
case "usage":
switch (args.slice(1).join(' ')?.toLowerCase()) { switch (args.slice(1).join(' ')?.toLowerCase()) {
case "bot": case "bot":
component.push({ component.push({
@ -310,26 +312,7 @@ module.exports = {
case "version": case "version":
case "ver": case "ver":
if (botInfo.codename === '') { if (botInfo.codename === '') {
component.push({
translate: "%s %s %s-%s-%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.version}`, color: config.colors.integer },
{ text: "#" },
{ text: `${botInfo.build}`, color: config.colors.integer },
{ text: "11/22/22", color: config.colors.commands.primary },
{ text: `${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`, color: config.colors.commands.secondary },
]
})
/*
`§9Friday §9Night §9Funkin §3Boyfriend §1Bot§8§r-
${botInfo.version}-#${botInfo.build}-${botInfo.codename}\n11/22/22 -
${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}
*/
} else {
component.push({ component.push({
translate: "%s %s %s-%s-%s%s-%s\n%s - %s", translate: "%s %s %s-%s-%s%s-%s\n%s - %s",
color: config.colors.commands.tertiary, color: config.colors.commands.tertiary,
@ -337,10 +320,27 @@ ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}
{ text: "Friday Night Funkin", color: "dark_blue" }, { text: "Friday Night Funkin", color: "dark_blue" },
{ text: "Boyfriend", color: "dark_aqua" }, { text: "Boyfriend", color: "dark_aqua" },
{ text: "Bot", color: "blue" }, { text: "Bot", color: "blue" },
{ text: `${botInfo.version}`, color: config.colors.integer }, { text: `${botInfo.buildstring.version}`, color: config.colors.integer },
{ text: "#" }, { text: "#" },
{ text: `${botInfo.build}`, color: config.colors.integer }, { text: `${botInfo.buildstring.build}`, color: config.colors.integer },
{ text: `${botInfo.codename}` }, { text: `${botInfo.buildstring.releaseDate}`, 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-%s%s-%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: "#" },
{ text: `${botInfo.buildstring.build}`, color: config.colors.integer },
{ text: `${botInfo.buildstring.releaseDate}`, color: config.colors.commands.secondary },
{ text: `${botInfo.buildstring.codename}` },
{ text: "11/22/22", color: config.colors.commands.primary }, { text: "11/22/22", color: config.colors.commands.primary },
{ text: `${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`, color: config.colors.commands.secondary }, { text: `${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`, color: config.colors.commands.secondary },
] ]

View file

@ -0,0 +1,32 @@
module.exports = {
data: {
name: 'memusage',
trustLevel: 0,
aliases: [
],
description: 'check the bots and the servers ram usage',
usages: [
"on/enable/true",
"off/disable/false",
],
},
execute (context) {
const bot = context.bot
const args = context.arguments;
switch (args[0]?.toLowerCase()) {
case "on":
case "enable":
case "true":
bot.memUsage.enabled = true;
bot.chat.message('enabled memusage');
break;
case "off":
case "enable":
case "false":
bot.memUsage.enabled = false;
bot.chat.message('disabled memusage');
break;
throw new CommandError({ translate: "command.unknown.argument", color: "dark_red" });
}
},
}

View file

@ -1,6 +1,6 @@
const wiki = require('wikipedia') const wiki = require('wikipedia');
const CommandError = require('../../util/command_error') const CommandError = require('../../util/command_error');
const { EmbedBuilder } = require('discord.js') const { EmbedBuilder } = require('discord.js');
module.exports = { module.exports = {
data: { data: {
name: 'wiki', name: 'wiki',
@ -10,20 +10,20 @@ module.exports = {
'wikipedia' 'wikipedia'
], ],
usages:[ usages:[
"<definition>" "<article>"
], ],
}, },
async execute (context) { async execute (context) {
const source = context.source const source = context.source;
const args = context.arguments const args = context.arguments;
const bot = context.bot const bot = context.bot;
try { try {
const page = await wiki.page(args.join(' ')) const page = await wiki.page(args.join(' '))
const summary = await page.intro(); const summary = await page.intro();
bot.tellraw(`@a`, { text: `${summary}`, color: 'gray' }); bot.tellraw(`@a`, { text: `${summary}`, color: 'gray' });
} catch (error) { } catch (error) {
if (error.toString() === "pageError: TypeError: Cannot read properties of undefined (reading 'pages')") { if (error.toString() === "pageError: TypeError: Cannot read properties of undefined (reading 'pages')") {
bot.tellraw(`@a`, { text: 'Definition not found!', color: 'dark_red' }) bot.tellraw(`@a`, { text: 'Article not found!', color: 'dark_red' })
} else { } else {
bot.tellraw(`@a`, `${error.toString()}`) bot.tellraw(`@a`, `${error.toString()}`)
} }

View file

@ -3,7 +3,7 @@ const CommandError = require('../../util/command_error')
module.exports = { module.exports = {
data: { data: {
name: 'tpr', name: 'tpr',
description: 'teleport to a random place', description: 'teleport to very fucked up coords',
trustLevel: 1, trustLevel: 1,
aliases: [ aliases: [
'rtp', 'rtp',

View file

@ -1,17 +1,21 @@
prefixes: prefixes:
- "!" - "!"
discord: discord:
token: "discord token here" token: "discord token here"
prefix: "!" prefix: "!"
invite: "discord invite here" invite: "discord invite here"
enabled: true
roles: roles:
trusted: "trusted" trusted: "trusted"
admin: "admin" admin: "admin"
owner: "FNFBoyfriendBot Owner" owner: "FNFBoyfriendBot Owner"
core: core:
# core refill methods:
# chat: refill core in chat
# item refill core in a command block placed by the bot
name: {"translate":"outOfMemory.message"} name: {"translate":"outOfMemory.message"}
method: 'item'
area: area:
start: start:
x: 0 x: 0

View file

@ -0,0 +1,19 @@
module.exports = {
data: {
name: '<command name>',
trustLevel: 0, // trust levels: 0, 1, 2, 3, 4
aliases: [
""
],
description: '',
usages: [
""
],
},
execute (context) {
},
discordExecute (context) {
}
}

View file

@ -0,0 +1,19 @@
export default {
data: {
name: '<command name>',
trustLevel: 0, // trust levels: 0, 1, 2, 3, 4
aliases: [
],
description: '',
usages: [
""
],
},
execute (context) {
},
discordExecute (context) {
}
}

View file

@ -0,0 +1,4 @@
function whatevername (bot, options, config, discordClient) {
}
module.exports = whatevername

View file

@ -0,0 +1,3 @@
module.exports = (bot, options, config, discordClient) => {
}

View file

@ -0,0 +1,3 @@
export default function () {
}

View file

@ -1 +0,0 @@
[{"ignoreCase":false,"regexed":false,"name":"04928"},{"ignoreCase":false,"regexed":false,"name":"04928"},{"ignoreCase":false,"regexed":false,"name":"04928"},{"ignoreCase":false,"regexed":false,"name":"04928"},{"ignoreCase":false,"regexed":false,"name":"Parker2991"}]

View file

@ -9,6 +9,7 @@ const { Client, GatewayIntentBits } = require('discord.js');
const { MessageContent, GuildMessages, Guilds } = GatewayIntentBits; const { MessageContent, GuildMessages, Guilds } = GatewayIntentBits;
const discordClient = new Client({ intents: [Guilds, GuildMessages, MessageContent] }); const discordClient = new Client({ intents: [Guilds, GuildMessages, MessageContent] });
console.log('Starting FNFBoyfriendBot'); console.log('Starting FNFBoyfriendBot');
process.stdout.write('\x1b]2;Starting FNFBoyfriendBot please wait,.....\x1b\x5c')
checks(); checks();
try { try {
@ -16,10 +17,15 @@ try {
} catch (e) { } catch (e) {
console.log(e.stack); console.log(e.stack);
} }
if (config.core.method !== 'item' && config.core.method !== 'chat') {
config.core.method = 'item';
console.warn('invalid core method type defaulting to item');
}
const rl = readline.createInterface({ const rl = readline.createInterface({
input: process.stdin, input: process.stdin,
output: process.stdout, output: process.stdout,
}) })
//console.log(completion);
if (config.discord.enabled) discordClient.login(config.discord.token); if (config.discord.enabled) discordClient.login(config.discord.token);
const bots = []; const bots = [];
for (const options of config.bots) { for (const options of config.bots) {

View file

@ -1,4 +1,8 @@
function boot (bot, options, discordClient, config) {
function boot (context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
bot.on("packet.login", (data) => { bot.on("packet.login", (data) => {
if (bot.options.isCreayun) return if (bot.options.isCreayun) return
if (new Date().getDay() === 5) { if (new Date().getDay() === 5) {
@ -6,7 +10,9 @@ function boot (bot, options, discordClient, config) {
} else { } else {
bot.chat.message('&9FNF&3Boyfriend&1Bot &fcreated by &4Parker&02991'); bot.chat.message('&9FNF&3Boyfriend&1Bot &fcreated by &4Parker&02991');
} }
}) // &9 &3 &1 })
setInterval(() => {
process.stdout.write(`\x1b]2; FNFBoyfriendBot | Time: ${new Date().toLocaleString("en-US",{timeZone: "America/CHICAGO"})} | \x1b\x5c`)
}, 1000)
} }
module.exports = boot; module.exports = boot;

View file

@ -12,8 +12,11 @@ function tryParse (json) {
return { text: '' } return { text: '' }
} }
} }
//what was changed?? //what was changed?
function chat (bot, options, config) { function chat (context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
let ChatMessage let ChatMessage
bot.on('registry_ready', registry => { bot.on('registry_ready', registry => {
ChatMessage = loadPrismarineChat(registry) ChatMessage = loadPrismarineChat(registry)

View file

@ -1,6 +1,9 @@
const CommandSource = require('../util/command_source'); const CommandSource = require('../util/command_source');
module.exports = (bot, options, config) => { module.exports = (context) => {
let ratelimit = 0; let ratelimit = 0;
const bot = context.bot;
const config = context.config;
const options = context.options;
bot.on("parsed_message", (data) => { bot.on("parsed_message", (data) => {
if (data.type !== "minecraft:chat") return; if (data.type !== "minecraft:chat") return;
const prefixes = config.prefixes; const prefixes = config.prefixes;

View file

@ -1,5 +1,9 @@
function core (bot, options, config) { const mcData = require('minecraft-data')('1.20.2');
let number = 0;
function core (context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
bot.core = { bot.core = {
area: { area: {
start: config.core?.area.start ?? { x: 0, y: 0, z: 0 }, start: config.core?.area.start ?? { x: 0, y: 0, z: 0 },
@ -25,7 +29,51 @@ function core (bot, options, config) {
it will not refill core until the pos is not NaN it will not refill core until the pos is not NaN
instead of tping to a set cords cuz fuck you im not doing that instead of tping to a set cords cuz fuck you im not doing that
*/ */
bot.chat.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} repeating_command_block{CustomName:'${JSON.stringify(config.core.name)}'}`) const 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} repeating_command_block{CustomName:'${JSON.stringify(config.core.name)}'} destroy`
if (config.core.method === 'chat') {
bot.chat.command(`${command}`)
} else if (config.core.method === 'item') {
bot._client.write('set_creative_slot', {
slot: 36,
item: {
present: true,
itemId: mcData.itemsByName.command_block.id,
itemCount: 1,
nbtData: { }
}
});
bot._client.write('block_dig', {
status: 0,
location: {
x: bot.position.x,
y: bot.position.y,
z: bot.position.z
},
face: 0
});
bot._client.write('block_place', {
hand: 0,
location: {
x: bot.position.x,
y: bot.position.y,
z: bot.position.z
},
direction: 0,
cursorX: 0.1,
cursorY: 0,
cursorZ: 0.1,
insideBlock: false
});
bot._client.write('update_command_block', {
location: bot.position,
command,
flags: 5,
mode: 1
})
}
}, },
move (pos = bot.position) { move (pos = bot.position) {
@ -76,15 +124,61 @@ function core (bot, options, config) {
} else { } else {
bot._client.write('update_command_block', { command: command.substring(0, 32767), location, mode: 1, flags: 0b100 }); bot._client.write('update_command_block', { command: command.substring(0, 32767), location, mode: 1, flags: 0b100 });
bot._client.write('query_block_nbt', ({ location: location, transactionId: eee})); bot._client.write('query_block_nbt', ({ location: location, transactionId: eee}));
bot.core.incrementCurrentBlock() bot.core.incrementCurrentBlock();
} }
}, },
runTracked (command) {
const transactionId = Math.floor(Math.random() * 1000);
const location = bot.core.currentBlock();
if (!location) return;
if (bot.position.y !== bot.core.position.y) {
bot.chat.command(`minecraft:tp ${bot.core.position.x} ${bot.core.position.y} ${bot.core.position.z}`)
}
bot._client.write('update_command_block', {
command: command.substring(0, 32767),
location,
flags: 5,
mode: 1,
// LastOutput: true,
});
bot.core.incrementCurrentBlock();
bot._client.write('query_block_nbt', {
location,
transactionId
});
bot.on('packet.nbt_query_response', (data) => {
// transactionId,
try {
if (data.transactionId === transactionId) {
bot.tellraw("@a", require('util').inspect(data.value))
bot.tellraw("@a", JSON.stringify(data.value))
}
} catch (e) {
bot.tellraw("@a", require("util").inspect(e.stack));
}
})
}
} }
if (bot.options.isSavage || bot.options.isCreayun) return if (bot.options.isSavage || bot.options.isCreayun) return
bot.on('move', () => { bot.on('move', () => {
bot.core.move(bot.position) bot.core.move(bot.position)
}) })
}
bot.on('packet.block_change', (data) => {
// console.log('data pos ' + JSON.stringify(data.location))
// console.log('core pos ' +JSON.stringify(bot.core.position));
if (data.type === 0) {
// console.log('data pos ' + JSON.stringify(data.location));
// console.log('core position ' + JSON.stringify(bot.core.position));
// bot.core.refill();
}
})
}
module.exports = core; module.exports = core;

View file

@ -1,4 +1,5 @@
function command_loop (bot, options, config) { function command_loop (context) {
const bot = context.bot;
bot.cloop = { bot.cloop = {
list: [], list: [],
add (command, interval) { add (command, interval) {

View file

@ -3,7 +3,12 @@ const path = require('path');
const CommandError = require('../util/command_error.js'); const CommandError = require('../util/command_error.js');
const CommandSource = require('../util/command_source'); const CommandSource = require('../util/command_source');
const { EmbedBuilder } = require('discord.js'); const { EmbedBuilder } = require('discord.js');
async function command_manager (bot, options, config, discordClient) {
async function command_manager (context) {
const bot = context.bot;
const config = context.config;
const discordClient = context.discordClient;
const options = context.options;
bot.commandManager = { bot.commandManager = {
commands: {}, commands: {},
commandlist: [], commandlist: [],
@ -43,29 +48,45 @@ async function command_manager (bot, options, config, discordClient) {
] ]
})?.toAnsi()) })?.toAnsi())
} }
if (command?.data?.trustLevel > 0) {
const event = bot.discord.message; const event = bot.discord.message;
const roles = event?.member?.roles?.cache; const roles = event?.member?.roles?.cache;
if (command?.data?.trustLevel === 1 && !source?.sources?.discord) { switch (command?.data?.trustLevel) {
if (args.length === 0 && bot.validation.trusted && bot.validation.admin && bot.validation.owner && !source?.sources?.console) throw new CommandError({ text: "Please provide an trusted or an admin or an owner hash", color: "dark_red" }) case 0:
if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.admin && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or admin or owner hash', color: 'dark_red' }); // do nothing since trust level 0 is public
} else if (command?.data?.trustLevel === 1 && source?.sources.discord) { break;
const hasRole = roles?.some(role => role.name === `${config.discord.roles.trusted}` || role.name === `${config.discord.roles.owner}`) case 1:
if (source?.sources?.discord) {
const hasRole = roles?.some(role => role.name === `${config.discord.roles.trusted}` || role.name === `${config.discord.roles.admin}` || role.name === `${config.discord.roles.owner}`)
if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!', color: "dark_red" }) if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!', color: "dark_red" })
} else if (!source?.sources.console) {
if (args.length === 0) throw new CommandError({ text: "Please provide a trusted, admin or owner hash", color: "dark_red" });
if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.admin && args[0] !== bot.validation.owner) throw new CommandError({ translate: 'Invalid trusted, admin or owner hash', color: 'dark_red' });
} }
if (command?.data?.trustLevel === 2 && !source.sources.console) { break;
if (args.length === 0 && bot.validation.admin && bot.validation.owner && !source.sources.console) throw new CommandError({ text: "Please provide an trusted or owner hash", color: 'dark_red' }) case 2:
if (args[0] !== bot.validation.admin && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or owner hash', color: 'dark_red' }); if (source?.sources?.discord) {
const hasRole = roles?.some(role => role.name === `${config.discord.roles.admin}` || role.name === `${config.discord.roles.owner}`)
if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!', color: "dark_red" })
} else if (!source?.sources?.console) {
if (args.length === 0) throw new CommandError({ text: "Please provide an admin or owner hash", color: 'dark_red' })
if (args[0] !== bot.validation.admin && args[0] !== bot.validation.owner) throw new CommandError({ translate: 'Invalid admin or owner hash', color: 'dark_red' });
} }
if (command?.data?.trustLevel === 3 && !source.sources.discord && !source.sources.console) { break;
if (args.length === 0 && bot.validation.owner) throw new CommandError({ text: "Please provide an owner hash", color: "dark_red" }) case 3:
if (args[0] !== bot.validation.owner) throw new CommandError({ translate: 'Invalid owner hash', color: 'dark_red' }) if (source?.sources?.discord) {
} else if (command?.data?.trustLevel === 3 && source.sources.discord && !source.sources.console) {
const hasRole = roles?.some(role => role.name === `${config.discord.roles.owner}`) const hasRole = roles?.some(role => role.name === `${config.discord.roles.owner}`)
if (!hasRole) throw new CommandError({ translate: 'You are not the owner!', color: "dark_red" }) if (!hasRole) throw new CommandError({ translate: 'You are not the owner!', color: "dark_red" })
} else if (command?.data?.trustLevel === 4 && !source.sources.console) { } else if (!source?.sources?.console) {
throw new CommandError({ text: 'This command can only be ran via console', color: "dark_red" }); if (args.length === 0 && bot.validation.owner) throw new CommandError({ text: "Please provide an owner hash", color: "dark_red" })
if (args[0] !== bot.validation.owner) throw new CommandError({ translate: 'Invalid owner hash', color: 'dark_red' })
} }
break;
case 4:
if (!source?.sources?.console) {
throw new CommandError({ text: 'This command can only be ran via console', color: "dark_red" })
}
break;
} }
if (!command?.discordExecute && command && source?.sources?.discord) { if (!command?.discordExecute && command && source?.sources?.discord) {
throw new CommandError(`${command.name} command is not supported in discord!`) throw new CommandError(`${command.name} command is not supported in discord!`)
@ -81,7 +102,7 @@ async function command_manager (bot, options, config, discordClient) {
if (source?.sources?.discord && !source?.sources?.console) { if (source?.sources?.discord && !source?.sources?.console) {
const Embed = new EmbedBuilder() const Embed = new EmbedBuilder()
.setColor(`${config.colors.discord.error}`) .setColor(`${config.colors.discord.error}`)
.setTitle(`${command?.name} command`) .setTitle(`${command?.data?.name} command`)
.setDescription(`\`\`\`${error}\`\`\``) .setDescription(`\`\`\`${error}\`\`\``)
bot?.discord?.message?.reply({ bot?.discord?.message?.reply({
embeds: [ embeds: [

View file

@ -1,6 +1,10 @@
const CommandSource = require('../util/command_source'); const CommandSource = require('../util/command_source');
const prismarineChat = require('prismarine-chat')('1.20.2'); const prismarineChat = require('prismarine-chat')('1.20.2');
function Console (bot, options, config) {
function Console (context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
let ratelimit = 0; let ratelimit = 0;
bot.console = { bot.console = {
readline: null, readline: null,
@ -101,39 +105,9 @@ function Console (bot, options, config) {
bot.on('actionBar', (message) => { bot.on('actionBar', (message) => {
if (!options.logging) return; if (!options.logging) return;
if (ratelimit > 10) return if (ratelimit > 10) return
// bot.console.log(bot.getMessageAsPrismarine(message)?.toAnsi()); bot.console.log(bot.getMessageAsPrismarine(message)?.toAnsi());
bot.console.fileLogger(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ${bot.getMessageAsPrismarine(message)?.toString()}`); bot.console.fileLogger(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ${bot.getMessageAsPrismarine(message)?.toString()}`);
ratelimit++ ratelimit++
}) })
/*
setInterval(() => spamCount = 0, 1000 * 2)
bot.on('message', message => {
if (spamCount > 300) {
console.log('WTF spam detected not logging')
return
}
const ansi = bot.getMessageAsPrismarine(message)?.toAnsi()
const string = bot.getMessageAsPrismarine(message)?.toString()
const now = new Date().toLocaleString()
spamCount++
*/
/* bot.on('message', (message) => {
rateLimit++
setTimeout(() => {
rateLimit--
}, 1000)
if (!options.logging) return;
if (rateLimit > 100) {
return
}
bot.console.log(bot.getMessageAsPrismarine(message)?.toAnsi());
bot.console.fileLogger(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ${bot.getMessageAsPrismarine(message)?.toString()}`);
})*/
} }
module.exports = Console; module.exports = Console;

View file

@ -6,8 +6,11 @@ const CommandSource = require('../util/command_source')
//const client = new Client({ intents: [Guilds, GuildMessages, MessageContent] }) //const client = new Client({ intents: [Guilds, GuildMessages, MessageContent] })
const util = require('util') const util = require('util')
function discord (context) {
function discord(bot, options, config, discordClient) { const bot = context.bot;
const config = context.config;
const discordClient = context.discordClient;
const options = context.options;
if (!options?.channelId) { if (!options?.channelId) {
bot.discord = { bot.discord = {
invite: config.discord?.invite invite: config.discord?.invite
@ -82,7 +85,7 @@ function discord(bot, options, config, discordClient) {
if (message.content.startsWith(config.discord.prefix)) { // TODO: Don't hardcode this if (message.content.startsWith(config.discord.prefix)) { // TODO: Don't hardcode this
const source = new CommandSource({ const source = new CommandSource({
profile: { profile: {
name: message?.member?.displayName name: `${message?.member.nickname || message?.author.displayName}`
} }
}, { }, {
discord: true, discord: true,
@ -132,7 +135,7 @@ function discord(bot, options, config, discordClient) {
} }
}, },
{ {
text: message?.member?.displayName text: `${message.member.nickname || message.author.displayName}`,
}, },
message.content message.content
] ]

View file

@ -3,7 +3,10 @@ const path = require("path");
const { createGzip } = require("zlib"); const { createGzip } = require("zlib");
const readline = require('readline'); const readline = require('readline');
const { Console } = require("console"); const { Console } = require("console");
function fileLogger(bot, options, message) { function fileLogger(context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
const currentDate = new Date(); const currentDate = new Date();
const timestamp = `${currentDate.getFullYear()}-${(currentDate.getMonth() + 1) const timestamp = `${currentDate.getFullYear()}-${(currentDate.getMonth() + 1)
.toString() .toString()

37
src/modules/memusage.js Normal file
View file

@ -0,0 +1,37 @@
const os = require('os');
module.exports = (context) => {
const bot = context.bot;
const config = context.config;
let timer;
bot.memUsage = {
enabled: false
}
timer = setInterval(() => {
component = {
translate: "%s%s%s %s | %s: %s%s / %s%s | %s: %s%s / %s%s |",
color: config.colors.commands.tertiary,
with: [
{ text: "FNF", color: "dark_blue" },
{ text: "Boyfriend", color: "dark_aqua" },
{ text: "Bot", color: "blue" },
{ text: "Memory Usage" },
{ text: "Free Server Memory", color: config.colors.commands.primary },
{ text: `${Math.floor(os.freemem() / 1048576)}`, color: config.colors.integer },
{ text: "MiB", color: config.colors.commands.secondary },
{ text: `${Math.floor(os.totalmem() / 1048576)}`, color: config.colors.integer },
{ text: "MiB", color: config.colors.commands.secondary },
{ text: "Bot Memory Usage", 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 }
]
}
if (!bot.memUsage.enabled) return;
bot.core.run(`minecraft:title @a[tag=!memusage] actionbar ${JSON.stringify(component)}`)
}, 100)
bot.on('end', () => {
bot.memUsage.enabled = false;
})
}

View file

@ -1,4 +1,7 @@
function player_list (bot, options, config) { function player_list (context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
bot.players = [] bot.players = []
bot.on('packet.player_info', async (packet) => { bot.on('packet.player_info', async (packet) => {

View file

@ -1,4 +1,6 @@
function position (bot, options, config) {
function position (context) {
const bot = context.bot;
bot.position = null bot.position = null
bot.on('packet.position', packet => { bot.on('packet.position', packet => {

View file

@ -1,6 +1,9 @@
const mc = require('minecraft-protocol'); const mc = require('minecraft-protocol');
const usernameGen = require("../util/usernameGen"); const usernameGen = require("../util/usernameGen");
function reconnect (bot, options, config) { function reconnect (context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
bot.on('end', () => { bot.on('end', () => {
//bot = undefined; //bot = undefined;

View file

@ -1,4 +1,7 @@
function selfcare (bot, options, config) { function selfcare (context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
let entityId; let entityId;
let permissionLevel = 2; let permissionLevel = 2;
let unmuted = false; let unmuted = false;
@ -62,7 +65,7 @@ You already have registered this username!
else if (stringMessage?.startsWith("Successfully set your username to ")) username = true else if (stringMessage?.startsWith("Successfully set your username to ")) username = true
else if (stringMessage === `You already have the username "${bot.username}"`) username = false else if (stringMessage === `You already have the username "${bot.username}"`) username = false
else if (stringMessage === `You no longer have a nickname.`) nickname = false; else if (stringMessage === `You no longer have a nickname.`) nickname = false;
else if (stringMessage.startsWith('Your nickname is now ')) nickname = true; else if (stringMessage?.startsWith('Your nickname is now ')) nickname = true;
} }
}) })

View file

@ -1,4 +1,6 @@
module.exports = (bot) => {
module.exports = (context) => {
const bot = context.bot;
// let aaa cook // let aaa cook
bot.tab_complete = (str) => { bot.tab_complete = (str) => {
return new Promise((resolve) => { return new Promise((resolve) => {
@ -7,7 +9,6 @@ module.exports = (bot) => {
}) })
const tab_completeH = (packet) => { const tab_completeH = (packet) => {
bot._client.removeListener('tab_complete', tab_completeH) bot._client.removeListener('tab_complete', tab_completeH)
resolve(packet.matches) resolve(packet.matches)
} }
bot._client.once('tab_complete', tab_completeH) bot._client.once('tab_complete', tab_completeH)

View file

@ -1,5 +1,7 @@
const crypto = require('crypto') const crypto = require('crypto')
function validation (bot, options, config) { function validation (context) {
const bot = context.bot;
const config = context.config;
setInterval(() => { setInterval(() => {
bot.validation = { bot.validation = {
trusted: crypto.createHash('sha256').update(Math.floor(Date.now() / 1000) + config.keys.trusted).digest('hex').substring(0, 16), trusted: crypto.createHash('sha256').update(Math.floor(Date.now() / 1000) + config.keys.trusted).digest('hex').substring(0, 16),

View file

@ -15,55 +15,6 @@ function ansi (message) {
'\x1B[4m': "\x1B[24m", // underline '\x1B[4m': "\x1B[24m", // underline
'\x1B[9m': "\x1B[29m", // strike through '\x1B[9m': "\x1B[29m", // strike through
'\x1B[6m': "\x1B[29m" // obfuscated '\x1B[6m': "\x1B[29m" // obfuscated
/*
Black 30 40
Red 31 41
Green 32 42
Yellow 33 43
Blue 34 44
Magenta 35 45
Cyan 36 46
White 37 47
Default 39 49
Reset 0 0
ESC[1;34;{...}m Set graphics modes for cell, separated by semicolon (;).
ESC[0m reset all modes (styles and colors)
ESC[1m ESC[22m set bold mode.
ESC[2m ESC[22m set dim/faint mode.
ESC[3m ESC[23m set italic mode.
ESC[4m ESC[24m set underline mode.
ESC[5m ESC[25m set blinking mode
ESC[7m ESC[27m set inverse/reverse mode
ESC[8m ESC[28m set hidden/invisible mode
ESC[9m ESC[29m set strikethrough mode.
*/
/*
const defaultAnsiCodes = {
'§0': '\u001b[30m',
'§1': '\u001b[34m',
'§2': '\u001b[32m',
'§3': '\u001b[36m',
'§4': '\u001b[31m',
'§5': '\u001b[35m',
'§6': '\u001b[33m',
'§7': '\u001b[37m',
'§8': '\u001b[90m',
'§9': '\u001b[94m',
'§a': '\u001b[92m',
'§b': '\u001b[96m',
'§c': '\u001b[91m',
'§d': '\u001b[95m',
'§e': '\u001b[93m',
'§f': '\u001b[97m',
'§l': '\u001b[1m',
'§o': '\u001b[3m',
'§n': '\u001b[4m',
'§m': '\u001b[9m',
'§k': '\u001b[6m',
'§r': '\u001b[0m'
}
*/
}; };
let i = message; let i = message;

View file

@ -9,11 +9,11 @@ module.exports = () => {
) )
} }
if (!fs.existsSync(path.join(__dirname, "../data/filter.json"))) { /* if (!fs.existsSync(path.join(__dirname, "../data/filter.json"))) {
console.warn("filter json not found creating the file,......"); console.warn("filter json not found creating the file,......");
let data = [{ ignoreCase: false, regexed: false, name: 'whatever player username idfk' }] let data = [{ ignoreCase: false, regexed: false, name: 'whatever player username idfk' }]
fs.writeFileSync(path.join(__dirname, "../data/filter.json"), JSON.stringify(data)) fs.writeFileSync(path.join(__dirname, "../data/filter.json"), JSON.stringify(data))
} }*/
/* /*
if (!fs.existsSync(path.join(__dirname, "../data/trustedPlayers.json"))) { if (!fs.existsSync(path.join(__dirname, "../data/trustedPlayers.json"))) {

View file

@ -1,38 +1,19 @@
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
async function loadModules (bot, options, config, discordClient) { async function loadModules (bot, options, config, discordClient) {
// let module
bot.loadModule = module => module(bot, options, config, discordClient)
for (const filename of fs.readdirSync(path.join(__dirname, '../', 'modules'))) { for (const filename of fs.readdirSync(path.join(__dirname, '../', 'modules'))) {
try { try {
if (filename.endsWith(".mjs")) { if (filename.endsWith(".js")) {
// const module = await import(path.join(__dirname, '../', 'modules', filename)); const module = require(path.join(__dirname, '../modules', filename));
// bot.loadModule(module); module({ bot, options, config, discordClient });
} else if (filename.endsWith(".js")) { } if (filename.endsWith(".mjs")) {
const module = require(path.join(__dirname, '../', 'modules', filename)); const module = await import(path.join(__dirname, '../modules', filename));
bot.loadModule(module); module.default(bot, options, config, discordClient);
} }
//bot.loadModule(module)
} catch (error) { } catch (error) {
console.error('Failed to load module', filename, ':', error) console.error(`Failed to load module ${filename} due to error`);
console.error(`\x1b[31m${error.stack}\x1b[0m`);
} }
} }
} }
module.exports = loadModules; module.exports = loadModules;
/*
for (const filename of fs.readdirSync(path.join(__dirname, '../commands'))) {
try {
if (filename.endsWith('.mjs')) {
let commands = await import(path.join(__dirname, '../commands', filename))
bot.commandManager.register(commands.command);
bot.commandManager.commandlist.push(commands.command);
} if (filename.endsWith('.js')) {
let commands = require(path.join(__dirname, '../commands', filename));
bot.commandManager.register(commands);
bot.commandManager.commandlist.push(commands);
}
} catch (error) {
console.error('Failed to load command', filename, ':', error)
}
}
*/