Skip to content

Instantly share code, notes, and snippets.

@wfjsw
Created October 6, 2018 12:53
Show Gist options
  • Save wfjsw/13c7d6cf44fcc0c9dc7241973477e73c to your computer and use it in GitHub Desktop.
Save wfjsw/13c7d6cf44fcc0c9dc7241973477e73c to your computer and use it in GitHub Desktop.
Fetch stats.craft.moe banned users.
let players = await fetch('/static/data/players.json')
players = await players.json()
let players_uuid = players.map(p => p.uuid)
let banned_uuids = []
for (let u of players_uuid) {
let p = await fetch(`/static/data/${u}/stats.json`)
p = await p.json()
if (p.data.banned) banned_uuids.push(u)
}
let player_uuid_to_name = new Map()
for (let u of players) {
player_uuid_to_name.set(u.uuid, u.playername)
}
let banned_names = banned_uuids.map(u => player_uuid_to_name.get(u))
let player_uuid_to_seen = new Map()
for (let u of players) {
player_uuid_to_seen.set(u.uuid, u.seen)
}
let banned_seen = banned_uuids.map(u => player_uuid_to_seen.get(u))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment