Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
33 changes: 18 additions & 15 deletions src/utils/polyUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import axios from 'axios';

/**
* polyUtils
*
Expand All @@ -16,19 +14,22 @@ export default class polyUtils {
* @return {Promise<any>} User info
*/
public static async getUserInfoFromUsername(username: string): Promise<any> {
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;
}
Expand All @@ -42,11 +43,13 @@ export default class polyUtils {
* @return {Promise<any>} User info
*/
public static async getUserInfoFromID(id: number): Promise<any> {
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;
}
Expand Down
Loading