From 4adc97d6aecbb7c253ac6f9d02330cc9a5d943b0 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Sun, 10 Apr 2022 21:51:44 +0200 Subject: [PATCH] Change forEach loop to filter --- util/custom_commands/getOwnerOfCustomCommand.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/util/custom_commands/getOwnerOfCustomCommand.js b/util/custom_commands/getOwnerOfCustomCommand.js index bdcf156..f0106c0 100644 --- a/util/custom_commands/getOwnerOfCustomCommand.js +++ b/util/custom_commands/getOwnerOfCustomCommand.js @@ -1,15 +1,10 @@ const fs = require('fs'); module.exports = function(customName){ - let author = false; const customPath = './data/customCommands.json'; let json = fs.readFileSync(customPath, 'utf8'); let customCommands = JSON.parse(json) - customCommands.forEach(function (customCommand) { - if (customCommand.customName === customName) { - author = customCommand.author; - } - }); - - return author; + let author = customCommands.filter(customCommands => customCommands.customName === customName); + if(author.length === 0) return false; + return author[0].author; } \ No newline at end of file