Change forEach loop to filter
This commit is contained in:
parent
4e41a035ed
commit
4adc97d6ae
1 changed files with 3 additions and 8 deletions
|
@ -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;
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue