Added filter presets function to utils and code formatted
This commit is contained in:
@@ -139,3 +139,25 @@ exports.filterAutocompleteValues = async (interaction, options) => {
|
|||||||
filtered.map(option => ({ name: option, value: option })),
|
filtered.map(option => ({ name: option, value: option })),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter an array of nodeObjects to get all unique presets within
|
||||||
|
*
|
||||||
|
* @param {Array} nodeObjects An array of nodeObjects to get the presets from
|
||||||
|
* @returns {Array} Presets available from given nodeObjects
|
||||||
|
*/
|
||||||
|
exports.filterPresetsAvailable = async (nodeObjects) => {
|
||||||
|
log.DEBUG("Node objects: ", nodeObjects);
|
||||||
|
var presetsAvailable = [];
|
||||||
|
for (const nodeObject of nodeObjects) {
|
||||||
|
log.DEBUG("Node object: ", nodeObject);
|
||||||
|
presetsAvailable.push.apply(presetsAvailable, nodeObject.presets);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.DEBUG("All Presets available: ", presetsAvailable);
|
||||||
|
|
||||||
|
// Remove duplicates
|
||||||
|
presetsAvailable = [...new Set(presetsAvailable)];
|
||||||
|
log.DEBUG("DeDuped Presets available: ", presetsAvailable);
|
||||||
|
return presetsAvailable;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user