From 6a464198f961b6e6c7870b6f21173936d9e8437f Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Mon, 19 Feb 2018 18:23:40 +0000 Subject: [PATCH] Cache league champions list --- commands/search/league-of-legends-champion.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/commands/search/league-of-legends-champion.js b/commands/search/league-of-legends-champion.js index 8e6cf71a..12cec04c 100644 --- a/commands/search/league-of-legends-champion.js +++ b/commands/search/league-of-legends-champion.js @@ -24,6 +24,7 @@ module.exports = class LeagueOfLegendsChampionCommand extends Command { }); this.version = null; + this.champions = null; } async run(msg, { champion }) { @@ -91,8 +92,10 @@ module.exports = class LeagueOfLegendsChampionCommand extends Command { } async fetchChampions() { + if (this.champions && this.champions.version === this.version) return this.champions; const { body } = await snekfetch .get(`https://ddragon.leagueoflegends.com/cdn/${this.version}/data/en_US/champion.json`); + this.champions = body; return body; }