removed dev comments

This commit is contained in:
2022-01-31 17:07:59 -06:00
parent c2c59e53ca
commit 50c297bfea
2 changed files with 7 additions and 57 deletions

30
dist/api.js vendored
View File

@@ -25,30 +25,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.getPlayerInteraction = exports.getPlayer = void 0;
const cheerio = __importStar(require("cheerio"));
const https_1 = __importDefault(require("https"));
//making long regex rather than splitting the string at ":" because regex would be easier to debug than logic in the case the website changes
//while names cant have spaces, the name slot in ogtitle could be shown as "No Player Name" which has spaces
const uniteApiRegex = {
//$1 = name, $2 = id
ogtitle: /unite api - (.+) \((.*)\)/i,
//$1 = level, $2 = rank, $3 = elo/class (rest is found by splitting each line)
ogdescription: [
//line 1
[
/lv\.(\d+) (\w+) \((\d+)\)/i,
/lv\.(\d+) (\w+): class (\d+)/i //other
],
/lv\.(\d+) (\w+) \((\d+)\)/i,
/lv\.(\d+) (\w+): class (\d+)/i //other
]
};
/*
og:title
Unite API - IanWhysp (X188GF7)
og:description
Pokémon Unite : Lv.40 Master (1741)
Battles : 1089
Wins : 576
Win Rate : 52%
*/
/**
* gets the html of the uniteApi page for the player
* @param name name of player
@@ -127,7 +112,7 @@ function readHTML(html) {
{
//will be only text after "pokemon unite:"
let line = lines[0].split(':').slice(1).join(':').trim();
let regex = uniteApiRegex.ogdescription[0];
let regex = uniteApiRegex.ogdescription;
if (regex[0].test(line)) { //is master/has elo
let regexData = line.match(regex[0]);
if (!regexData || regexData.length < 4)
@@ -161,15 +146,6 @@ function readHTML(html) {
break;
}
});
/*let data = uniteApiRegex.ogdescription.exec(attr.content);
if (data !== null && data.length >= 7) {
foundData.level = data[1];
foundData.rank = data[2];
foundData.elo = data[3];
foundData.battles = data[4];
foundData.wins = data[5];
foundData.winrate = data[6];
}*/
}
});
return foundData;

View File

@@ -3,19 +3,13 @@ import { CommandInteraction } from 'discord.js';
import { IncomingMessage } from 'http';
import http from 'https';
//making long regex rather than splitting the string at ":" because regex would be easier to debug than logic in the case the website changes
//while names cant have spaces, the name slot in ogtitle could be shown as "No Player Name" which has spaces
const uniteApiRegex = {
//$1 = name, $2 = id
ogtitle: /unite api - (.+) \((.*)\)/i,
//$1 = level, $2 = rank, $3 = elo/class (rest is found by splitting each line)
ogdescription: [
//line 1
[
/lv\.(\d+) (\w+) \((\d+)\)/i, //master
/lv\.(\d+) (\w+): class (\d+)/i //other
],
ogdescription: [ //just the first line
/lv\.(\d+) (\w+) \((\d+)\)/i, //master
/lv\.(\d+) (\w+): class (\d+)/i //other
]
}
@@ -31,16 +25,6 @@ type uniteApiData = {
wins: string,
winrate: string
}
/*
og:title
Unite API - IanWhysp (X188GF7)
og:description
Pokémon Unite : Lv.40 Master (1741)
Battles : 1089
Wins : 576
Win Rate : 52%
*/
/**
* gets the html of the uniteApi page for the player
@@ -142,7 +126,7 @@ function readHTML(html: string): uniteApiData {
//will be only text after "pokemon unite:"
let line = lines[0].split(':').slice(1).join(':').trim();
let regex = uniteApiRegex.ogdescription[0];
let regex = uniteApiRegex.ogdescription;
if (regex[0].test(line)) { //is master/has elo
@@ -193,16 +177,6 @@ function readHTML(html: string): uniteApiData {
});
/*let data = uniteApiRegex.ogdescription.exec(attr.content);
if (data !== null && data.length >= 7) {
foundData.level = data[1];
foundData.rank = data[2];
foundData.elo = data[3];
foundData.battles = data[4];
foundData.wins = data[5];
foundData.winrate = data[6];
}*/
}
})