Compare commits

..

No commits in common. "main" and "v6.1.4" have entirely different histories.
main ... v6.1.4

19 changed files with 192 additions and 293 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.5", "version": "v6.1.4",
"build": "1225", "build": "1215",
"codename": "", "codename": "",
"url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot" "url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot"
}, },

View file

@ -20,17 +20,13 @@ 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}"]`, new MessageBuilder() bot.tellraw(`@a[name="${source.player.profile.name}"]`, [
.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: {
@ -45,7 +41,7 @@ module.exports = {
value: `${script}` value: `${script}`
} }
} }
]);*/ ]);
} }
} catch (e) { } catch (e) {
throw new CommandError(e.toString()) throw new CommandError(e.toString())

View file

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

View file

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

View file

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

View file

@ -16,146 +16,43 @@ 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 = new MessageBuilder() component.push({
.setTranslate("%s\n%s\n%s: %s (%s)\n%s\n%s\n%s: %s\n%s: %s") 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",
.setColor(config.colors.commands.tertiary) color: config.colors.commands.tertiary,
.addWith(new MessageBuilder() with: [
.setTranslate("%s: %s, %s %s") { text: "Location", color: config.colors.commands.primary },
.setColor(config.colors.commands.tertiary) { text: `${info.location.name}, ${info.location.region}, ${info.location.country}`, color: config.colors.commands.secondary },
.addWith(new MessageBuilder() { text: "Latitude", color: config.colors.commands.primary },
.setColor(config.colors.commands.primary) { text: `${info.location.lat}`, color: config.colors.integer },
.setText("Location") { text: "Longitude", color: config.colors.commands.primary },
) { text: `${info.location.lon}`, color: config.colors.integer },
.addWith(new MessageBuilder() { text: "Time zone", color: config.colors.commands.primary },
.setColor(config.colors.commands.secondary) { text: `${info.location.tz_id}`, color: config.colors.commands.secondary },
.setText(info.location.name) { text: "Time", color: config.colors.commands.primary },
) { text: `${new Date().toLocaleTimeString("en-US", { timeZone: info.location.tz_id, })}`, color: config.colors.integer },
.addWith(new MessageBuilder() { text: "Temp", color: config.colors.commands.primary },
.setColor(config.colors.commands.secondary) { text: `${info.current.temp_c}`, color: config.colors.integer },
.setText(info.location.region) { text: "\u00b0C", color: config.colors.commands.secondary },
) { text: `${info.current.temp_f}`, color: config.colors.integer },
.addWith(new MessageBuilder() { text: "\u00b0F", color: config.colors.commands.secondary },
.setColor(config.colors.commands.secondary) { text: "Wind speed" , color: config.colors.commands.primary },
.setText(info.location.country) { 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 },
.addWith(new MessageBuilder() { text: `${info.current.wind_mph}`, color: config.colors.integer },
.setTranslate("%s: %s, %s") { text: `mph`, color: config.colors.commands.secondary },
.setColor(config.colors.commands.tertiary) { text: `${info.current.wind_dir}`, color: config.colors.commands.secondary },
.addWith(new MessageBuilder() { text: "Condition", color: config.colors.commands.primary },
.setColor(config.colors.commands.primary) { text: `${info.current.condition.text}`, color: config.colors.commands.secondary },
.setText("Coords") { text: "Humidity", color: config.colors.commands.primary },
) { text: `${info.current.humidity}`, color: config.colors.integer },
.addWith(new MessageBuilder() ]
.setColor(config.colors.integer) })
.setText(`${info.location.lat}`) bot.tellraw("@a", component)
)
.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,20 +17,13 @@ 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", new MessageBuilder() bot.tellraw(`@a`, { text: `${summary}`, color: 'gray' });
.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", new MessageBuilder() bot.tellraw(`@a`, { text: 'Article not found!', color: 'dark_red' })
.setText("Article not found!")
.setColor("red")
)
} else { } else {
bot.tellraw(`@a`, `${error.toString()}`) bot.tellraw(`@a`, `${error.toString()}`)
} }

View file

@ -78,11 +78,6 @@ 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,25 +1,19 @@
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 = require('js-yaml').load(fs.readFileSync(path.join(__dirname, '../', 'config.yml'))) config = js_yaml.load(fs.readFileSync(path.join(__dirname, '../', 'config.yml')))
} catch (e) { } catch (e) {
console.log(e.stack); console.log(e.stack);
} }
@ -35,6 +29,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;
require('./util/loadModules')(bot, options, config, discordClient); loadModules(bot, options, config, discordClient);
bot.console.readlineInterface(rl); bot.console.readlineInterface(rl);
} }

View file

@ -89,11 +89,9 @@ function chat (context) {
return return
} }
if (message.translate === "advMode.notAllowed") return; bot.emit('systemChat', message)
bot.emit('systemChat', message); tryParsingMessage(message, { players: bot.players, getMessageAsPrismarine: bot.getMessageAsPrismarine })
tryParsingMessage(message, { players: bot.players, getMessageAsPrismarine: bot.getMessageAsPrismarine });
}) })
bot.on('packet.action_bar', (message) => { bot.on('packet.action_bar', (message) => {
@ -167,9 +165,8 @@ 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

@ -4,7 +4,6 @@ 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;
@ -17,9 +16,8 @@ module.exports = (context) => {
setTimeout(() => { setTimeout(() => {
ratelimit-- ratelimit--
}, 1000) }, 1000)
if (ratelimit > 2) { // new e.MessageBuilder().setText("e").toJSON() if (ratelimit > 2) {
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'})
// 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

@ -49,7 +49,11 @@ 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', {
@ -181,7 +185,13 @@ 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

@ -9,7 +9,6 @@ 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: [],
@ -26,33 +25,16 @@ 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)
if (bot.options.isSavage) { bot.tellraw("@a", {
bot.chat.message(bot.getMessageAsPrismarine({ translate: "%s%s%s %s",
translate: "%s", color: "dark_gray",
color: "dark_gray", with: [
with: [ { translate: "command.unknown.command", color: "red" },
{ translate: "command.unknown.command", color: "red" }, { text: "\n" },
] { text: `${commandName}` },
})?.toMotd().replaceAll('§','&')); { translate: "command.context.here", color: "red" }
]
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,6 +22,8 @@ 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)
@ -70,6 +72,9 @@ 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,13 +11,15 @@ 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, `${config.logsFolder.path}`, `${config.logsFolder.name}`); const logFolder = path.join(__dirname, "../../logs");
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) {
@ -25,6 +27,7 @@ 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,71 +2,32 @@ 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 = new MessageBuilder() component = {
.setTranslate("%s%s%s %s | %s: %s%s / %s%s | %s: %s%s / %s%s |") translate: "%s%s%s %s | %s: %s%s / %s%s | %s: %s%s / %s%s |",
.setColor(config.colors.commands.tertiary) color: config.colors.commands.tertiary,
.addWith(new MessageBuilder() with: [
.setColor("dark_blue") { text: "FNF", color: "dark_blue" },
.setText("FNF") { text: "Boyfriend", color: "dark_aqua" },
) { text: "Bot", color: "blue" },
.addWith(new MessageBuilder() { text: "Memory Usage" },
.setColor("dark_aqua") { text: "Free Server Memory", color: config.colors.commands.primary },
.setText("Boyfriend") { text: `${Math.floor(os.freemem() / 1048576)}`, color: config.colors.integer },
) { text: "MiB", color: config.colors.commands.secondary },
.addWith(new MessageBuilder() { text: `${Math.floor(os.totalmem() / 1048576)}`, color: config.colors.integer },
.setColor("blue") { text: "MiB", color: config.colors.commands.secondary },
.setText("Bot") { text: "Bot Memory Usage", color: config.colors.commands.primary },
) { text: `${Math.floor(process.memoryUsage().heapUsed / 1048576)}`, color: config.colors.integer },
.addWith(new MessageBuilder() { text: "MiB", color: config.colors.commands.secondary },
.setText("Memory Usage") { text: `${Math.floor(process.memoryUsage().heapTotal / 1048576 )}`, color: config.colors.integer },
) { 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,7 +40,6 @@ 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,7 +5,11 @@ 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) {

23
src/util/checks.js Normal file
View file

@ -0,0 +1,23 @@
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")
)
}
}