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 diff --git a/package.json b/package.json index ed95e2d..989d39b 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,14 @@ { "dependencies": { - "axios": "^1.7.3", - "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", 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; }