Skip to content

Commit

Permalink
fix: NaN in ratios
Browse files Browse the repository at this point in the history
  • Loading branch information
kk committed Nov 8, 2023
1 parent 85a42ac commit 8fa56e9
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/util/CommonUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export const formatRatio = (num1: number, num2: number) => {
const playerValue = num1 / num2;
let displayValue: number | string = playerValue;
if (!isFinite(playerValue)) displayValue = ~~Number((((0 - 18) / 0) * 100).toFixed(2));
if (!Number.isInteger(playerValue)) displayValue = playerValue.toFixed(2);
else if (!Number.isInteger(playerValue)) displayValue = playerValue.toFixed(2);
else if (Number.isNaN(playerValue)) displayValue = 0;
return displayValue.toString();
};

Expand All @@ -39,11 +40,7 @@ export const useHypixelApi = async (botInstance: MinecraftBot, apiCaller: (hypix
const hypixelClient = new SeraphCache();
return await apiCaller(hypixelClient);
} catch (exceptionThrown) {
if (exceptionThrown instanceof InvalidKeyError) {
botInstance.getMineflayerInstance().chat("Invalid API Key, Generating...");
await botInstance.getMineflayerInstance().waitForTicks(40);
botInstance.getMineflayerInstance().chat("/api new");
} else if (exceptionThrown instanceof AxiosError) {
if (exceptionThrown instanceof AxiosError) {
botInstance.getMineflayerInstance().chat("This player is invalid! Maybe you typed their name incorrectly.");
}
}
Expand Down

0 comments on commit 8fa56e9

Please sign in to comment.