summaryrefslogtreecommitdiff
path: root/api.js
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-04-19 12:11:12 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2017-04-19 12:11:12 +0200
commit6f9173764a3c40bd252097d2029c82a0401a42ec (patch)
tree1ece95e3c36c6fa49fbb77dee9935c4644ed0f05 /api.js
parent65da4cba0053bc6ee6f5442a45022bf5b4198e70 (diff)
downloaddiscordbot-6f9173764a3c40bd252097d2029c82a0401a42ec.tar.gz
discordbot-6f9173764a3c40bd252097d2029c82a0401a42ec.zip
use actor - name mapping
Diffstat (limited to 'api.js')
-rw-r--r--api.js28
1 files changed, 21 insertions, 7 deletions
diff --git a/api.js b/api.js
index 24c9a9a..a5d42af 100644
--- a/api.js
+++ b/api.js
@@ -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 () => {