From 30139df2c1b8bd0e846d440a48a4c10786ecaba3 Mon Sep 17 00:00:00 2001 From: KillerBossOriginal Date: Sat, 9 Dec 2023 22:12:35 +0100 Subject: [PATCH] v0.5.2 --- package.json | 2 +- src/CreditsManager.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index aaee239..468f32e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tn-api.js", - "version": "0.5.1", + "version": "0.5.2", "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 ebdd929..6d30efb 100644 --- a/src/CreditsManager.ts +++ b/src/CreditsManager.ts @@ -66,6 +66,8 @@ export default class CreditsManager { * @return {void} */ 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 == 403) throw new Error("No Permission"); if (req.status == 404) throw new Error("User not Found");