diff options
| -rw-r--r-- | api.js | 4 | ||||
| -rw-r--r-- | responses.js | 5 |
2 files changed, 6 insertions, 3 deletions
@@ -14,6 +14,8 @@ let cache = cacheManager.caching({ ttl: 10 // s }); +const UPDATE_TIMEOUT = parseInt(process.env.UPDATE_TIMEOUT) || 60; // s + const API_FE_URL = process.env.API_FE_URL || "http://vainsocial.dev/bots/api", API_MAP_URL = process.env.API_MAP_URL || "http://vainsocial.dev/masters/", API_WS_URL = process.env.API_WS_URL || "ws://vainsocial.dev/ws", @@ -79,7 +81,7 @@ module.exports.mapGameMode = async function(id) { // be an async iterator // next() returns promises that are awaited until there is an update -module.exports.subscribeUpdates = function(name, timeout=60) { +module.exports.subscribeUpdates = function(name, timeout=UPDATE_TIMEOUT) { const channel = new Channel(), subscription = subscribe("player." + name, channel); diff --git a/responses.js b/responses.js index 15e7ec7..9137af0 100644 --- a/responses.js +++ b/responses.js @@ -11,7 +11,8 @@ const Commando = require("discord.js-commando"), api = require("./api"); const PREVIEW = process.env.PREVIEW || true, - MATCH_HISTORY_LEN = parseInt(process.env.MATCH_HISTORY_LEN) || 3; + MATCH_HISTORY_LEN = parseInt(process.env.MATCH_HISTORY_LEN) || 3, + REACTION_TIMEOUT = parseInt(process.env.REACTION_TIMEOUT) || 60; // s const reactionsPipe = new Channel(); @@ -116,7 +117,7 @@ module.exports.onNewReaction = (reaction) => { // create an iterator that returns promises to await new reactions // the Promise result is the reaction name -function awaitReactions(message, emoji, timeout=60) { +function awaitReactions(message, emoji, timeout=REACTION_TIMEOUT) { const pipeOut = new Channel(); // stop listening after timeout setTimeout(() => pipeOut.close(), timeout*1000); |
