feat: did you mean prompt

This commit is contained in:
TresAbhi committed 2023-04-22 01:58:42 +00:00
1 parent 64241febae
commit 7907c563e2
1 file changed
+6 -2
+6 -2
View File
@@ -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.`,
),
],
});