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, "lockfileVersion": 3,
"requires": true, "requires": true,
"buildstring": { "buildstring": {
"version": "v6.1.4", "version": "v6.1.5",
"build": "1215", "build": "1225",
"codename": "", "codename": "",
"url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot" "url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot"
}, },

View file

@ -20,13 +20,17 @@ module.exports = {
const discordClient = context.discordClient; const discordClient = context.discordClient;
const args = context.arguments; const args = context.arguments;
const script = args.slice(1).join(' '); const script = args.slice(1).join(' ');
const { MessageBuilder } = require('prismarine-chat')(bot.options.version);
try { try {
if (source.sources.console) { if (source.sources.console) {
bot.console.log(bot.getMessageAsPrismarine({ text: util.inspect(eval(args.join(' ')), { stylize })})?.toAnsi()) bot.console.log(bot.getMessageAsPrismarine({ text: util.inspect(eval(args.join(' ')), { stylize })})?.toAnsi())
} else if (bot.options.useChat || bot.options.isSavage) { } else if (bot.options.useChat || bot.options.isSavage) {
bot.chat.message(bot.getMessageAsPrismarine({ text: util.inspect(eval(script), { stylize }).substring(0, 32700) })?.toMotd().replaceAll('§','&')) bot.chat.message(bot.getMessageAsPrismarine({ text: util.inspect(eval(script), { stylize }).substring(0, 32700) })?.toMotd().replaceAll('§','&'))
} else { } 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), text: util.inspect(eval(script), { stylize }).substring(0, 32700),
hoverEvent: { hoverEvent: {
@ -41,7 +45,7 @@ module.exports = {
value: `${script}` value: `${script}`
} }
} }
]); ]);*/
} }
} catch (e) { } catch (e) {
throw new CommandError(e.toString()) throw new CommandError(e.toString())

View file

@ -358,6 +358,10 @@ module.exports = {
default: default:
throw new CommandError({ translate: "command.unknown.argument", color: "dark_red" }); 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 server.description
] ]
}) })
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, component);
/* bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [ if (bot.options.isSavage) {
{ bot.chat.message(`Ip \u203a ${host}:${Number(port ?? 25565)}`);
text: `Ip \u203a ${host}:${Number(port ?? 25565)}\n`, bot.chat.message(`Players \u203a ${server.players.online} / ${server.players.max}`);
color: 'gray', bot.chat.message(`Version \u203a ${server.version.name}`);
hoverEvent: { bot.chat.message(bot.getMessageAsPrismarine(server.description)?.toMotd().replaceAll('§','&'));
action: 'show_text', } else {
contents: [{ bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, component);
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,
])*/
} catch (e) { } catch (e) {
bot.chat.message(`${e.toString()}`) bot.chat.message(`${e.toString()}`)
} }

View file

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

View file

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

View file

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

View file

@ -1,19 +1,25 @@
const createBot = require('./bot.js'); const createBot = require('./bot.js');
const readline = require('readline'); const readline = require('readline');
const loadModules = require('./util/loadModules');
const js_yaml = require('js-yaml'); const js_yaml = require('js-yaml');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const { Client, GatewayIntentBits } = require('discord.js'); 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] });
require('./util/checks')();
console.log('Starting FNFBoyfriendBot'); console.log('Starting FNFBoyfriendBot');
process.stdout.write('\x1b]2;Starting FNFBoyfriendBot please wait,.....\x1b\x5c'); 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 { 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) { } catch (e) {
console.log(e.stack); console.log(e.stack);
} }
@ -29,6 +35,6 @@ for (const options of config.bots) {
const bot = new createBot(options, config); const bot = new createBot(options, config);
bots.push(bot); bots.push(bot);
bot.bots = bots; bot.bots = bots;
loadModules(bot, options, config, discordClient); require('./util/loadModules')(bot, options, config, discordClient);
bot.console.readlineInterface(rl); bot.console.readlineInterface(rl);
} }

View file

@ -89,9 +89,11 @@ function chat (context) {
return 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) => { bot.on('packet.action_bar', (message) => {
@ -165,8 +167,9 @@ function chat (context) {
acknowledged: Buffer.alloc(3), acknowledged: Buffer.alloc(3),
previousMessages: [] previousMessages: []
}) })
} },
} }
bot.tellraw = (selector, message) => { bot.tellraw = (selector, message) => {
bot.core.run(`minecraft:tellraw ${selector} ` + JSON.stringify(message)) bot.core.run(`minecraft:tellraw ${selector} ` + JSON.stringify(message))
} }

View file

@ -49,11 +49,7 @@ function core (context) {
bot.chat.command('spawn'); bot.chat.command('spawn');
return 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` 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', { bot._client.write('set_creative_slot', {
@ -185,13 +181,7 @@ function core (context) {
}) })
bot.on('packet.block_change', (data) => { 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

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

View file

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

View file

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

View file

@ -11,15 +11,13 @@ function fileLogger(context) {
const timestamp = `${currentDate.getFullYear()}-${(currentDate.getMonth() + 1) const timestamp = `${currentDate.getFullYear()}-${(currentDate.getMonth() + 1)
.toString() .toString()
.padStart(2, "0")}-${currentDate.getDate().toString().padStart(2, "0")}`; .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 logFileName = "latest.log";
const logFilePath = path.join(logFolder, logFileName); const logFilePath = path.join(logFolder, logFileName);
const logStream = fs.createWriteStream(logFilePath, { flags: "a" }); const logStream = fs.createWriteStream(logFilePath, { flags: "a" });
if (!fs.existsSync(path.join(__dirname, "../../logs"))) {
fs.mkdirSync(path.join(__dirname, "../../logs"))
}
try { try {
if (!fs.existsSync(logFolder)) { if (!fs.existsSync(logFolder)) {
console.info(`logs folder not found recreating it at ${config.logsFolder.path}${config.logsFolder.name}`);
fs.mkdirSync(logFolder); fs.mkdirSync(logFolder);
} }
} catch (e) { } catch (e) {
@ -27,7 +25,6 @@ function fileLogger(context) {
} }
function compressFile(input, output) { function compressFile(input, output) {
// if (!bot.Console.filelogging) return
const plainOutput = output.slice(0, -3); const plainOutput = output.slice(0, -3);
fs.renameSync(input, plainOutput); fs.renameSync(input, plainOutput);

View file

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

View file

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

View file

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