From 9c140b932c733acf8d815ef57ea5fe6a2f6510de Mon Sep 17 00:00:00 2001 From: KillerBossOriginal Date: Sat, 9 Dec 2023 22:40:53 +0100 Subject: [PATCH] v0.5.4 --- package.json | 2 +- src/CreditsManager.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 7cb33d2..aa10483 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tn-api.js", - "version": "0.5.3", + "version": "0.5.4", "description": "A Public Template for npm", "main": "build/index.js", "repository": "https://source.thundernetwork.org/ThunderNetworkRaD/tn-api.js", diff --git a/src/CreditsManager.ts b/src/CreditsManager.ts index 81de458..c00e95d 100644 --- a/src/CreditsManager.ts +++ b/src/CreditsManager.ts @@ -68,9 +68,9 @@ export default class CreditsManager { async pay(id: number, toPayID: number, amount: number) { if (amount < 0) throw new Error("Invalid Amount"); - let req = await axios.patch(`${this.URL}/credits/${id}`, { amount, to: toPayID }, { headers: { Authorization: `Bearer ${this.token}` } }); - if (req.status == 400 && req.data.error == "TOO_MANY_CREDITS") throw new Error("Not Enought Credits"); - if (req.status == 403 && req.data.error == "NO_NEGATIVE_AMOUNT") throw new Error("Invalid Amount"); + let req = await axios.patch(`${this.URL}/credits/${id}`, { amount, to: toPayID }, { headers: { Authorization: `Bearer ${this.token}` } }).catch(); + if (req.data.error == "TOO_MANY_CREDITS") throw new Error("Not Enought Credits"); + if (req.data.error == "NO_NEGATIVE_AMOUNT") throw new Error("Invalid Amount"); else if (req.status == 403) throw new Error("No Permission"); if (req.status == 404) throw new Error("User not Found"); }