From 7907c563e2cd34f6a1c3f78108ef21094684b043 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Sat, 22 Apr 2023 01:55:44 +0000 Subject: [PATCH] feat: did you mean prompt --- src/utilities/getBlitzAccount.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utilities/getBlitzAccount.ts b/src/utilities/getBlitzAccount.ts index e25055ec8..36c19176d 100644 --- a/src/utilities/getBlitzAccount.ts +++ b/src/utilities/getBlitzAccount.ts @@ -18,7 +18,7 @@ export default async function getBlitzAccount( `https://api.wotblitz.${server}/wotb/account/list/?application_id=${process.env.WARGAMING_APPLICATION_ID}&search=${ign}`, ).then((response) => response.json())) as AccountList; - if (players?.data?.[0]?.nickname === ign) { + if (players?.data && players.data[0]?.nickname === ign) { callback(players.data[0]); } else { // no exact match @@ -36,7 +36,11 @@ export default async function getBlitzAccount( : 0 } similarly spelled account${ players?.data?.length !== 1 ? 's' : '' - }. Try re-running the command. Don't make typos and capitalize correctly.`, + }. ${ + players?.data && players.data.length > 0 + ? `Did you mean "${players.data[0].nickname}"? ` + : '' + }Try re-running the command, don't make typos, and capitalize correctly.`, ), ], });