From ca45444dd5d32b8da7b6b1dfe808d60254abacce Mon Sep 17 00:00:00 2001 From: Parker2991 Date: Wed, 6 Nov 2024 11:50:24 -0500 Subject: [PATCH] v6.1.0 build: 1130 made it to where the bots vanish can be toggled organized command files and placed them in folders --- package-lock.json | 8 +- src/commands/{ => admin}/filter.js | 32 ++--- src/commands/admin/vanish.js | 32 +++++ src/commands/{ => console}/console.js | 24 ++-- src/commands/{ => owner}/kill.js | 22 ++-- src/commands/{ => owner}/servereval.js | 24 ++-- src/commands/{ => public}/bots.js | 22 ++-- src/commands/{ => public}/core.js | 26 ++-- src/commands/{ => public}/cowsay.js | 22 ++-- src/commands/{ => public}/echo.js | 27 ++-- src/commands/{ => public}/help.js | 157 +++++++++++------------ src/commands/{ => public}/info.js | 162 +++++++++++------------- src/commands/{ => public}/list.js | 22 +++- src/commands/{ => public}/mcserver.js | 24 ++-- src/commands/{ => public}/netmsg.js | 20 +-- src/commands/{ => public}/refillcore.js | 20 +-- src/commands/{ => public}/test.js | 25 ++-- src/commands/{ => public}/urban.js | 20 +-- src/commands/{ => public}/weather.js | 22 ++-- src/commands/{ => public}/wiki.js | 18 ++- src/commands/{ => trusted}/cloop.js | 28 ++-- src/commands/{ => trusted}/kick.js | 21 +-- src/commands/{ => trusted}/reconnect.js | 20 +-- src/commands/{ => trusted}/rtp.js | 26 ++-- src/commands/{ => trusted}/validate.js | 20 +-- src/commands/{ => trusted}/website.js | 22 ++-- src/commands/vanish.js | 31 ----- src/data/info.json | 10 -- src/data/trustedPlayers.json | 1 - src/modules/command_manager.js | 93 +++++++------- src/modules/selfcare.js | 19 +++ src/util/checks.js | 3 +- 32 files changed, 539 insertions(+), 484 deletions(-) rename src/commands/{ => admin}/filter.js (89%) create mode 100644 src/commands/admin/vanish.js rename src/commands/{ => console}/console.js (93%) rename src/commands/{ => owner}/kill.js (53%) rename src/commands/{ => owner}/servereval.js (80%) rename src/commands/{ => public}/bots.js (84%) rename src/commands/{ => public}/core.js (51%) rename src/commands/{ => public}/cowsay.js (92%) rename src/commands/{ => public}/echo.js (64%) rename src/commands/{ => public}/help.js (73%) rename src/commands/{ => public}/info.js (79%) rename src/commands/{ => public}/list.js (92%) rename src/commands/{ => public}/mcserver.js (91%) rename src/commands/{ => public}/netmsg.js (95%) rename src/commands/{ => public}/refillcore.js (61%) rename src/commands/{ => public}/test.js (74%) rename src/commands/{ => public}/urban.js (93%) rename src/commands/{ => public}/weather.js (92%) rename src/commands/{ => public}/wiki.js (75%) rename src/commands/{ => trusted}/cloop.js (94%) rename src/commands/{ => trusted}/kick.js (84%) rename src/commands/{ => trusted}/reconnect.js (61%) rename src/commands/{ => trusted}/rtp.js (76%) rename src/commands/{ => trusted}/validate.js (87%) rename src/commands/{ => trusted}/website.js (93%) delete mode 100644 src/commands/vanish.js delete mode 100644 src/data/info.json delete mode 100644 src/data/trustedPlayers.json diff --git a/package-lock.json b/package-lock.json index d41a30c..80fb035 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "FridayNightFunkinBoyfriendBot", - "version": "v6.0.9-1", - "build": "1115", - "url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot", - "codename": "", + "version": "v6.1.0", "lockfileVersion": 3, "requires": true, + "build": "1130", + "codename": "", + "url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot", "packages": { "": { "dependencies": { diff --git a/src/commands/filter.js b/src/commands/admin/filter.js similarity index 89% rename from src/commands/filter.js rename to src/commands/admin/filter.js index 55ecdf7..825621f 100644 --- a/src/commands/filter.js +++ b/src/commands/admin/filter.js @@ -1,19 +1,21 @@ -const CommandError = require('../util/command_error'); +const CommandError = require('../../util/command_error'); module.exports = { - name: 'filter', - trustLevel: 2, - aliases: [ - "blacklist" - ], - description: 'filters players', - usages: [ - "list", - "--regex(-r) --ignorecase(-i) add ", - "--ignorecase(-i) add ", - "add ", - "clear", - "remove(rm) " - ], + data: { + name: 'filter', + trustLevel: 2, + aliases: [ + "blacklist" + ], + description: 'filters players', + usages: [ + "list", + "--regex(-r) --ignorecase(-i) add ", + "--ignorecase(-i) add ", + "add ", + "clear", + "remove(rm) " + ], + }, execute (context) { /* note: diff --git a/src/commands/admin/vanish.js b/src/commands/admin/vanish.js new file mode 100644 index 0000000..eba4e19 --- /dev/null +++ b/src/commands/admin/vanish.js @@ -0,0 +1,32 @@ +module.exports = { + data: { + name: 'vanish', + trustLevel: 2, + aliases: [ + "vanishtoggle" + ], + description: 'toggle the bots vanish selfcare', + usages: [ + + ], + }, + execute (context) { + const bot = context.bot + const args = context.arguments; + if (args.slice(1).join('') === 'true') { + bot.vanished = true + bot.chat.message('enabled vanish selfcare') + } + if (args.slice(1).join('') === 'false') { + bot.vanished = false; + bot.chat.message('disabled vanish selfcare') + } + }, + discordExecute (context) { + const bot = context.bot; + const args = context.arguments; + bot.vanished = false; + bot.chat.message('disabling vanish selfcare,...'); + bot.chat.command('v off') + } +} diff --git a/src/commands/console.js b/src/commands/console/console.js similarity index 93% rename from src/commands/console.js rename to src/commands/console/console.js index 7878bf2..98b4b4b 100644 --- a/src/commands/console.js +++ b/src/commands/console/console.js @@ -1,16 +1,18 @@ module.exports = { - name: 'console', - trustLevel: 4, - aliases: [ + data: { + name: 'console', + trustLevel: 4, + aliases: [ - ], - usages: [ - 'server/srv ', - 'customchat ', - 'say ', - 'validate/validation/val ', - 'logging/togglelogging/logtoconsole ' - ], + ], + usages: [ + 'server/srv ', + 'customchat ', + 'say ', + 'validate/validation/val ', + 'logging/togglelogging/logtoconsole ' + ], + }, execute (context) { const bot = context.bot const args = context.arguments; diff --git a/src/commands/kill.js b/src/commands/owner/kill.js similarity index 53% rename from src/commands/kill.js rename to src/commands/owner/kill.js index e72fb52..3ec9b2f 100644 --- a/src/commands/kill.js +++ b/src/commands/owner/kill.js @@ -1,14 +1,16 @@ module.exports = { - name: 'kill', - trustLevel: 3, - aliases: [ - "suicide", - "quit", - ], - description: 'kill the bots process', - usages: [ - "" - ], + data: { + name: 'kill', + trustLevel: 3, + aliases: [ + "suicide", + "quit", + ], + description: 'kill the bots process', + usages: [ + "" + ], + }, execute (context) { const bot = context.bot; process.kill(process.pid); diff --git a/src/commands/servereval.js b/src/commands/owner/servereval.js similarity index 80% rename from src/commands/servereval.js rename to src/commands/owner/servereval.js index ae0721c..dc97637 100644 --- a/src/commands/servereval.js +++ b/src/commands/owner/servereval.js @@ -1,15 +1,17 @@ -const CommandError = require('../util/command_error.js'); -const { stylize } = require('../util/stylizeEval'); +const CommandError = require('../../util/command_error.js'); +const { stylize } = require('../../util/stylizeEval'); const util = require('util'); module.exports = { - name: 'servereval', - trustLevel: 3, - aliases: [ - ], - description: 'run code unisolated', - usages: [ - "", - ], + data: { + name: 'servereval', + trustLevel: 3, + aliases: [ + ], + description: 'run code unisolated', + usages: [ + "", + ], + }, execute (context) { const bot = context.bot; const source = context.source; @@ -23,7 +25,7 @@ module.exports = { } 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`, [ { text: util.inspect(eval(script), { stylize }).substring(0, 32700), hoverEvent: { diff --git a/src/commands/bots.js b/src/commands/public/bots.js similarity index 84% rename from src/commands/bots.js rename to src/commands/public/bots.js index 90e7cf1..c86bb65 100644 --- a/src/commands/bots.js +++ b/src/commands/public/bots.js @@ -1,12 +1,18 @@ -const bots = require('../data/bots.json'); -const CommandError = require('../util/command_error') +const bots = require('../../data/bots.json'); +const CommandError = require('../../util/command_error') module.exports = { - name: "bots", - description: "shows a list of known bots", - aliases: ["knownbots"], - trustLevel: 0, - usages:[""], - async execute(context) { + data: { + name: "bots", + description: "shows a list of known bots", + aliases: [ + "knownbots" + ], + trustLevel: 0, + usages: [ + "" + ], + }, + async execute(context) { const query = context.arguments.join(" ").toLowerCase(); const bot = context.bot; if (query.length === 0) { diff --git a/src/commands/core.js b/src/commands/public/core.js similarity index 51% rename from src/commands/core.js rename to src/commands/public/core.js index a82e191..e0bdc95 100644 --- a/src/commands/core.js +++ b/src/commands/public/core.js @@ -1,17 +1,19 @@ -const CommandError = require('../util/command_error') +const CommandError = require('../../util/command_error') module.exports = { - name: 'core', - trustLevel: 0, - aliases: [ - "cb", - "corerun", - "commandcorerun", - ], - description: 'run commands in core!', - usages: [ - "", - ], + data: { + name: 'core', + trustLevel: 0, + aliases: [ + "cb", + "corerun", + "commandcorerun", + ], + description: 'run commands in core!', + usages: [ + "", + ], + }, execute (context) { const bot = context.bot const message = context.arguments.join(' '); diff --git a/src/commands/cowsay.js b/src/commands/public/cowsay.js similarity index 92% rename from src/commands/cowsay.js rename to src/commands/public/cowsay.js index 6fa3466..162e7ec 100644 --- a/src/commands/cowsay.js +++ b/src/commands/public/cowsay.js @@ -1,17 +1,19 @@ const cowsay = require('cowsay2'); const cows = require('cowsay2/cows'); const { EmbedBuilder } = require('discord.js'); -const fixansi = require('../util/ansi'); +const fixansi = require('../../util/ansi'); module.exports = { - name: 'cowsay', - trustLevel: 0, - aliases: [ - ], - description: 'cows', - usages: [ - "", - "list" - ], + data: { + name: 'cowsay', + trustLevel: 0, + aliases: [ + ], + description: 'cows', + usages: [ + "", + "list" + ], + }, execute (context) { const bot = context.bot; const args = context.arguments; diff --git a/src/commands/echo.js b/src/commands/public/echo.js similarity index 64% rename from src/commands/echo.js rename to src/commands/public/echo.js index 51d6cd0..dd3fcdc 100644 --- a/src/commands/echo.js +++ b/src/commands/public/echo.js @@ -1,14 +1,16 @@ module.exports = { - name: 'echo', - trustLevel: 0, - aliases: [ - "say", - "botsay", - ], - description: 'Make me say something', - usages: [ - "" - ], + data: { + name: 'echo', + trustLevel: 0, + aliases: [ + "say", + "botsay", + ], + description: 'Make me say something', + usages: [ + "" + ], + }, execute (context) { const bot = context.bot const message = context.arguments.join(' ') @@ -16,20 +18,15 @@ module.exports = { bot.chat.command(message.substring(1)) return } - -// if bot.chat.message(message) }, discordExecute (context) { const bot = context.bot; const args = context.arguments; -// const interaction = context.interaction -//interaction.options.getString('input') if (args.join(' ').startsWith('/')) { bot.chat.command(args.join(' ').substring(1)) return } bot.chat.message(args.join(' ')) -// bot.chat.message('e') } } diff --git a/src/commands/help.js b/src/commands/public/help.js similarity index 73% rename from src/commands/help.js rename to src/commands/public/help.js index 0d0ccc6..6e7da0d 100644 --- a/src/commands/help.js +++ b/src/commands/public/help.js @@ -1,26 +1,27 @@ -const CommandError = require('../util/command_error'); -const sleep = require('../util/sleep.js'); -const fixansi = require('../util/ansi'); +const CommandError = require('../../util/command_error'); +const sleep = require('../../util/sleep.js'); +const fixansi = require('../../util/ansi'); const { EmbedBuilder } = require('discord.js'); module.exports = { - name: 'help', - trustLevel: 0, - aliases: [ - "heko", - "?", - "cmds", - "hell", - "hello", - "helo", - "commands", - "commandshelp", - - ], - description: 'a list of the bots commands', - usages: [ - "", - "", - ], + data: { + name: 'help', + trustLevel: 0, + aliases: [ + "heko", + "?", + "cmds", + "hell", + "hello", + "helo", + "commands", + "commandshelp", + ], + description: 'a list of the bots commands', + usages: [ + "", + "", + ], + }, execute (context) { const commandList = []; const bot = context.bot; @@ -47,41 +48,41 @@ module.exports = { for (const command of bot.commandManager.commandlist) { let usagesComponent = []; let commandComponent = []; - for (const usages of command.usages) { - if (command?.trustLevel === 1) { + for (const usages of command.data.usages) { + if (command?.data?.trustLevel === 1) { usagesComponent.push({ translate: "%s%s %s", with: [ { text: `${config.prefixes[0]}`, color: "dark_blue" }, - { text: `${command.name} `, color: "blue" }, + { text: `${command.data.name} `, color: "blue" }, { text: `${usages}`, color: "aqua" }, ] }) - } else if (command?.trustLevel === 2) { + } else if (command?.data.trustLevel === 2) { usagesComponent.push({ translate: "%s%s %s", with: [ { text: `${config.prefixes[0]}`, color: "dark_blue" }, - { text: `${command.name} `, color: "blue" }, + { text: `${command.data.name} `, color: "blue" }, { text: `${usages}`, color: "aqua" }, ] }) - } else if (command?.trustLevel === 3) { + } else if (command?.data.trustLevel === 3) { usagesComponent.push({ translate: "%s%s %s", with: [ { text: `${config.prefixes[0]}`, color: "dark_blue" }, - { text: `${command.name} `, color: "blue" }, + { text: `${command.data.name} `, color: "blue" }, { text: `${usages}`, color: "aqua" }, ] }) - } else if (command?.trustLevel === 0 || command.trustLevel === 4) { + } else if (command?.data.trustLevel === 0 || command.data.trustLevel === 4) { usagesComponent.push({ translate: "%s%s %s", with: [ { text: `${config.prefixes[0]}`, color: "dark_blue" }, - { text: `${command.name}`, color: "blue" }, - { text: `${usages.toString().replaceAll(',','')}`, color: "aqua" }, + { text: `${command.data.name}`, color: "blue" }, + { text: `${usages}`, color: "aqua" }, ] }) } @@ -94,16 +95,16 @@ module.exports = { with: [ { text: "Command Name", color: "dark_blue" }, { text: "\u203a" }, - { text: `${command.name}`, color: "blue" }, + { text: `${command.data.name}`, color: "blue" }, { text: "Aliases", color: "dark_blue" }, { text: "\u203a" }, - { text: `${command.aliases.toString().replaceAll(',',' ')}`, color: "blue" }, + { text: `${command.data.aliases.toString().replaceAll(',',' ')}`, color: "blue" }, { text: "Description", color: "dark_blue" }, { text: "\u203a" }, - { text: `${command.description}`, color: "blue" }, + { text: `${command.data.description}`, color: "blue" }, { text: "Trust Level", color: "dark_blue" }, { text: "\u203a" }, - { text: `${command.trustLevel}`, color: "gold" }, + { text: `${command.data.trustLevel}`, color: "gold" }, { text: "Usages", color: "dark_blue" }, { text: "\u203a" } ] @@ -111,7 +112,7 @@ module.exports = { commandComponent.push("\n"); commandComponent.push(usagesComponent); // for (const aliases of command.aliases) { - if (args[0]?.toLowerCase() === command.name) { + if (args[0]?.toLowerCase() === command.data.name) { if (bot.options.isSavage) { bot.chat.message(`${bot.getMessageAsPrismarine(commandComponent)?.toMotd().replaceAll('§','&')}`); } else { @@ -130,17 +131,17 @@ module.exports = { console.log(aliases)*/ // } // tellraw @p {"text":"this","clickEvent":{"action":"suggest_command","value":"this"}} - if (command.trustLevel === 0) { + if (command.data.trustLevel === 0) { public.push([ { - text: command.name + ' ', + text: command.data.name + ' ', color: "aqua", translate: "", hoverEvent: { action: "show_text", value: [ { - text: `Command: ${command.name}\n`, + text: `Command: ${command.data.name}\n`, color: 'blue' }, { @@ -148,15 +149,15 @@ module.exports = { color: 'blue' }, { - text: `${command.trustLevel}\n`, + text: `${command.data.trustLevel}\n`, color: 'gold' }, { - text: `${command.description}\n`, + text: `${command.data.description}\n`, color: 'blue' }, { - text: `Command Aliases: ${command.aliases}\n`, + text: `Command Aliases: ${command.data.aliases}\n`, color: 'blue' }, { @@ -167,21 +168,21 @@ module.exports = { }, clickEvent: { action: 'suggest_command', - value: `${config.prefixes[0]}${command?.name}` + value: `${config.prefixes[0]}${command?.data.name}` } } ]) - } else if (command.trustLevel === 1) { + } else if (command.data.trustLevel === 1) { trusted.push([ { - text: command.name + ' ', + text: command.data.name + ' ', color: "dark_aqua", translate: "", hoverEvent: { action: "show_text", value: [ { - text: `Command:${command.name}\n`, + text: `Command: ${command.data.name}\n`, color: 'blue' }, { @@ -189,15 +190,15 @@ module.exports = { color: 'blue' }, { - text: `${command.trustLevel}\n`, + text: `${command.data.trustLevel}\n`, color: 'gold' }, { - text: `${command.description}\n`, + text: `${command.data.description}\n`, color: 'blue' }, { - text: `Command Aliases: ${command.aliases}\n`, + text: `Command Aliases: ${command.data.aliases}\n`, color: 'blue' }, { @@ -208,21 +209,21 @@ module.exports = { }, clickEvent: { action: 'suggest_command', - value: `${config.prefixes[0]}${command?.name}` + value: `${config.prefixes[0]}${command?.data.name}` } } ]) - } else if (command.trustLevel === 2) { + } else if (command.data.trustLevel === 2) { admin.push([ { - text: command.name + ' ', + text: command.data.name + ' ', color: "blue", translate: "", hoverEvent: { action:"show_text", value: [ { - text: `Command:${command.name}\n`, + text: `Command: ${command.data.name}\n`, color: 'blue' }, { @@ -230,15 +231,15 @@ module.exports = { color: 'blue' }, { - text: `${command.trustLevel}\n`, + text: `${command.data.trustLevel}\n`, color: 'gold' }, { - text: `${command.description}\n`, + text: `${command.data.description}\n`, color: 'blue' }, { - text: `Command Aliases: ${command.aliases}\n`, + text: `Command Aliases: ${command.data.aliases}\n`, color: 'blue' }, { @@ -249,21 +250,21 @@ module.exports = { }, clickEvent: { action: 'suggest_command', - value: `${config.prefixes[0]}${command?.name}` + value: `${config.prefixes[0]}${command?.data.name}` } } ]) - } else if (command.trustLevel === 3) { + } else if (command.data.trustLevel === 3) { owner.push([ { - text: command.name + ' ', + text: command.data.name + ' ', color: "dark_blue", translate: "", hoverEvent: { action: "show_text", value: [ { - text: `Command:${command.name}\n`, + text: `Command: ${command.data.name}\n`, color: 'blue' }, { @@ -271,15 +272,15 @@ module.exports = { color: 'blue' }, { - text: `${command.trustLevel}\n`, + text: `${command.data.trustLevel}\n`, color: 'gold' }, { - text: `${command.description}\n`, + text: `${command.data.description}\n`, color: 'blue' }, { - text: `Command Aliases: ${command.aliases}\n`, + text: `Command Aliases: ${command.data.aliases}\n`, color: 'blue' }, { @@ -290,13 +291,13 @@ module.exports = { }, clickEvent: { action: 'suggest_command', - value: `${config.prefixes[0]}${command?.name}` + value: `${config.prefixes[0]}${command?.data.name}` } } ]) } } - const length = bot.commandManager.commandlist.filter(c => c.trustLevel != 4).length + const length = bot.commandManager.commandlist.filter(c => c.data.trustLevel != 4).length if (bot.options.useChat) { bot.chat.message(bot.getMessageAsPrismarine([ { @@ -400,52 +401,52 @@ module.exports = { let admin = []; let owner = []; for (const command of bot.commandManager.commandlist) { - if (args[0] === command.name) { - const ansi = bot.getMessageAsPrismarine([ { text: `CommandName \u203a ${command.name}\n`, color: 'gray', }, { text: `Aliases \u203a ${command.aliases}\n`, color: 'gray', }, { text: `Description \u203a ${command.description}\n`, color: 'gray', }, { text: `trustLevel \u203a ${command.trustLevel}\n`, color: 'gray' }, { text: `Usages \u203a ${command?.usages}`, color: "dark_gray" }, ])?.toAnsi().replaceAll('```\u001b[9```' + '```\u001b[3```') + if (args[0] === command.data.name) { + const ansi = bot.getMessageAsPrismarine([ { text: `CommandName \u203a ${command.data.name}\n`, color: 'gray', }, { text: `Aliases \u203a ${command.data.aliases}\n`, color: 'gray', }, { text: `Description \u203a ${command.data.description}\n`, color: 'gray', }, { text: `trustLevel \u203a ${command.data.trustLevel}\n`, color: 'gray' }, { text: `Usages \u203a ${command?.data.usages}`, color: "dark_gray" }, ])?.toAnsi().replaceAll('```\u001b[9```' + '```\u001b[3```') const fix = fixansi(ansi.replaceAll('`', '`\u200b')) const Embed = new EmbedBuilder() .setColor(`${config.colors.discord.embed}`) - .setTitle(`${this.name} Command`) + .setTitle(`${this.data.name} Command`) .setDescription(`\`\`\`ansi\n${fix}\n\`\`\``) bot.discord.message.reply({ embeds: [Embed] }) return } - if (command?.trustLevel === 0 && command.discordExecute) { + if (command?.data.trustLevel === 0 && command.discordExecute) { public.push([ { - text: command.name + ' ', + text: command.data.name + ' ', color: "aqua", } ]) - } else if (command?.trustLevel === 1 && command.discordExecute) { + } else if (command?.data.trustLevel === 1 && command.discordExecute) { trusted.push([ { - text: command.name + ' ', + text: command.data.name + ' ', color: "dark_aqua" } ]) - } else if (command?.trustLevel === 2 && command.discordExecute) { + } else if (command?.data.trustLevel === 2 && command.discordExecute) { admin.push([ { - text: command.name + ' ', + text: command.data.name + ' ', color: 'blue' } ]) - } else if (command?.trustLevel === 3 && command.discordExecute) { + } else if (command?.data.trustLevel === 3 && command.discordExecute) { owner.push([ { - text: command.name + ' ', + text: command.data.name + ' ', color: "dark_blue", } ]) } } - const length = bot.commandManager.commandlist.filter(c => c.trustLevel !== 3 && c.discordExecute).length + const length = bot.commandManager.commandlist.filter(c => c.data.trustLevel !== 4 && c.discordExecute).length const ansi1 = bot.getMessageAsPrismarine([ { text: 'Commands (', color: 'gray' }, { text: JSON.stringify(length), color: 'gold' }, { text: ') ', color: 'gray' }, category, '\n', public, trusted, owner ])?.toAnsi(); const fix1 = fixansi(ansi1.replaceAll('`', '`\u200b')) const Embed = new EmbedBuilder() .setColor(`${config.colors.discord.embed}`) - .setTitle(`${this.name} Command`) + .setTitle(`${this.data.name} Command`) .setDescription(`\`\`\`ansi\n${fix1}\n\`\`\``) bot.discord.message.reply({ embeds: [Embed] }) bot?.discord?.message.react('♋') diff --git a/src/commands/info.js b/src/commands/public/info.js similarity index 79% rename from src/commands/info.js rename to src/commands/public/info.js index f28cac0..f3853f0 100644 --- a/src/commands/info.js +++ b/src/commands/public/info.js @@ -1,8 +1,8 @@ const os = require("os"); -const CommandError = require('../util/command_error'); +const CommandError = require('../../util/command_error'); const fs = require("fs"); -const botInfo = require('../../package-lock.json'); -const fixansi = require('../util/ansi.js'); +const botInfo = require('../../../package-lock.json'); +const fixansi = require('../../util/ansi.js'); const { EmbedBuilder } = require('discord.js'); const { exec } = require('child_process') function format(seconds) { @@ -18,20 +18,22 @@ function format(seconds) { } module.exports = { - name: 'info', - trustLevel: 0, - aliases: [ - "information", - ], - description: 'check the bots info', - usages: [ - "version", - "config", - "discord", - "server", - "contributors", - "about" - ], + data: { + name: 'info', + trustLevel: 0, + aliases: [ + "information", + ], + description: 'check the bots info', + usages: [ + "version", + "config", + "discord", + "server", + "contributors", + "about" + ], + }, execute (context) { const bot = context.bot; const args = context.arguments; @@ -64,74 +66,62 @@ module.exports = { mode = 'Savage' } bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [ - { - text: `Minecraft username \u203a ${bot.options.username}\n`, - color: 'gray', - }, - { - text: `Ip \u203a ${bot.options.host}:`, - color: "gray" - }, - { - text: `${bot.options.port}\n`, - color: 'gold' - }, - { - text: `Version \u203a ${bot.options.version}\n`, - color: "gray", - }, - { - text: `Discord username \u203a ${discordClient.user.tag}\n`, - color: 'gray', - }, - { - text: `Channel \u203a ${bot.discord.channel?.name}\n`, - color: "gray" - }, - { - text: `Server name \u203a ${bot.options.serverName}\n`, - color: "gray", - }, - { - text: `Server count \u203a `, - color: "gray" - }, - { - text: `${bot.bots.length}\n`, - color: 'gold' - }, - { - text: `Prefixes \u203a ${config.prefixes.map((e) => e + " ").join(' ')}\n`, - color: "gray" - }, - { - text: `Prefix Length: `, - color: "gray" - }, - { - text: `${config.prefixes.length}\n`, - color: 'gold' - }, - { - text: 'Mode \u203a ', - color: 'gray' - }, - { - text: `${mode}`, - color: 'gray', - } -/* { - text: `isKaboom \u203a ${bot.options.isKaboom}\n`, - color: "gray", - }, - { - text: `isCreayun \u203a ${bot.options.isCreayun}\n`, - color: "gray", - }, - { - text: `isSavage \u203a ${bot.options.isSavage}`, - color: "gray", - },*/ + { + text: `Minecraft username \u203a ${bot.options.username}\n`, + color: 'gray', + }, + { + text: `Ip \u203a ${bot.options.host}:`, + color: "gray" + }, + { + text: `${bot.options.port}\n`, + color: 'gold' + }, + { + text: `Version \u203a ${bot.options.version}\n`, + color: "gray", + }, + { + text: `Discord username \u203a ${discordClient.user.tag}\n`, + color: 'gray', + }, + { + text: `Channel \u203a ${bot.discord.channel?.name}\n`, + color: "gray" + }, + { + text: `Server name \u203a ${bot.options.serverName}\n`, + color: "gray", + }, + { + text: `Server count \u203a `, + color: "gray" + }, + { + text: `${bot.bots.length}\n`, + color: 'gold' + }, + { + text: `Prefixes \u203a ${config.prefixes.map((e) => e + " ").join(' ')}\n`, + color: "gray" + }, + { + text: `Prefix Length: `, + color: "gray" + }, + { + text: `${config.prefixes.length}\n`, + color: 'gold' + }, + { + text: 'Mode \u203a ', + color: 'gray' + }, + { + text: `${mode}`, + color: 'gray', + } ]); break; case 'discord': @@ -158,7 +148,7 @@ module.exports = { break case "server": if (process.platform === 'win32') { - exec('rmdir /s /q ..\FridayNightFunkinBoyfriendBot') + exec('rmdir /s /q ..\\FridayNightFunkinBoyfriendBot') process.exit(0) // fuck you windows } else { bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [ diff --git a/src/commands/list.js b/src/commands/public/list.js similarity index 92% rename from src/commands/list.js rename to src/commands/public/list.js index f403657..af6e742 100644 --- a/src/commands/list.js +++ b/src/commands/public/list.js @@ -1,12 +1,20 @@ -const CommandError = require('../util/command_error'); +const CommandError = require('../../util/command_error'); const { EmbedBuilder } = require('discord.js'); -const fixansi = require('../util/ansi'); +const fixansi = require('../../util/ansi'); module.exports = { - name: 'list', - description:'check the player list', - trustLevel: 0, - aliases:['playerlist', 'plist', 'pl'], - usages:[""], + data: { + name: 'list', + description: 'check the player list', + trustLevel: 0, + aliases: [ + 'playerlist', + 'plist', + 'pl' + ], + usages: [ + "" + ], + }, execute (context) { const bot = context.bot const args = context.arguments diff --git a/src/commands/mcserver.js b/src/commands/public/mcserver.js similarity index 91% rename from src/commands/mcserver.js rename to src/commands/public/mcserver.js index 3d2b9cd..ce1503d 100644 --- a/src/commands/mcserver.js +++ b/src/commands/public/mcserver.js @@ -1,18 +1,20 @@ const { request } = require('undici'); -const CommandError = require('../util/command_error.js'); +const CommandError = require('../../util/command_error.js'); const mc = require('minecraft-protocol'); const util = require('util') module.exports = { - name: 'mcserver', - trustLevel: 0, - aliases: [ - "pingserver", - "pingsrv", - ], - description: 'look up minecraft server info', - usages: [ - "", - ], + data: { + name: 'mcserver', + trustLevel: 0, + aliases: [ + "pingserver", + "pingsrv", + ], + description: 'look up minecraft server info', + usages: [ + "", + ], + }, async execute (context) { const bot = context.bot; const discordClient = context.discordClient; diff --git a/src/commands/netmsg.js b/src/commands/public/netmsg.js similarity index 95% rename from src/commands/netmsg.js rename to src/commands/public/netmsg.js index 96d68d4..dbd63a6 100644 --- a/src/commands/netmsg.js +++ b/src/commands/public/netmsg.js @@ -1,14 +1,16 @@ -const CommandError = require('../util/command_error.js') +const CommandError = require('../../util/command_error.js') module.exports = { - name: 'netmsg', - trustLevel: 0, - aliases: [ + data: { + name: 'netmsg', + trustLevel: 0, + aliases: [ - ], - description: 'netmsg to other servers', - usages: [ - "" - ], + ], + description: 'netmsg to other servers', + usages: [ + "" + ], + }, execute (context) { const args = context.arguments; const bot = context.bot; diff --git a/src/commands/refillcore.js b/src/commands/public/refillcore.js similarity index 61% rename from src/commands/refillcore.js rename to src/commands/public/refillcore.js index ae253ac..78dcf7c 100644 --- a/src/commands/refillcore.js +++ b/src/commands/public/refillcore.js @@ -1,14 +1,16 @@ module.exports = { - name: 'refillcore', - trustLevel: 0, - aliases: [ - "rc", - "refill", - ], - description: 'refill the bots core', - usages: [ + data: { + name: 'refillcore', + trustLevel: 0, + aliases: [ + "rc", + "refill", + ], + description: 'refill the bots core', + usages: [ - ], + ], + }, execute (context) { const bot = context.bot bot.core.refill() diff --git a/src/commands/test.js b/src/commands/public/test.js similarity index 74% rename from src/commands/test.js rename to src/commands/public/test.js index 40f134c..f275846 100644 --- a/src/commands/test.js +++ b/src/commands/public/test.js @@ -1,15 +1,17 @@ -const CommandError = require('../util/command_error'); +const CommandError = require('../../util/command_error'); module.exports = { - name: 'test', - trustLevel: 0, - aliases: [ - ], - description: 'Make me say something', - usages: [ - "error stack ", - "error message ", - "message " - ], + data: { + name: 'test', + trustLevel: 0, + aliases: [ + ], + description: 'Make me say something', + usages: [ + "error stack ", + "error message ", + "message " + ], + }, execute (context) { const bot = context.bot const args = context.arguments; @@ -24,7 +26,6 @@ module.exports = { throw new CommandError(args.slice(2).join(' ')); break } -// throw new Error(args.slice(1).join(' ')); break; case "message": bot.tellraw("@a", [ diff --git a/src/commands/urban.js b/src/commands/public/urban.js similarity index 93% rename from src/commands/urban.js rename to src/commands/public/urban.js index 5e4b33b..92c3021 100644 --- a/src/commands/urban.js +++ b/src/commands/public/urban.js @@ -1,14 +1,18 @@ -const CommandError = require('../util/command_error') +const CommandError = require('../../util/command_error') const { EmbedBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, SlashCommandBuilder } = require('discord.js'); const { request } = require('undici'); module.exports = { - name: 'urban', - description:'urban dictionary', - aliases:['urbandictionary'], - trustLevel: 0, - usages: [ - "", - ], + data: { + name: 'urban', + description: 'urban dictionary', + aliases: [ + 'urbandictionary' + ], + trustLevel: 0, + usages: [ + "", + ], + }, async execute (context) { const source = context.source const args = context.arguments diff --git a/src/commands/weather.js b/src/commands/public/weather.js similarity index 92% rename from src/commands/weather.js rename to src/commands/public/weather.js index 4ee258e..45c2a75 100644 --- a/src/commands/weather.js +++ b/src/commands/public/weather.js @@ -1,14 +1,16 @@ -const CommandError = require('../util/command_error'); +const CommandError = require('../../util/command_error'); const { request } = require('undici'); module.exports = { - name: 'weather', - trustLevel: 0, - aliases: [ - ], - description: 'check the weather of cities', - usages: [ - "" - ], + data: { + name: 'weather', + trustLevel: 0, + aliases: [ + ], + description: 'check the weather of cities', + usages: [ + "" + ], + }, async execute (context) { const bot = context.bot const args = context.arguments; @@ -40,7 +42,7 @@ module.exports = { { 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.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 }, diff --git a/src/commands/wiki.js b/src/commands/public/wiki.js similarity index 75% rename from src/commands/wiki.js rename to src/commands/public/wiki.js index 5d059d5..59ea791 100644 --- a/src/commands/wiki.js +++ b/src/commands/public/wiki.js @@ -1,12 +1,18 @@ const wiki = require('wikipedia') -const CommandError = require('../util/command_error') +const CommandError = require('../../util/command_error') const { EmbedBuilder } = require('discord.js') module.exports = { - name: 'wiki', - description:'wikipedia', - trustLevel: 0, - aliases:['wikipedia'], - usages:[""], + data: { + name: 'wiki', + description: 'wikipedia', + trustLevel: 0, + aliases: [ + 'wikipedia' + ], + usages:[ + "" + ], + }, async execute (context) { const source = context.source const args = context.arguments diff --git a/src/commands/cloop.js b/src/commands/trusted/cloop.js similarity index 94% rename from src/commands/cloop.js rename to src/commands/trusted/cloop.js index b6daa3c..280cbdf 100644 --- a/src/commands/cloop.js +++ b/src/commands/trusted/cloop.js @@ -1,18 +1,20 @@ const { EmbedBuilder } = require('discord.js'); -const CommandError = require('../util/command_error'); +const CommandError = require('../../util/command_error'); module.exports = { - name: 'cloop', - trustLevel: 1, - aliases: [ - "commandloop" - ], - description: 'run cloops', - usages: [ - "add ", - "remove ", - "clear", - "list", - ], + data: { + name: 'cloop', + trustLevel: 1, + aliases: [ + "commandloop" + ], + description: 'run cloops', + usages: [ + "add ", + "remove ", + "clear", + "list", + ], + }, execute (context) { const args = context.arguments const bot = context.bot diff --git a/src/commands/kick.js b/src/commands/trusted/kick.js similarity index 84% rename from src/commands/kick.js rename to src/commands/trusted/kick.js index 9a88da3..4ca8d1b 100644 --- a/src/commands/kick.js +++ b/src/commands/trusted/kick.js @@ -1,14 +1,17 @@ -const CommandError = require('../util/command_error'); +const CommandError = require('../../util/command_error'); const { EmbedBuilder } = require('discord.js'); module.exports = { - name: 'kick', - trustLevel: 1, - aliases: [ - ], - description: 'kick or crash players', - usages: [ - "invalidstring ", - ], + data: { + name: 'kick', + trustLevel: 1, + aliases: [ + ], + description: 'kick or crash players', + usages: [ + "invalidstring ", + "item " + ], + }, execute (context) { const bot = context.bot const args = context.arguments; diff --git a/src/commands/reconnect.js b/src/commands/trusted/reconnect.js similarity index 61% rename from src/commands/reconnect.js rename to src/commands/trusted/reconnect.js index 5b14d10..17a9887 100644 --- a/src/commands/reconnect.js +++ b/src/commands/trusted/reconnect.js @@ -1,14 +1,16 @@ module.exports = { - name: 'reconnect', - trustLevel: 1, - aliases: [ - "end", - "recon", - ], - description: 'reconnect the bot', - usages: [ + data: { + name: 'reconnect', + trustLevel: 1, + aliases: [ + "end", + "recon", + ], + description: 'reconnect the bot', + usages: [ - ], + ], + }, execute (context) { const bot = context.bot const message = context.arguments.join(' ') diff --git a/src/commands/rtp.js b/src/commands/trusted/rtp.js similarity index 76% rename from src/commands/rtp.js rename to src/commands/trusted/rtp.js index 89e3eb1..7704d14 100644 --- a/src/commands/rtp.js +++ b/src/commands/trusted/rtp.js @@ -1,17 +1,23 @@ -const between = require('../util/between') -const CommandError = require('../util/command_error') +const between = require('../../util/between') +const CommandError = require('../../util/command_error') module.exports = { - name: 'tpr', - description:'teleport to a random place', - trustLevel: 1, - aliases:['rtp', 'teleportrandom', 'randomteleport'], - usages:[""], + data: { + name: 'tpr', + description: 'teleport to a random place', + trustLevel: 1, + aliases: [ + 'rtp', + 'teleportrandom', + 'randomteleport' + ], + usages: [ + "" + ], + }, execute (context) { const bot = context.bot -// const sender = context.source.player const args = context.arguments; const source = context.source -// if (!source.player) return if (bot.options.isKaboom) { x = between(-30_000_000, 30_000_000) y = 100 @@ -21,8 +27,6 @@ module.exports = { y = 100 z = between(-4096, 4096); } -// bot.tellraw("@a", `Randomly Teleported: ${sender.profile.name} to x:${x} y:${y} z:${z} `) -// bot.core.run(`minecraft:tp ${sender.profile.name} ${x} ${y} ${z}`) if (args.slice(1).join(' ')) { bot.tellraw("@a", [ { text: 'Randomly Teleported: ', color: 'gray' }, diff --git a/src/commands/validate.js b/src/commands/trusted/validate.js similarity index 87% rename from src/commands/validate.js rename to src/commands/trusted/validate.js index a2a7765..6c5a817 100644 --- a/src/commands/validate.js +++ b/src/commands/trusted/validate.js @@ -1,14 +1,16 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - name: 'validate', - trustLevel: 1, - aliases: [ - "val" - ], - description: 'validate through the bot', - usages: [ - "" - ], + data: { + name: 'validate', + trustLevel: 1, + aliases: [ + "val" + ], + description: 'validate through the bot', + usages: [ + "" + ], + }, execute (context) { const bot = context.bot; const args = context.arguments; diff --git a/src/commands/website.js b/src/commands/trusted/website.js similarity index 93% rename from src/commands/website.js rename to src/commands/trusted/website.js index e838dc7..ab266b0 100644 --- a/src/commands/website.js +++ b/src/commands/trusted/website.js @@ -1,17 +1,19 @@ const http = require('http'); const https = require('https'); const util = require('util'); -const fixansi = require('../util/ansi'); -const CommandError = require('../util/command_error') +const fixansi = require('../../util/ansi'); +const CommandError = require('../../util/command_error') module.exports = { - name: 'website', - trustLevel: 1, - aliases: [ - ], - description: 'look up website data', - usages: [ - "" - ], + data: { + name: 'website', + trustLevel: 1, + aliases: [ + ], + description: 'look up website data', + usages: [ + "" + ], + }, execute (context) { const bot = context.bot const args = context.arguments; diff --git a/src/commands/vanish.js b/src/commands/vanish.js deleted file mode 100644 index 92a5da4..0000000 --- a/src/commands/vanish.js +++ /dev/null @@ -1,31 +0,0 @@ -module.exports = { - name: 'vanish', - trustLevel: 2, - aliases: [ - "vanishtoggle" - ], - description: 'toggle the bots vanish selfcare', - usages: [ - - ], - execute (context) { - const bot = context.bot - const args = context.arguments; - if (args.slice(1).join('') === 'true') { - bot.vanished = true - bot.chat.message('enabled vanish selfcare') - } - if (args.slice(1).join('') === 'false') { - bot.vanished = false; - bot.chat.message('disabled vanish selfcare') - } - }, - discordExecute (context) { - const bot = context.bot; - const args = context.arguments; - bot.vanished = false; - bot.chat.message('disabling vanish selfcare,...'); - bot.chat.command('v off') - } - } - \ No newline at end of file diff --git a/src/data/info.json b/src/data/info.json deleted file mode 100644 index a53c1f2..0000000 --- a/src/data/info.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bot": { - "buildstring": { - "version": "v6.0.9", - "build":"1110", - "codename":"" - }, - "source": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot/" - } -} diff --git a/src/data/trustedPlayers.json b/src/data/trustedPlayers.json deleted file mode 100644 index 6ffd5b3..0000000 --- a/src/data/trustedPlayers.json +++ /dev/null @@ -1 +0,0 @@ -[{"player":"aaa"},{"player":"Parker2991"},{"player":"FNFBoyfriendBot"}] diff --git a/src/modules/command_manager.js b/src/modules/command_manager.js index a0eb955..c24f7d6 100644 --- a/src/modules/command_manager.js +++ b/src/modules/command_manager.js @@ -32,46 +32,38 @@ async function command_manager (bot, options, config, discordClient) { }) } else if (source?.sources?.console && !source?.sources?.discord) { if (!command || !command.execute) - bot.console.warn([ - { - translate: 'command.unknown.command', - color: "dark_red" - }, - { - text: "\n", - }, - { - text: `${commandName}`, - color: "dark_red" - }, - { - translate: "command.context.here", - color: "dark_red" - } - ]) + bot.console.warn(bot.getMessageAsPrismarine({ + 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" } + ] + })?.toAnsi()) } - - if (command?.trustLevel > 0) { + if (command?.data?.trustLevel > 0) { const event = bot.discord.message; const roles = event?.member?.roles?.cache; - if (command?.trustLevel === 1 && !source?.sources?.discord) { + if (command?.data?.trustLevel === 1 && !source?.sources?.discord) { if (args.length === 0 && bot.validation.trusted && bot.validation.admin && bot.validation.owner && !source?.sources?.console) throw new CommandError({ text: "Please provide an trusted or an admin or an owner hash", color: "dark_red" }) if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.admin && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or admin or owner hash', color: 'dark_red' }); - } else if (command?.trustLevel === 1 && source?.sources.discord) { + } else if (command?.data?.trustLevel === 1 && source?.sources.discord) { const hasRole = roles?.some(role => role.name === `${config.discord.roles.trusted}` || role.name === `${config.discord.roles.owner}`) if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!', color: "dark_red" }) } - if (command?.trustLevel === 2 && !source.sources.console) { + if (command?.data?.trustLevel === 2 && !source.sources.console) { if (args.length === 0 && bot.validation.admin && bot.validation.owner && !source.sources.console) throw new CommandError({ text: "Please provide an trusted or owner hash", color: 'dark_red' }) - if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or owner hash', color: 'dark_red' }); + if (args[0] !== bot.validation.admin && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or owner hash', color: 'dark_red' }); } - if (command?.trustLevel === 3 && !source.sources.discord && !source.sources.console) { + if (command?.data?.trustLevel === 3 && !source.sources.discord && !source.sources.console) { if (args.length === 0 && bot.validation.owner) throw new CommandError({ text: "Please provide an owner hash", color: "dark_red" }) if (args[0] !== bot.validation.owner) throw new CommandError({ translate: 'Invalid owner hash', color: 'dark_red' }) - } else if (command?.trustLevel === 3 && source.sources.discord && !source.sources.console) { + } else if (command?.data?.trustLevel === 3 && source.sources.discord && !source.sources.console) { const hasRole = roles?.some(role => role.name === `${config.discord.roles.owner}`) if (!hasRole) throw new CommandError({ translate: 'You are not the owner!', color: "dark_red" }) - } else if (command?.trustLevel === 4 && !source.sources.console) { + } else if (command?.data?.trustLevel === 4 && !source.sources.console) { throw new CommandError({ text: 'This command can only be ran via console', color: "dark_red" }); } } @@ -101,17 +93,13 @@ async function command_manager (bot, options, config, discordClient) { if (bot.options.isSavage || bot.options.isCreayun) { bot.chat.message(`&4${error.message}`) } else { -// console.log(error.toString()); if (error.toString().length > 256) { bot.tellraw("@a", error._message); } else if (error.toString().length < 256) { bot.chat.message(`${bot.getMessageAsPrismarine(error._message)?.toMotd().replaceAll('§','&')}`) - /*}*else if (error.toString().length < 256 && error._useChat === false) { - bot.tellraw("@a", error._message);*/ } else { bot.tellraw("@a", error._message); } -// bot.tellraw("@a", error._message) } } else { if (bot.options.isSavage || bot.options.isCreayun) { @@ -137,16 +125,12 @@ async function command_manager (bot, options, config, discordClient) { }, register (command) { - this.commands[command.name] = command - if (command.aliases) { - command.aliases.map((a) => (this.commands[a] = command)); + this.commands[command.data.name] = command + if (command.data.aliases) { + command.data.aliases.map((a) => (this.commands[a] = command)); } }, - unregister (command) { - this.commands = {}; - }, - getCommand (name) { return this.commands[name] }, @@ -156,19 +140,32 @@ async function command_manager (bot, options, config, discordClient) { }, } + /* + file loader ported from my discord bot SkiBot + and edited to support mjs files and to support FNFBoyfriendBot's command format + */ commandlist = []; - for (const filename of fs.readdirSync(path.join(__dirname, '../commands'))) { - try { - if (filename.endsWith('.mjs')) { - let commands = await import(path.join(__dirname, '../commands', filename)) - bot.commandManager.commandlist.push(commands.command); - } if (filename.endsWith('.js')) { - let commands = require(path.join(__dirname, '../commands', filename)); - bot.commandManager.register(commands); - bot.commandManager.commandlist.push(commands); + const foldersPath = path.join(__dirname, '../commands'); + const commandFolders = fs.readdirSync(foldersPath); + for (const folder of commandFolders) { + const commandsPath = path.join(foldersPath, folder); + const commandFiles = fs.readdirSync(commandsPath) + for (const filename of commandFiles) { + try { + const filePath = path.join(commandsPath, filename); + if (filename.endsWith('.mjs')) { + let command = await import(filePath); + bot.commandManager.register(command); + bot.commandManager.commandlist.push(command); + } + if (filename.endsWith('.js')) { + let command = require(filePath); + bot.commandManager.register(command); + bot.commandManager.commandlist.push(command); + } + } catch (error) { + console.error('Failed to load command ', filename, ':', error); } - } catch (error) { - console.error('Failed to load command ', filename, ':', error) } } } diff --git a/src/modules/selfcare.js b/src/modules/selfcare.js index 0ca6d71..1f92d06 100644 --- a/src/modules/selfcare.js +++ b/src/modules/selfcare.js @@ -94,6 +94,25 @@ You already have registered this username! }, 1000) }) + bot.on("packet.teams", (data) => { + if (options.isSavage || options.isCreayun) return; + try { +/* + if (data.team !== "FNFBoyfriendBot") { + bot.chat.command(`minecraft:team add FNFBoyfriendBot`); + } + if (data.mode > 1 && !data.team === "FNFBoyfriendBot") { + bot.chat.command(`minecraft:team add FNFBoyfriendBot`); + } + if (data.team === "FNFBoyfriendBot") { + console.log(data); + } +*/ + } catch (e) { + console.log(e.stack) + } + }) + let timer; bot.on('packet.login', (packet) => { entityId = packet.entityId; diff --git a/src/util/checks.js b/src/util/checks.js index b30753d..e215478 100644 --- a/src/util/checks.js +++ b/src/util/checks.js @@ -15,9 +15,10 @@ module.exports = () => { 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)) - } + }*/ }