Make finding horses easier

This commit is contained in:
Dragon Fire
2020-10-27 00:12:46 -04:00
parent a3e8a56870
commit 3dba67088a
+6 -2
View File
@@ -16,8 +16,12 @@ module.exports = class HorseInfoCommand extends Command {
key: 'horse',
prompt: 'Which horse would you like to get information on?',
type: 'string',
oneOf: Object.values(horses).map(horse => horse.name.toLowerCase()),
parse: horse => horses.find(h => h.name.toLowerCase() === horse.toLowerCase())
validate: horse => {
const valid = horses.filter(h => h.name.toLowerCase().includes(horse.toLowerCase()));
if (valid.length > 1) return 'Multiple horses found. Please be more specific.';
return Boolean(horses.length);
},
parse: horse => horses.find(h => h.name.toLowerCase().includes(horse.toLowerCase()))
}
]
});