updated to es2020
This commit is contained in:
43
dist/api.js
vendored
43
dist/api.js
vendored
@@ -18,15 +18,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
@@ -107,7 +98,7 @@ function readHTML(html) {
|
||||
winrate: ""
|
||||
};
|
||||
//filter down to just ones named "og:..."
|
||||
metaElems = metaElems.filter(el => { var _a; return (_a = el.attribs.property) === null || _a === void 0 ? void 0 : _a.startsWith('og:'); });
|
||||
metaElems = metaElems.filter(el => el.attribs.property?.startsWith('og:'));
|
||||
metaElems.forEach(el => {
|
||||
let attr = el.attribs;
|
||||
if (attr.property === 'og:title') {
|
||||
@@ -201,30 +192,26 @@ function verifyData(data) {
|
||||
* @param name name of player
|
||||
* @returns player data
|
||||
*/
|
||||
function getPlayer(name) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let html = yield getHTML(name);
|
||||
let data = readHTML(html);
|
||||
if (verifyData(data))
|
||||
return data;
|
||||
return null;
|
||||
});
|
||||
async function getPlayer(name) {
|
||||
let html = await getHTML(name);
|
||||
let data = readHTML(html);
|
||||
if (verifyData(data))
|
||||
return data;
|
||||
return null;
|
||||
}
|
||||
exports.getPlayer = getPlayer;
|
||||
/**
|
||||
* calls getPlayer() with the name from the interaction
|
||||
* @param interaction discord interaction
|
||||
*/
|
||||
function getPlayerInteraction(interaction) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let username = interaction.options.getString('username', true);
|
||||
yield interaction.deferReply();
|
||||
let data = yield getPlayer(username);
|
||||
if (data === null)
|
||||
yield interaction.editReply('Unable to find user');
|
||||
else
|
||||
yield interaction.editReply('```\n' + JSON.stringify(data, null, 2) + '\n```');
|
||||
});
|
||||
async function getPlayerInteraction(interaction) {
|
||||
let username = interaction.options.getString('username', true);
|
||||
await interaction.deferReply();
|
||||
let data = await getPlayer(username);
|
||||
if (data === null)
|
||||
await interaction.editReply('Unable to find user');
|
||||
else
|
||||
await interaction.editReply('```\n' + JSON.stringify(data, null, 2) + '\n```');
|
||||
}
|
||||
exports.getPlayerInteraction = getPlayerInteraction;
|
||||
//await getPlayer('IanWhysp')
|
||||
|
||||
Reference in New Issue
Block a user