From 3dba67088a60d97847ba3b6cbb11bd46f5010217 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Tue, 27 Oct 2020 00:12:46 -0400 Subject: [PATCH] Make finding horses easier --- commands/games-sp/horse-info.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/commands/games-sp/horse-info.js b/commands/games-sp/horse-info.js index 4605f423..6881049b 100644 --- a/commands/games-sp/horse-info.js +++ b/commands/games-sp/horse-info.js @@ -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())) } ] });