diff --git a/package-lock.json b/package-lock.json index c5612f0..e0c27c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3,9 +3,8 @@ "lockfileVersion": 3, "requires": true, "buildstring": { - "version": "v6.1.3", - "build": "1210", - "releaseDate": "12/06/24", + "version": "v6.1.4", + "build": "1215", "codename": "", "url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot" }, diff --git a/src/commands/console/console.js b/src/commands/console/console.js index 0eb6e30..aa80e15 100644 --- a/src/commands/console/console.js +++ b/src/commands/console/console.js @@ -69,7 +69,6 @@ module.exports = { bot.console.customChat.chat(`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.owner} ${args.slice(3).join(' ')}`) } else if (!bot.console.customChat.enabled) { bot.chat.message(`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.owner} ${args.slice(3).join(' ')}`) -// bot.chat.message(`${config.prefixes[0]}${args.slice(2)} ${args.slice(3).shift()}${bot.validation.trusted}`) } break case "admin": diff --git a/src/commands/owner/kill.js b/src/commands/owner/kill.js index 3ec9b2f..bbd3dda 100644 --- a/src/commands/owner/kill.js +++ b/src/commands/owner/kill.js @@ -13,10 +13,11 @@ module.exports = { }, execute (context) { const bot = context.bot; - process.kill(process.pid); + process.exit(1); }, + discordExecute (context) { const bot = context.bot; - process.kill(process.pid); + process.exit(1) } } diff --git a/src/commands/public/help.js b/src/commands/public/help.js index ba61fce..e6c48f2 100644 --- a/src/commands/public/help.js +++ b/src/commands/public/help.js @@ -348,7 +348,7 @@ module.exports = { setTimeout(() => { bot.chat.message(bot.getMessageAsPrismarine(trusted)?.toMotd().replaceAll("§","&")); }, 400) - setTimexout(() => { + setTimeout(() => { bot.chat.message(bot.getMessageAsPrismarine(admin)?.toMotd()?.replaceAll('§','&')) }, 400) setTimeout(() => { diff --git a/src/commands/public/info.js b/src/commands/public/info.js index fe0234e..ab75cea 100644 --- a/src/commands/public/info.js +++ b/src/commands/public/info.js @@ -311,40 +311,48 @@ module.exports = { break; case "version": case "ver": - if (botInfo.codename === '') { - + if (botInfo.buildstring.codename.length > 0) { component.push({ - translate: "%s %s %s-%s-%s%s-%s\n%s - %s", + translate: "%s %s %s-%s-%s\n%s: %s\n%s: %s\n%s: %s\n%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: "#" }, + botInfo.buildstring.codename, + { text: "Build", color: config.colors.commands.primary }, { 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 }, + { text: "Repo Build", color: config.colors.commands.primary }, + { text: `${execSync('git rev-list --count --all').toString().replaceAll('\n','')}`, color: config.colors.integer }, + { text: "Version Release Date", color: config.colors.commands.primary }, + { text: `${new Date(execSync('git log -1 --format=%ci').toString()).toLocaleString("en-US", {timeZone: "America/CHICAGO"})}`, color: config.colors.commands.secondary }, + { text: "Commit", color: config.colors.commands.primary }, + { text: `${execSync("git rev-parse HEAD").toString().substring(0, 10)}`, color: config.colors.commands.secondary }, + { 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", + translate: "%s %s %s-%s\n%s: %s\n%s: %s\n%s: %s\n%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: "Build", color: config.colors.commands.primary }, { text: `${botInfo.buildstring.build}`, color: config.colors.integer }, - { text: `${botInfo.buildstring.releaseDate}`, color: config.colors.commands.secondary }, - { text: `${botInfo.buildstring.codename}` }, + { text: "Repo Build", color: config.colors.commands.primary }, + { text: `${execSync('git rev-list --count --all').toString().replaceAll('\n','')}`, color: config.colors.integer }, + { text: "Version Release Date", color: config.colors.commands.primary }, + { text: `${new Date(execSync('git log -1 --format=%ci').toString()).toLocaleString("en-US", {timeZone: "America/CHICAGO"})}`, color: config.colors.commands.secondary }, + { text: "Commit", color: config.colors.commands.primary }, + { text: `${execSync("git rev-parse HEAD").toString().substring(0, 10)}`, 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 }, + { text: `${new Date().toLocaleDateString("en-US",{timeZone:"America/CHICAGO"})}`, color: config.colors.commands.secondary }, ] - }) + }); } break; default: diff --git a/src/index.js b/src/index.js index f5e94d1..06123e7 100644 --- a/src/index.js +++ b/src/index.js @@ -4,10 +4,11 @@ const loadModules = require('./util/loadModules'); const js_yaml = require('js-yaml'); const fs = require('fs'); const path = require('path'); -const checks = require('./util/checks'); 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'); @@ -17,12 +18,6 @@ try { console.log(e.stack); } -checks(config); - -/*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, diff --git a/src/modules/boot.js b/src/modules/boot.js index b702447..405d43d 100644 --- a/src/modules/boot.js +++ b/src/modules/boot.js @@ -1,4 +1,3 @@ - function boot (context) { const bot = context.bot; const config = context.config; diff --git a/src/modules/command_core.js b/src/modules/command_core.js index 8811c77..6456629 100644 --- a/src/modules/command_core.js +++ b/src/modules/command_core.js @@ -153,7 +153,7 @@ function core (context) { const itemPosition = bot.core.itemPosition; if (!location) return; - if (bot.options.isSavage || bot.options.isCreayun || bot.options.useChat) { + if (bot.options.isCreayun || bot.options.useChat || bot.options.isSavage) { return } else { if (bot.core.usePlacedCommandBlock) { diff --git a/src/modules/command_manager.js b/src/modules/command_manager.js index bceae80..b456e20 100644 --- a/src/modules/command_manager.js +++ b/src/modules/command_manager.js @@ -89,11 +89,11 @@ async function command_manager (context) { break; } if (!command?.discordExecute && command && source?.sources?.discord) { - throw new CommandError(`${command.name} command is not supported in discord!`) + throw new CommandError(`${command.data.name} command is not supported in discord!`) } else if (command?.discordExecute && command && source?.sources?.discord) { return command.discordExecute({ bot, source, arguments: args, config, discordClient }) } else if (!command?.execute && command && !source?.sources?.discord) { - throw new CommandError(`${command.name} command is not supported in game!`) + throw new CommandError(`${command.data.name} command is not supported in game!`) } else if (command?.execute && command && !source?.sources?.discord) { return command?.execute({ bot, source, arguments: args, config, discordClient }); } diff --git a/src/modules/selfcare.js b/src/modules/selfcare.js index 36cc7a5..108f251 100644 --- a/src/modules/selfcare.js +++ b/src/modules/selfcare.js @@ -87,60 +87,18 @@ function selfcare (context) { } }, 1000) }) -/* - bot.on("packet.teams", async (data) => { - if (options.isSavage || options.isCreayun) return; - try { -// console.log(data); -// bot.chat.command('minecraft:team add FNFBoyfriendBot'); -// if (data.team === "FNFBoyfriendBot") return; - if (data.team === "FNFBoyfriendBot" && data.mode === 1) { - bot.core.run("minecraft:team add FNFBoyfriendBot"); - } - - for (const eachPlayer of data?.players) { - if (eachPlayer !== bot.options.username) { - bot.core.run("minecraft:team empty FNFBoyfriendBot"); - await sleep(100); - bot.core.run("minecraft:team join FNFBoyfriendBot"); - } - } - } catch (e) { - console.log(e.stack) - } - })*/ -/* - { - team: 'FNFBoyfriendBot', - mode: 3, - name: undefined, - friendlyFire: undefined, - nameTagVisibility: undefined, - collisionRule: undefined, - formatting: undefined, - prefix: undefined, - suffix: undefined, - players: [ 'Parker2991' ] -} -*/ - let timer; bot.on('packet.login', async (packet) => { entityId = packet.entityId; gameMode = packet.gameMode; clientLock = packet.gameMode; -/* if (bot.options.isKaboom) { - bot.core.run('minecraft:team add FNFBoyfriendBot'); - await sleep(100); - bot.core.run('minecraft:team join FNFBoyfriendBot'); - }*/ timer = setInterval(() => { if (bot.options.isSavage && !bot.options.isKaboom && !bot.options.isCreayun) { if (login) bot.chat.command('login amogusissus'); else if (register) bot.chat.command('register amogusissus amogusissus'); -// else if (permissionLevel < 2) bot.chat.command(`minecraft:op ${bot.options.username}`); else if (gameMode !== 1) bot.chat.command('minecraft:gamemode creative'); + else if (permissionLevel < 2) bot.chat.command(`minecraft:op ${bot.options.username}`); else if (clientLock !== 4) bot._client.write("client_command", { actionId: 0 }); } else if (bot.options.isCreayun && !bot.options.isKaboom && !bot.options.isSavage) { diff --git a/src/modules/team.js b/src/modules/team.js index 1884ee9..ee9c85a 100644 --- a/src/modules/team.js +++ b/src/modules/team.js @@ -18,7 +18,6 @@ module.exports = (context) => { if (options.isSavage || options.isCreayun) return; try { if (data.team === config.team.name) { -// console.log(data); data?.players?.map(async (player) => { if (player !== bot.options.username) { await sleep(100); diff --git a/src/util/checks.js b/src/util/checks.js index 1302134..29c8e99 100644 --- a/src/util/checks.js +++ b/src/util/checks.js @@ -1,6 +1,18 @@ const fs = require('fs'); const path = require('path'); -module.exports = () => { +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( @@ -8,17 +20,4 @@ module.exports = () => { path.join(__dirname, "../../config.yml") ) } - -/* 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"))) { - console.warn("Trusted Players json not found creating the file,......"); - let data = [{player: ""}] - fs.writeFileSync(path.join(__dirname, "../data/trustedPlayers.json"), JSON.stringify(data)) - }*/ }