From 7702f10587d138bbe358538a461e065f108c3f31 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Thu, 19 Dec 2024 18:56:53 +0100 Subject: [PATCH] Use set for listing all custom commands --- commands/misc/custom.js | 2 +- util/custom_commands/getAllCustomCommands.js | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/commands/misc/custom.js b/commands/misc/custom.js index e39ffb8..39e7ad4 100644 --- a/commands/misc/custom.js +++ b/commands/misc/custom.js @@ -61,7 +61,7 @@ module.exports = { } case "list": { const embed = new EmbedBuilder(); - sendText = getAllCustomCommands(); + sendText = getAllCustomCommands(client); if(sendText !== ""){ embed.setColor(15780145) embed.addFields( diff --git a/util/custom_commands/getAllCustomCommands.js b/util/custom_commands/getAllCustomCommands.js index fba3b28..b40cc6f 100644 --- a/util/custom_commands/getAllCustomCommands.js +++ b/util/custom_commands/getAllCustomCommands.js @@ -1,13 +1,7 @@ -const fs = require('fs'); -module.exports = function(){ - const customPath = './data/customCommands.json'; + + +module.exports = function(client){ let list = ""; - - let json = fs.readFileSync(customPath, 'utf8'); - let customCommands = JSON.parse(json) - customCommands.forEach(function (customCommand) { - list = list + customCommand.customName+"\n"; - }); - + client.customCommands.keys().forEach(commandName => list += `${commandName}\n`) return list; } \ No newline at end of file