Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ((
- /** @type {string} */ streamUptimeString,
- /** @type {string} */ streamStartDateString,
- /** @type {string} */ urlEncodedGetMmrHistoryResponseJson,
- ) => {
- /* streamStartDateString will be a date string even if the channel is not currently live (the date will be the current
- date). This may be a Nightbot bug. This is why streamUptimeString is needed to check whether the channel is live */
- if (/\bnot live\b/i.test(streamUptimeString)) {
- return 'Draxick is not live';
- }
- const streamStartDate = new Date(streamStartDateString);
- if (Number.isNaN(streamStartDate.valueOf())) {
- return `Failed to parse stream start date: ${streamStartDateString}`.slice(0, 400);
- }
- const getMmrHistoryResponseJson = decodeURIComponent(urlEncodedGetMmrHistoryResponseJson);
- if (/^Error Connecting To Remote Server\b/i.test(getMmrHistoryResponseJson)) {
- return 'No games played yet.';
- }
- try {
- /** @type {{
- readonly data: ReadonlyArray<{
- readonly mmr_change_to_last_game: number;
- readonly date_raw: number;
- }>;
- }} */
- const getMmrHistoryResponse = JSON.parse(getMmrHistoryResponseJson);
- let mmrChangeThisStream = 0;
- let winCountThisStream = 0;
- let lossCountThisStream = 0;
- let rankedRating = 0;
- var string = "";
- var rank = "";
- json = JSON.parse(getMmrHistoryResponseJson);
- currenttierpatched = json.data.currenttierpatched;
- elo = json.data.elo;
- mmr_change_to_last_game = json.data.mmr_change_to_last_game;
- if(mmr_change_to_last_game > 0) {
- string = "gained";
- }else if(mmr_change_to_last_game < 0){
- string = "lost";
- }else{
- string = "at";
- }
- return `Draxick is at ${(elo-2100)}RR in ${currenttierpatched} and ${string} ${Math.abs(mmr_change_to_last_game)}RR last game.` ;
- } catch (e) {
- return `Failed to parse MMR history: ${e.message}: ${getMmrHistoryResponseJson}`.slice(0, 400);
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment