Cache league champions list

This commit is contained in:
Daniel Odendahl Jr
2018-02-19 18:23:40 +00:00
parent 51b063e661
commit 6a464198f9
@@ -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;
}