From 11dfcc7754c6210c6bf11c15badcf471e8d9149c Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 5 Nov 2024 05:05:10 +0100 Subject: [PATCH] Add count subcommand for custom command --- commands/misc/custom.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/commands/misc/custom.js b/commands/misc/custom.js index f684b3b..c797f3e 100644 --- a/commands/misc/custom.js +++ b/commands/misc/custom.js @@ -17,7 +17,8 @@ module.exports = { "custom remove - Delete your custom commands.", "custom owner - check owner of custom command", "custom list - list all custom commands", - "custom variables - list all variables you can use" + "custom variables - list all variables you can use", + "custom count - display the amount of custom commands" ], execute({message, args, client, prefix, owners}) { const customPath = 'data/customCommands.json'; @@ -58,7 +59,7 @@ module.exports = { case "list": const embed = new EmbedBuilder(); sendText = getAllCustomCommands(); - if(sendText != ""){ + if(sendText !== ""){ embed.setColor(15780145) embed.addFields( { name: "Custom commands", value: sendText }, @@ -86,6 +87,12 @@ module.exports = { case "rename": sendText = renameCustomCommand(customName, args[2], message.author.id); break; + case "count": + const customPath = './data/customCommands.json'; + let json = fs.readFileSync(customPath, 'utf8'); + let customCommands = JSON.parse(json) + sendText = `There are ${customCommands.length} custom commands in total`; + break; default: sendText = `Argument not recognized.\n"${prefix}help custom" to see all arguments you can use.` break;