new commands update for the bot
This commit is contained in:
55
src/services/PlayerService.js
Normal file
55
src/services/PlayerService.js
Normal 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;
|
||||
Reference in New Issue
Block a user