From 2103f973467665bed62b8bbab86ef5f9364c58eb Mon Sep 17 00:00:00 2001 From: StarManTheGamer <68450308+StarManTheGamer@users.noreply.github.com> Date: Tue, 7 Jan 2025 19:55:46 -0600 Subject: [PATCH 1/4] Migrate from axios to fetch --- src/utils/polyUtils.ts | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/utils/polyUtils.ts b/src/utils/polyUtils.ts index dc3e7c8..b37d2ab 100644 --- a/src/utils/polyUtils.ts +++ b/src/utils/polyUtils.ts @@ -1,5 +1,3 @@ -import axios from 'axios'; - /** * polyUtils * @@ -16,19 +14,22 @@ export default class polyUtils { * @return {Promise} User info */ public static async getUserInfoFromUsername(username: string): Promise { - const response = await axios.get(`https://api.polytoria.com/v1/users/find?username=${username}`, { - validateStatus: () => true, - }); + const response = await fetch(`https://api.polytoria.com/v1/users/find?username=${username}`); + + if (!response.ok) { + throw new Error(`Failed to fetch user info for username: ${username}`); + } - // get id - const data = response.data; + const data = await response.json(); const id = data.id; - const idResponse = await axios.get(`https://api.polytoria.com/v1/users/${id}`, { - validateStatus: () => true, - }); + const idResponse = await fetch(`https://api.polytoria.com/v1/users/${id}`); - const userData = idResponse.data; + if (!idResponse.ok) { + throw new Error(`Failed to fetch user info for ID: ${id}`); + } + + const userData = await idResponse.json(); return userData; } @@ -42,11 +43,13 @@ export default class polyUtils { * @return {Promise} User info */ public static async getUserInfoFromID(id: number): Promise { - const response = await axios.get(`https://api.polytoria.com/v1/users/${id}`, { - validateStatus: () => true, - }); + const response = await fetch(`https://api.polytoria.com/v1/users/${id}`); + + if (!response.ok) { + throw new Error(`Failed to fetch user info for ID: ${id}`); + } - const userData = response.data; + const userData = await response.json(); return userData; } From 758a536d80bd3aa97143a3456f7af685f1412cc5 Mon Sep 17 00:00:00 2001 From: StarManTheGamer <68450308+StarManTheGamer@users.noreply.github.com> Date: Tue, 7 Jan 2025 19:56:03 -0600 Subject: [PATCH 2/4] Remove axios --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index ed95e2d..2c2e4a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,5 @@ { "dependencies": { - "axios": "^1.7.3", "chalk": "^5.3.0", "discord-command-parser": "^1.5.3", "discord.js": "^14.16.2", From 92401b3e96f85bd60a8f02497882140cb182d4cf Mon Sep 17 00:00:00 2001 From: StarManTheGamer <68450308+StarManTheGamer@users.noreply.github.com> Date: Tue, 7 Jan 2025 20:00:33 -0600 Subject: [PATCH 3/4] Update dependencies --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2c2e4a6..989d39b 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "dependencies": { - "chalk": "^5.3.0", + "chalk": "^5.4.1", "discord-command-parser": "^1.5.3", - "discord.js": "^14.16.2", - "dotenv": "^16.4.5", - "firebase-admin": "^12.3.1", + "discord.js": "^14.17.3", + "dotenv": "^16.4.7", + "firebase-admin": "^13.0.2", "parse-string-boolean": "^1.0.1", "path": "^0.12.7", "to-boolean": "^1.0.0", - "typescript": "^5.5.4" + "typescript": "^5.7.2" }, "name": "poly-verify", "description": "Polytoria Community Verify", From cdb2011920fbdccf1cbefb6baf42ebc8adaee59a Mon Sep 17 00:00:00 2001 From: StarManTheGamer <68450308+StarManTheGamer@users.noreply.github.com> Date: Tue, 7 Jan 2025 20:05:42 -0600 Subject: [PATCH 4/4] Update main.yml --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a6caa92..fa6baea 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,6 +19,7 @@ jobs: run: npm install - name: Pull latest changes + if: github.event_name == 'push' && github.ref == 'refs/heads/main' run: git pull - name: Test build