Compare commits

..

3 commits
v6.1.4 ... main

19 changed files with 293 additions and 192 deletions

4
package-lock.json generated
View file

@ -3,8 +3,8 @@
"lockfileVersion": 3,
"requires": true,
"buildstring": {
"version": "v6.1.4",
"build": "1215",
"version": "v6.1.5",
"build": "1225",
"codename": "",
"url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot"
},

View file

@ -20,13 +20,17 @@ module.exports = {
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.useChat || bot.options.isSavage) {
bot.chat.message(bot.getMessageAsPrismarine({ text: util.inspect(eval(script), { stylize }).substring(0, 32700) })?.toMotd().replaceAll('§','&'))
} else {
bot.tellraw(`@a[name="${source.player.profile.name}"]`, [
bot.tellraw(`@a[name="${source.player.profile.name}"]`, new MessageBuilder()
.setText(util.inspect(eval(script), { stylize }).substring(0, 32700))
)
/* bot.tellraw(`@a[name="${source.player.profile.name}"]`, [
{
text: util.inspect(eval(script), { stylize }).substring(0, 32700),
hoverEvent: {
@ -41,7 +45,7 @@ module.exports = {
value: `${script}`
}
}
]);
]);*/
}
} catch (e) {
throw new CommandError(e.toString())

View file

@ -358,6 +358,10 @@ module.exports = {
default:
throw new CommandError({ translate: "command.unknown.argument", color: "dark_red" });
}
bot.tellraw(`@a[name="${source.player.profile.name}"]`, component);
if (bot.options.isSavage) {
bot.chat.message(bot.getMessageAsPrismarine(component)?.toMotd().replaceAll('§','&'));
} else {
bot.tellraw(`@a[name="${source.player.profile.name}"]`, component);
}
},
}

View file

@ -44,49 +44,15 @@ module.exports = {
server.description
]
})
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, component);
/* bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [
{
text: `Ip \u203a ${host}:${Number(port ?? 25565)}\n`,
color: 'gray',
hoverEvent: {
action: 'show_text',
contents: [{
text: 'click here for the servers ip',
color: 'gray'
}]
},
clickEvent: {
action: 'copy_to_clipboard',
value: `${host}:${Number(port ?? 25565)}`
}
},
{
text: `Players \u203a `,
color: 'gray'
},
{
text: `${server.players.online}`,
color: "gold"
},
{
text: ' / ',
color: 'gray'
},
{
text: `${server.players.max}\n`,
color: "gold"
},
{
text: `Version \u203a ${server.version.name}\n`,
color: 'gray',
},
{
text: "Motd \u203a\n",
color: 'gray',
},
server.description,
])*/
if (bot.options.isSavage) {
bot.chat.message(`Ip \u203a ${host}:${Number(port ?? 25565)}`);
bot.chat.message(`Players \u203a ${server.players.online} / ${server.players.max}`);
bot.chat.message(`Version \u203a ${server.version.name}`);
bot.chat.message(bot.getMessageAsPrismarine(server.description)?.toMotd().replaceAll('§','&'));
} else {
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, component);
}
} catch (e) {
bot.chat.message(`${e.toString()}`)
}

View file

@ -39,20 +39,14 @@ module.exports = {
}
}
bot.bots.filter((eachBot) => {
if (eachBot.options.isSavage && !eachBot.options.useChat && !eachBot.options.isKaboom || eachBot.options.isCreayun && !eachBot.options.isSavage && !eachBot.options.useChat && !eachBot.options.isKaboom) {
eachBot.chat.message(`[${bot.options.serverName}] ${bot.getMessageAsPrismarine(source.player.displayName ?? source.player.profile.name)?.toMotd().replaceAll('§','&')} \u203a ${args.join(' ')}`)
} else if (!eachBot.options.serverName !== "Savage Friends" && !eachBot.options.isSavage && !eachBot.options.useChat && eachBot.options.isKaboom) {
eachBot.tellraw("@a", component);
} else if (!eachBot.options.serverName !== "Savage Friends" && !eachBot.options.isSavage && eachBot.options.useChat && eachBot.options.isKaboom) {
eachBot.chat.message(`&7[&7${bot.options.serverName}&7] ${bot.getMessageAsPrismarine(source.player.displayName ?? source.player.profile.name)?.toMotd().replaceAll('§','&')} &7\u203a ${args.join(' ')}`)
} else if (eachBot.options.useChat && !eachBot.options.isSavage) {
// eachBot.chat.message(bot.getMessageAsPrismarine(`[${bot.options.host}:${bot.options.port}] ${source.player.displayName ?? source.player.profile.name} \u203a ${args.join(' ')}`)?.toMotd().replaceAll('§','&'))
eachBot.chat.message(`&7[&7${bot.options.serverName}&7] ${bot.getMessageAsPrismarine(source.player.displayName ?? source.player.profile.name)?.toMotd().replaceAll('§','&')} &7\u203a ${args.join(' ')}`)
} else if (!eachBot.options.useChat && !eachBot.options.isSavage) {
if (!eachBot.options.isKaboom || eachBot.options.useChat) {
eachBot.chat.message(`${bot.getMessageAsPrismarine(component)?.toMotd().replaceAll('§','&')}`);
} else if (eachBot.options.isKaboom && !eachBot.options.useChat) {
eachBot.tellraw("@a", component);
}
})
},
discordExecute (context) {
const bot = context.bot;
const args = context.arguments;
@ -80,15 +74,9 @@ module.exports = {
}
}
bot.bots.filter((eachBot) => {
if (eachBot.options.serverName === "Savage Friends" && eachBot.options.isSavage && !eachBot.options.useChat && !eachBot.options.isKaboom) {
eachBot.chat.message(`[${bot.options.serverName}] ${bot.getMessageAsPrismarine(source.player.displayName ?? source.player.profile.name)?.toMotd().replaceAll('§','&')} \u203a ${args.join(' ')}`)
} else if (!eachBot.options.serverName !== "Savage Friends" && !eachBot.options.isSavage && !eachBot.options.useChat && eachBot.options.isKaboom) {
eachBot.tellraw("@a", component);
} else if (!eachBot.options.serverName !== "Savage Friends" && !eachBot.options.isSavage && eachBot.options.useChat && eachBot.options.isKaboom) {
eachBot.chat.message(`&7[&7${bot.options.serverName}&7] ${bot.getMessageAsPrismarine(source.player.displayName ?? source.player.profile.name)?.toMotd().replaceAll('§','&')} &7\u203a ${args.join(' ')}`)
} else if (eachBot.options.useChat && !eachBot.options.isSavage) {
eachBot.chat.message(`&7[&7${bot.options.serverName}&7] ${bot.getMessageAsPrismarine(source.player.displayName ?? source.player.profile.name)?.toMotd().replaceAll('§','&')} &7\u203a ${args.join(' ')}`)
} else if (!eachBot.options.useChat && !eachBot.options.isSavage) {
if (!eachBot.options.isKaboom || eachBot.options.useChat) {
eachBot.chat.message(`${bot.getMessageAsPrismarine(component)?.toMotd().replaceAll('§','&')}`);
} else if (eachBot.options.isKaboom && !eachBot.options.useChat) {
eachBot.tellraw("@a", component);
}
})

View file

@ -16,43 +16,146 @@ module.exports = {
const args = context.arguments;
const config = context.config;
const source = context.source;
const { MessageBuilder } = require('prismarine-chat')(bot.options.version);
try {
let component = [];
const weather = await request(`https://api.weatherapi.com/v1/current.json?key=${config.weatherApiKey}&q=${args.join(' ')?.replaceAll(' ', ',')}`);
let component;
const weather = await request(`https://api.weatherapi.com/v1/current.json?key=${config.weatherApiKey}&q=${args.join(' ').replaceAll(' ','&')}`);
const info = await weather.body.json();
component.push({
translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s%s (%s%s)\n%s: %s %s %s (%s %s %s)\n%s: %s\n%s: %s",
color: config.colors.commands.tertiary,
with: [
{ text: "Location", color: config.colors.commands.primary },
{ text: `${info.location.name}, ${info.location.region}, ${info.location.country}`, color: config.colors.commands.secondary },
{ text: "Latitude", color: config.colors.commands.primary },
{ text: `${info.location.lat}`, color: config.colors.integer },
{ text: "Longitude", color: config.colors.commands.primary },
{ text: `${info.location.lon}`, color: config.colors.integer },
{ text: "Time zone", color: config.colors.commands.primary },
{ text: `${info.location.tz_id}`, color: config.colors.commands.secondary },
{ text: "Time", color: config.colors.commands.primary },
{ text: `${new Date().toLocaleTimeString("en-US", { timeZone: info.location.tz_id, })}`, color: config.colors.integer },
{ text: "Temp", color: config.colors.commands.primary },
{ text: `${info.current.temp_c}`, color: config.colors.integer },
{ text: "\u00b0C", color: config.colors.commands.secondary },
{ text: `${info.current.temp_f}`, color: config.colors.integer },
{ text: "\u00b0F", color: config.colors.commands.secondary },
{ text: "Wind speed" , color: config.colors.commands.primary },
{ text: `${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: `${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: `${info.current.humidity}`, color: config.colors.integer },
]
})
bot.tellraw("@a", component)
component = new MessageBuilder()
.setTranslate("%s\n%s\n%s: %s (%s)\n%s\n%s\n%s: %s\n%s: %s")
.setColor(config.colors.commands.tertiary)
.addWith(new MessageBuilder()
.setTranslate("%s: %s, %s %s")
.setColor(config.colors.commands.tertiary)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.primary)
.setText("Location")
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText(info.location.name)
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText(info.location.region)
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText(info.location.country)
)
)
.addWith(new MessageBuilder()
.setTranslate("%s: %s, %s")
.setColor(config.colors.commands.tertiary)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.primary)
.setText("Coords")
)
.addWith(new MessageBuilder()
.setColor(config.colors.integer)
.setText(`${info.location.lat}`)
)
.addWith(new MessageBuilder()
.setColor(config.colors.integer)
.setText(`${info.location.lon}`)
)
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.primary)
.setText("Time")
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText(`${new Date().toLocaleTimeString("en-US", { timeZone: info.location.tz_id, })}`)
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText(`${info.location.tz_id}`)
)
.addWith(new MessageBuilder()
.setTranslate("%s: %s (%s), %s (%s)")
.setColor(config.colors.commands.tertiary)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.primary)
.setText("Temp")
)
.addWith(new MessageBuilder()
.setColor(config.colors.integer)
.setText(`${Math.floor(info.current.temp_c)}`)
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText("\u00b0C")
)
.addWith(new MessageBuilder()
.setColor(config.colors.integer)
.setText(`${Math.floor(info.current.temp_f)}`)
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText("\u00b0F")
)
)
.addWith(new MessageBuilder()
.setTranslate("%s: %s (%s, %s), %s (%s, %s)")
.setColor(config.colors.commands.tertiary)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.primary)
.setText("Wind Speed")
)
.addWith(new MessageBuilder()
.setColor(config.colors.integer)
.setText(`${Math.floor(info.current.wind_kph)}`)
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText("kph")
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText(info.current.wind_dir)
)
.addWith(new MessageBuilder()
.setColor(config.colors.integer)
.setText(`${Math.floor(info.current.wind_mph)}`)
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText("mph")
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText(info.current.wind_dir)
)
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.primary)
.setText("Condition")
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText(info.current.condition.text)
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.primary)
.setText("Humidity")
)
.addWith(new MessageBuilder()
.setColor(config.colors.integer)
.setText(`${Math.floor(info.current.humidity)}`)
)
if (bot.options.isSavage) {
bot.chat.message(`Location: ${info.location.name}, ${info.location.region}, ${info.location.country}`);
bot.chat.message(`Latitude: ${info.location.lat}`);
bot.chat.message(`Longitude: ${info.location.lon}`);
bot.chat.message(`Time: ${new Date().toLocaleTimeString("en-US", { timeZone: info.location.tz_id, })}(${info.location.tz_id})`);
bot.chat.message(`Temp: ${info.current.temp_c}(\u00b0C), ${info.current.temp_f}(\u00b0F)`);
bot.chat.message(`Wind speed: ${info.current.wind_kph}(KPH), ${info.current.wind_mph}(MPH)`);
bot.chat.message(`Condition: ${info.current.condition.text}`);
bot.chat.message(`Humidity: ${info.current.humidity}`);
} else {
bot.tellraw("@a", component);
}
} catch (e) {
if (e.toString() === "TypeError: Cannot read properties of undefined (reading 'name')" && args.length !== 0) {
bot.chat.message('The location is invalid please try a valid location');

View file

@ -17,13 +17,20 @@ module.exports = {
const source = context.source;
const args = context.arguments;
const bot = context.bot;
const { MessageBuilder } = require('prismarine-chat')(bot.options.version);
try {
const page = await wiki.page(args.join(' '))
const summary = await page.intro();
bot.tellraw(`@a`, { text: `${summary}`, color: 'gray' });
bot.tellraw("@a", new MessageBuilder()
.setText(summary)
.setColor("gray")
)
} catch (error) {
if (error.toString() === "pageError: TypeError: Cannot read properties of undefined (reading 'pages')") {
bot.tellraw(`@a`, { text: 'Article not found!', color: 'dark_red' })
bot.tellraw("@a", new MessageBuilder()
.setText("Article not found!")
.setColor("red")
)
} else {
bot.tellraw(`@a`, `${error.toString()}`)
}

View file

@ -78,6 +78,11 @@ colors:
console:
prefix: "c."
logsFolder:
path: "../../"
# this is being loaded from the log folder so make sure it starts with ../../
name: "logs"
bots:
- host: "localhost"
username: "FNFBoyfriendBot"

View file

@ -1,19 +1,25 @@
const createBot = require('./bot.js');
const readline = require('readline');
const loadModules = require('./util/loadModules');
const js_yaml = require('js-yaml');
const fs = require('fs');
const path = require('path');
const { Client, GatewayIntentBits } = require('discord.js');
const { MessageContent, GuildMessages, Guilds } = GatewayIntentBits;
const discordClient = new Client({ intents: [Guilds, GuildMessages, MessageContent] });
require('./util/checks')();
console.log('Starting FNFBoyfriendBot');
process.stdout.write('\x1b]2;Starting FNFBoyfriendBot please wait,.....\x1b\x5c');
if (!fs.existsSync(path.join(__dirname, "../config.yml"))) {
console.warn("Config not found creating config from the default config");
fs.copyFileSync(
path.join(__dirname, "./data/default_config.yml"),
path.join(__dirname, "../config.yml")
)
}
try {
config = js_yaml.load(fs.readFileSync(path.join(__dirname, '../', 'config.yml')))
config = require('js-yaml').load(fs.readFileSync(path.join(__dirname, '../', 'config.yml')))
} catch (e) {
console.log(e.stack);
}
@ -29,6 +35,6 @@ for (const options of config.bots) {
const bot = new createBot(options, config);
bots.push(bot);
bot.bots = bots;
loadModules(bot, options, config, discordClient);
require('./util/loadModules')(bot, options, config, discordClient);
bot.console.readlineInterface(rl);
}

View file

@ -89,9 +89,11 @@ function chat (context) {
return
}
bot.emit('systemChat', message)
if (message.translate === "advMode.notAllowed") return;
tryParsingMessage(message, { players: bot.players, getMessageAsPrismarine: bot.getMessageAsPrismarine })
bot.emit('systemChat', message);
tryParsingMessage(message, { players: bot.players, getMessageAsPrismarine: bot.getMessageAsPrismarine });
})
bot.on('packet.action_bar', (message) => {
@ -165,8 +167,9 @@ function chat (context) {
acknowledged: Buffer.alloc(3),
previousMessages: []
})
}
},
}
bot.tellraw = (selector, message) => {
bot.core.run(`minecraft:tellraw ${selector} ` + JSON.stringify(message))
}

View file

@ -49,11 +49,7 @@ function core (context) {
bot.chat.command('spawn');
return
}
/*^^^
for checking is the core pos is null and if so
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
*/
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`
bot._client.write('set_creative_slot', {
@ -185,13 +181,7 @@ function core (context) {
})
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

@ -4,6 +4,7 @@ module.exports = (context) => {
const bot = context.bot;
const config = context.config;
const options = context.options;
const { MessageBuilder } = require('prismarine-chat')(bot.options.version);
bot.on("parsed_message", (data) => {
if (data.type !== "minecraft:chat") return;
const prefixes = config.prefixes;
@ -16,8 +17,9 @@ module.exports = (context) => {
setTimeout(() => {
ratelimit--
}, 1000)
if (ratelimit > 2) {
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, { text: 'You are using commands too fast!', color: 'dark_red'})
if (ratelimit > 2) { // new e.MessageBuilder().setText("e").toJSON()
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, new MessageBuilder().setText("You are using commands too fast!").setColor("dark_red").toJSON())
// bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, { text: 'You are using commands too fast!', color: 'dark_red'})
} else if (command.split(" ")[0].length === 0) {
} else {
bot.commandManager.executeString(source, command)

View file

@ -9,6 +9,7 @@ async function command_manager (context) {
const config = context.config;
const discordClient = context.discordClient;
const options = context.options;
const { MessageBuilder } = require('prismarine-chat')(bot.options.version);
bot.commandManager = {
commands: {},
commandlist: [],
@ -25,16 +26,33 @@ async function command_manager (context) {
}
} else if (!source?.sources?.discord && !source?.sources?.console) {
if (!command || !command.execute)
bot.tellraw("@a", {
translate: "%s%s%s %s",
color: "dark_gray",
with: [
{ translate: "command.unknown.command", color: "red" },
{ text: "\n" },
{ text: `${commandName}` },
{ translate: "command.context.here", color: "red" }
]
})
if (bot.options.isSavage) {
bot.chat.message(bot.getMessageAsPrismarine({
translate: "%s",
color: "dark_gray",
with: [
{ translate: "command.unknown.command", color: "red" },
]
})?.toMotd().replaceAll('§','&'));
bot.chat.message(bot.getMessageAsPrismarine({
translate: "%s %s",
color: "dark_gray",
with: [
{ text: `${commandName}` },
{ translate: "command.context.here", color: "red" }
]
})?.toMotd().replaceAll('§','&'));
} else {
bot.tellraw("@a", new MessageBuilder()
.setTranslate("%s%s%s %s")
.setColor("dark_gray")
.addWith(new MessageBuilder().setTranslate("command.unknown.command").setColor("red"))
.addWith(new MessageBuilder().setText("\n"))
.addWith(new MessageBuilder().setText(`${commandName}`))
.addWith(new MessageBuilder().setTranslate("command.context.here").setColor("red"))
)
}
} else if (source?.sources?.console && !source?.sources?.discord) {
if (!command || !command.execute)
bot.console.warn(bot.getMessageAsPrismarine({

View file

@ -22,8 +22,6 @@ function discord (context) {
channel: undefined,
invite: config.discord.invite || undefined,
prefix: config.discord.prefix,
// presence: bot.discord.presence,
// token: config.discord.token,
}
discordClient.once('ready', (context) => {
bot.discord.channel = discordClient.channels.cache.get(options.channelId)
@ -72,9 +70,6 @@ function discord (context) {
bot.on('playerChat', (message) => {
sendComponent(message);
})
/* bot.on('message', message => {
sendComponent(message)
})*/
function messageCreate(message, source) {
bot.discord.message = message;

View file

@ -11,15 +11,13 @@ function fileLogger(context) {
const timestamp = `${currentDate.getFullYear()}-${(currentDate.getMonth() + 1)
.toString()
.padStart(2, "0")}-${currentDate.getDate().toString().padStart(2, "0")}`;
const logFolder = path.join(__dirname, "../../logs");
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" });
if (!fs.existsSync(path.join(__dirname, "../../logs"))) {
fs.mkdirSync(path.join(__dirname, "../../logs"))
}
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) {
@ -27,7 +25,6 @@ function fileLogger(context) {
}
function compressFile(input, output) {
// if (!bot.Console.filelogging) return
const plainOutput = output.slice(0, -3);
fs.renameSync(input, plainOutput);

View file

@ -2,32 +2,71 @@ const os = require('os');
module.exports = (context) => {
const bot = context.bot;
const config = context.config;
const { MessageBuilder } = require('prismarine-chat')(bot.options.version);
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 }
]
}
component = new MessageBuilder()
.setTranslate("%s%s%s %s | %s: %s%s / %s%s | %s: %s%s / %s%s |")
.setColor(config.colors.commands.tertiary)
.addWith(new MessageBuilder()
.setColor("dark_blue")
.setText("FNF")
)
.addWith(new MessageBuilder()
.setColor("dark_aqua")
.setText("Boyfriend")
)
.addWith(new MessageBuilder()
.setColor("blue")
.setText("Bot")
)
.addWith(new MessageBuilder()
.setText("Memory Usage")
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.primary)
.setText("Free Server Memory")
)
.addWith(new MessageBuilder()
.setColor(config.colors.integer)
.setText(`${Math.floor(os.freemem() / 1048576)}`)
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText("MiB")
)
.addWith(new MessageBuilder()
.setColor(config.colors.integer)
.setText(`${Math.floor(os.totalmem() / 1048576)}`)
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText("MiB")
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.primary)
.setText("Bot Memory Usage")
)
.addWith(new MessageBuilder()
.setColor(config.colors.integer)
.setText(`${Math.floor(process.memoryUsage().heapUsed / 1048576)}`)
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText("MiB")
)
.addWith(new MessageBuilder()
.setColor(config.colors.integer)
.setText(`${Math.floor(process.memoryUsage().heapTotal / 1048576 )}`)
)
.addWith(new MessageBuilder()
.setColor(config.colors.commands.secondary)
.setText("MiB")
)
if (!bot.memUsage.enabled) return;
bot.core.run(`minecraft:title @a[tag=!memusage] actionbar ${JSON.stringify(component)}`)
}, 100)

View file

@ -40,6 +40,7 @@ function player_list (context) {
bot.players = bot.players.filter(_entry => _entry.uuid !== entry.uuid)
bot.players.push({
uuid: entry.uuid,
mcUUID: "",
profile: { name: entry.player.name, properties: entry.player.properties },
chatSession: undefined,
gamemode: undefined,

View file

@ -5,11 +5,7 @@ function reconnect (context) {
const config = context.config;
const options = context.options;
bot.on('end', () => {
//bot = undefined;
bot._client.removeAllListeners();
//client = undefined;
//bot._client = undefined;
if (bot.reconnectDelay < 0) return
setTimeout(() => {
if (options.usernameGen) {

View file

@ -1,23 +0,0 @@
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
const { request } = require('undici');
module.exports = async () => {
let url = await request('https://code.chipmunk.land/api/v1/repos/Parker2991/FridayNightFunkinBoyfriendBot/commits');
let data = await url.body.json();
let output = data[0]
let gitCommit = execSync('git rev-parse HEAD').toString().replaceAll('\n', '').substring(0, 10);
let urlCommit = output.sha.substring(0, 10);
if (gitCommit !== urlCommit) {
console.log('This build of the bot is not up to date! please update the bot at "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot" for the latest patches and new addons');
// this will check if the copy of the bot is up to date
} // i got bored and made this check now cry about it
if (!fs.existsSync(path.join(__dirname, "../../config.yml"))) {
console.warn("Config not found creating config from the default config");
fs.copyFileSync(
path.join(__dirname, "../data/default_config.yml"),
path.join(__dirname, "../../config.yml")
)
}
}