new commands update for the bot

This commit is contained in:
VinceC
2024-11-07 17:28:00 -06:00
parent 7b431e0406
commit 2b577c5be1
9 changed files with 865 additions and 324 deletions

View File

@@ -0,0 +1,55 @@
// src/services/PlayerService.js
const axios = require('axios');
class PlayerService {
constructor() {
this.baseUrl = 'https://www.vrbattles.gg';
}
async findUserByUsername(username) {
try {
const response = await axios.get(
`${this.baseUrl}/api/get_player_data_by_username/${encodeURIComponent(username)}`,
{
timeout: 5000
}
);
return response.data;
} catch (error) {
console.error('Error fetching user data:', error);
return null;
}
}
getBadgeImageUrl(badgeName) {
if (!badgeName) {
return `${this.baseUrl}/assets/images/badges/xp_badges/A/BADGE_A1_72p.png`;
}
badgeName = badgeName.toUpperCase().replace(/ /g, '_');
let badgeUrl = `${this.baseUrl}/assets/images/badges/xp_badges/`;
if (badgeName.startsWith('A')) {
badgeUrl += 'A/';
} else if (badgeName.startsWith('B')) {
badgeUrl += 'B/';
} else if (badgeName.startsWith('C')) {
badgeUrl += 'C/';
} else {
badgeUrl += 'A/';
}
badgeUrl += `BADGE_${badgeName}_72p.png`;
return badgeUrl;
}
getProfileUrl(username) {
return `${this.baseUrl}/profile/${username}`;
}
getStatsUrl(username) {
return `${this.baseUrl}/profile/${username}/stats`;
}
}
module.exports = PlayerService;