mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-05 22:01:54 +02:00
Make finding horses easier
This commit is contained in:
@@ -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()))
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user