diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-04-19 12:11:12 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-04-19 12:11:12 +0200 |
| commit | 6f9173764a3c40bd252097d2029c82a0401a42ec (patch) | |
| tree | 1ece95e3c36c6fa49fbb77dee9935c4644ed0f05 /api.js | |
| parent | 65da4cba0053bc6ee6f5442a45022bf5b4198e70 (diff) | |
| download | discordbot-6f9173764a3c40bd252097d2029c82a0401a42ec.tar.gz discordbot-6f9173764a3c40bd252097d2029c82a0401a42ec.zip | |
use actor - name mapping
Diffstat (limited to 'api.js')
| -rw-r--r-- | api.js | 28 |
1 files changed, 21 insertions, 7 deletions
@@ -66,13 +66,23 @@ function subscribe(topic, channel) { async function getMappings() { return await cache.wrap("mappings", async () => { let mapping = new Map(); - await Promise.map( - ["gamemode"], async (table) => { - mapping[table] = new Map(); - (await getMap(table)).map( - (map) => mapping[table][map["id"]] = map["name"]) - } - ); + await Promise.all([ + Promise.map( + ["gamemode"], async (table) => { + mapping[table] = new Map(); + (await getMap(table)).map( + (map) => mapping[table][map["id"]] = map["name"]) + } + ), + // name <-> API name + Promise.map( + ["hero"], async (table) => { + mapping[table] = new Map(); + (await getMap(table)).map( + (map) => mapping[table][map["api_name"]] = map["name"]) + } + ) + ]); return mapping; }, { ttl: 60 * 30 }); } @@ -81,6 +91,10 @@ module.exports.mapGameMode = async function(id) { return (await getMappings())["gamemode"][id]; } +module.exports.mapActor = async function(api_name) { + return (await getMappings())["hero"][api_name]; +} + // return a set of IGN of supporters module.exports.getGamers = async function() { return await cache.wrap("gamers", async () => { |
