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');
|
const fs = require('fs');
|
||||||
module.exports = function(customName){
|
module.exports = function(customName){
|
||||||
let author = false;
|
|
||||||
const customPath = './data/customCommands.json';
|
const customPath = './data/customCommands.json';
|
||||||
let json = fs.readFileSync(customPath, 'utf8');
|
let json = fs.readFileSync(customPath, 'utf8');
|
||||||
let customCommands = JSON.parse(json)
|
let customCommands = JSON.parse(json)
|
||||||
customCommands.forEach(function (customCommand) {
|
let author = customCommands.filter(customCommands => customCommands.customName === customName);
|
||||||
if (customCommand.customName === customName) {
|
if(author.length === 0) return false;
|
||||||
author = customCommand.author;
|
return author[0].author;
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return author;
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue