This commit is contained in:
KillerBossOriginal 2023-12-09 22:12:35 +01:00
parent fcdbc5eecd
commit 30139df2c1
2 changed files with 3 additions and 1 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "tn-api.js", "name": "tn-api.js",
"version": "0.5.1", "version": "0.5.2",
"description": "A Public Template for npm", "description": "A Public Template for npm",
"main": "build/index.js", "main": "build/index.js",
"repository": "https://source.thundernetwork.org/ThunderNetworkRaD/tn-api.js", "repository": "https://source.thundernetwork.org/ThunderNetworkRaD/tn-api.js",

View file

@ -66,6 +66,8 @@ export default class CreditsManager {
* @return {void} * @return {void}
*/ */
async pay(id: number, toPayID: number, amount: number) { 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}` } }); 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 == 403) throw new Error("No Permission");
if (req.status == 404) throw new Error("User not Found"); if (req.status == 404) throw new Error("User not Found");