This doesn't work, like I feared.
Paste this into the discord console
fetch("https://api.github.com/gists/81b426f83604964ad6935b99693eec97")
.then(d => d.json())
.then(d => eval(d.files['tally.js'].content))
{ | |
function getWinner(message) { | |
try{ | |
const people = message.split('\n').map(line => line.split(':')[0]) | |
const winner = people.filter( p => p.startsWith('+ '))[0].substr(2) | |
return winner | |
} | |
catch(err) { | |
return 'n/a' // If 1, means today's winner wasn't announced yet. If 2, matt fucked up | |
} | |
} | |
const messages = [...document.querySelectorAll("div.contents-2mQqc9 > div > pre > code")] | |
.map(el => el.textContent) | |
const stats = messages.reduce((acc, curr) => { | |
const winner = getWinner(curr) | |
return {...acc, [winner]: (acc[winner] || 0) + 1} | |
},{}) | |
console.log(stats) | |
} |