Skip to content

Instantly share code, notes, and snippets.

@wooosh
Last active August 2, 2020 04:24
Show Gist options
  • Save wooosh/6567f25de3894b657f5d68d6d0dc35ba to your computer and use it in GitHub Desktop.
Save wooosh/6567f25de3894b657f5d68d6d0dc35ba to your computer and use it in GitHub Desktop.
/*
i recommend using the browser console for all of this (specifically in discord to avoid CORS issues)
get emotes in a string like the following
":yes::wmay::waveboye::wavebackboye::vibe::uwu_seal::uwu::turtwo::thonkdead::thonk::this::starkiwmi::starewut::starewow:"
no line breaks or anything
NOTE: you will need to do this in multiple batches
*/
emotes_raw = `<insert_emotes_here>`
console.log('\\' + emotes_raw.replace(/::/g, ':\\:'))
/*
copy paste the result of this into discord so you get something like the following
"<:banhammer:657193833234169886><:ayes:663169796707319831><a:awoo:656665285822251058"
then put all of them into one variable, with no line breaks
*/
emotes_ids = `<insert_assimilated_results>`
emote_map = emote_ids.split(/<*>/g).map(x => {return {name: x + '>', results: 0}})
emote_map.splice(-1,1)
token = 'my_token' // put your discord token in here, needed for the search api
interval = 5000 // request interval
guild_id = 'my_guild'
function get_emote_statistic(i) {
console.log(`index ${i}: name: ${emote_map[i].name}`)
fetch(
`https://discord.com/api/v6/guilds/${guild_id}/messages/search?content=${emote_map[i].name}`,
{headers: {Authorization: token}}
)
.then(response => response.json())
.then(data => {
if (data.total_results == undefined) {alert("got undefined")}
console.log("results " + data.total_results.toString())
emote_map[i].results = data.total_results
setTimeout(() => get_emote_statistic(i+1), interval)
});
}
get_emote_statistic(0) // This will error out, ignore it
// this needs to be pasted after emotes stop being logged to console
output = ""
emote_map.sort((a,b) => a.results > b.results ? 1 : -1).forEach(x => output += `${x.name}: ${x.results.toString()}\n`)
console.log(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment