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",
"version": "v6.1.1",
"lockfileVersion": 3,
"requires": true,
"build": "1145",
"codename": "",
"url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot",
"buildstring": {
"version": "v6.1.2",
"build": "1200",
"releaseDate": "11/22/24",
"codename": "§eHazardous §4Massacre",
"url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot"
},
"packages": {
"": {
"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>",
],
},
async execute (context) {
execute (context) {
const bot = context.bot
const message = context.arguments.join(' ');
bot.core.run(message);
await sleep(45);
bot.core.runTracked(message);
/* bot.on('commandBlockOutput', (packet) => {
bot.tellraw("@a", require('util').inspect(packet));
console.log(packet);

View file

@ -46,7 +46,7 @@ module.exports = {
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.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}`,
translate: "",
hoverEvent: {
@ -57,7 +57,7 @@ module.exports = {
},
clickEvent: {
action: "open_url",
value: `${botInfo.url}`
value: `${botInfo.buildstring.url}`
}
})
break;
@ -153,7 +153,7 @@ module.exports = {
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",
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" },
@ -166,7 +166,8 @@ module.exports = {
{ text: "aaa", color: "gold" },
{ text: "Morgan", color: "green" },
{ text: "Ankan", color: "dark_green" },
{ text: "TurtleKid", color: "green" }
{ text: "TurtleKid", color: "green" },
{ text: "Ploat/ImGloriz", color: "#cd8ccb" },
]
})
break;
@ -191,6 +192,7 @@ module.exports = {
})
break;
case "usages":
case "usage":
switch (args.slice(1).join(' ')?.toLowerCase()) {
case "bot":
component.push({
@ -310,26 +312,7 @@ module.exports = {
case "version":
case "ver":
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({
translate: "%s %s %s-%s-%s%s-%s\n%s - %s",
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: "Boyfriend", color: "dark_aqua" },
{ text: "Bot", color: "blue" },
{ text: `${botInfo.version}`, color: config.colors.integer },
{ text: `${botInfo.buildstring.version}`, color: config.colors.integer },
{ text: "#" },
{ text: `${botInfo.build}`, color: config.colors.integer },
{ text: `${botInfo.codename}` },
{ text: `${botInfo.buildstring.build}`, color: config.colors.integer },
{ 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: `${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 CommandError = require('../../util/command_error')
const { EmbedBuilder } = require('discord.js')
const wiki = require('wikipedia');
const CommandError = require('../../util/command_error');
const { EmbedBuilder } = require('discord.js');
module.exports = {
data: {
name: 'wiki',
@ -10,23 +10,23 @@ module.exports = {
'wikipedia'
],
usages:[
"<definition>"
"<article>"
],
},
async execute (context) {
const source = context.source
const args = context.arguments
const bot = context.bot
const source = context.source;
const args = context.arguments;
const bot = context.bot;
try {
const page = await wiki.page(args.join(' '))
const summary = await page.intro();
bot.tellraw(`@a`, { text: `${summary}`, color: 'gray' });
} catch (error) {
if (error.toString() === "pageError: TypeError: Cannot read properties of undefined (reading 'pages')") {
bot.tellraw(`@a`, { text: 'Definition not found!', color: 'dark_red' })
} else {
bot.tellraw(`@a`, `${error.toString()}`)
}
if (error.toString() === "pageError: TypeError: Cannot read properties of undefined (reading 'pages')") {
bot.tellraw(`@a`, { text: 'Article not found!', color: 'dark_red' })
} else {
bot.tellraw(`@a`, `${error.toString()}`)
}
}
}
}

View file

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

View file

@ -1,17 +1,21 @@
prefixes:
- "!"
discord:
token: "discord token here"
prefix: "!"
invite: "discord invite here"
enabled: true
roles:
trusted: "trusted"
admin: "admin"
owner: "FNFBoyfriendBot Owner"
core:
# core refill methods:
# chat: refill core in chat
# item refill core in a command block placed by the bot
name: {"translate":"outOfMemory.message"}
method: 'item'
area:
start:
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 discordClient = new Client({ intents: [Guilds, GuildMessages, MessageContent] });
console.log('Starting FNFBoyfriendBot');
process.stdout.write('\x1b]2;Starting FNFBoyfriendBot please wait,.....\x1b\x5c')
checks();
try {
@ -16,10 +17,15 @@ try {
} catch (e) {
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({
input: process.stdin,
output: process.stdout,
})
//console.log(completion);
if (config.discord.enabled) discordClient.login(config.discord.token);
const 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) => {
if (bot.options.isCreayun) return
if (new Date().getDay() === 5) {
@ -6,7 +10,9 @@ function boot (bot, options, discordClient, config) {
} else {
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;

View file

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

View file

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

View file

@ -1,5 +1,9 @@
function core (bot, options, config) {
let number = 0;
const mcData = require('minecraft-data')('1.20.2');
function core (context) {
const bot = context.bot;
const config = context.config;
const options = context.options;
bot.core = {
area: {
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
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) {
@ -76,15 +124,61 @@ function core (bot, options, config) {
} else {
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.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
bot.on('move', () => {
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;

View file

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

View file

@ -3,7 +3,12 @@ const path = require('path');
const CommandError = require('../util/command_error.js');
const CommandSource = require('../util/command_source');
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 = {
commands: {},
commandlist: [],
@ -43,29 +48,45 @@ async function command_manager (bot, options, config, discordClient) {
]
})?.toAnsi())
}
if (command?.data?.trustLevel > 0) {
const event = bot.discord.message;
const roles = event?.member?.roles?.cache;
if (command?.data?.trustLevel === 1 && !source?.sources?.discord) {
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" })
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' });
} else if (command?.data?.trustLevel === 1 && source?.sources.discord) {
const hasRole = roles?.some(role => role.name === `${config.discord.roles.trusted}` || role.name === `${config.discord.roles.owner}`)
const event = bot.discord.message;
const roles = event?.member?.roles?.cache;
switch (command?.data?.trustLevel) {
case 0:
// do nothing since trust level 0 is public
break;
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 (command?.data?.trustLevel === 2 && !source.sources.console) {
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' })
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 (command?.data?.trustLevel === 3 && !source.sources.discord && !source.sources.console) {
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' })
} else if (command?.data?.trustLevel === 3 && source.sources.discord && !source.sources.console) {
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" })
} else if (command?.data?.trustLevel === 4 && !source.sources.console) {
throw new CommandError({ text: 'This command can only be ran via console', 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' });
}
break;
case 2:
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' });
}
break;
case 3:
if (source?.sources?.discord) {
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" })
} else if (!source?.sources?.console) {
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) {
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) {
const Embed = new EmbedBuilder()
.setColor(`${config.colors.discord.error}`)
.setTitle(`${command?.name} command`)
.setTitle(`${command?.data?.name} command`)
.setDescription(`\`\`\`${error}\`\`\``)
bot?.discord?.message?.reply({
embeds: [

View file

@ -1,6 +1,10 @@
const CommandSource = require('../util/command_source');
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;
bot.console = {
readline: null,
@ -101,39 +105,9 @@ function Console (bot, options, config) {
bot.on('actionBar', (message) => {
if (!options.logging) 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()}`);
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;

View file

@ -6,8 +6,11 @@ const CommandSource = require('../util/command_source')
//const client = new Client({ intents: [Guilds, GuildMessages, MessageContent] })
const util = require('util')
function discord(bot, options, config, discordClient) {
function discord (context) {
const bot = context.bot;
const config = context.config;
const discordClient = context.discordClient;
const options = context.options;
if (!options?.channelId) {
bot.discord = {
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
const source = new CommandSource({
profile: {
name: message?.member?.displayName
name: `${message?.member.nickname || message?.author.displayName}`
}
}, {
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
]

View file

@ -3,7 +3,10 @@ const path = require("path");
const { createGzip } = require("zlib");
const readline = require('readline');
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 timestamp = `${currentDate.getFullYear()}-${(currentDate.getMonth() + 1)
.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.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.on('packet.position', packet => {

View file

@ -1,6 +1,9 @@
const mc = require('minecraft-protocol');
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 = 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 permissionLevel = 2;
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 === `You already have the username "${bot.username}"`) username = 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,16 +1,17 @@
module.exports = (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 = (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)
})
}
}

View file

@ -1,5 +1,7 @@
const crypto = require('crypto')
function validation (bot, options, config) {
function validation (context) {
const bot = context.bot;
const config = context.config;
setInterval(() => {
bot.validation = {
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[9m': "\x1B[29m", // strike through
'\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;

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,......");
let data = [{ ignoreCase: false, regexed: false, name: 'whatever player username idfk' }]
fs.writeFileSync(path.join(__dirname, "../data/filter.json"), JSON.stringify(data))
}
}*/
/*
if (!fs.existsSync(path.join(__dirname, "../data/trustedPlayers.json"))) {

View file

@ -1,38 +1,19 @@
const fs = require("fs");
const path = require("path");
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'))) {
try {
if (filename.endsWith(".mjs")) {
// const module = await import(path.join(__dirname, '../', 'modules', filename));
// bot.loadModule(module);
} else if (filename.endsWith(".js")) {
const module = require(path.join(__dirname, '../', 'modules', filename));
bot.loadModule(module);
if (filename.endsWith(".js")) {
const module = require(path.join(__dirname, '../modules', filename));
module({ bot, options, config, discordClient });
} if (filename.endsWith(".mjs")) {
const module = await import(path.join(__dirname, '../modules', filename));
module.default(bot, options, config, discordClient);
}
//bot.loadModule(module)
} 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;
/*
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)
}
}
*/