From d48af50178aeba52ab7048c26e32cf4430a89298 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Fri, 24 Mar 2017 00:02:15 -0700 Subject: [PATCH] Right... I cannot have global variables - scratch that idea --- titanembeds/discordrest.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/titanembeds/discordrest.py b/titanembeds/discordrest.py index 0516385..9e4fef3 100644 --- a/titanembeds/discordrest.py +++ b/titanembeds/discordrest.py @@ -5,8 +5,7 @@ import json from cachetools import cached, TTLCache _DISCORD_API_BASE = "https://discordapp.com/api/v6" -get_widget_cache = TTLCache(200, 300) -guild_list_cache = TTLCache(1, 300) # Pop the list if new guilds are added +cache = TTLCache(200, 300) def json_or_text(response): text = response.text @@ -140,7 +139,7 @@ class DiscordREST: # User ##################### - @cached(guild_list_cache) + @cached(cache) def get_all_guilds(self): _endpoint = "/users/@me/guilds" params = {} @@ -163,7 +162,7 @@ class DiscordREST: # Widget Handler ##################### - @cached(get_widget_cache) + @cached(cache) def get_widget(self, guild_id): _endpoint = _DISCORD_API_BASE + "/servers/{guild_id}/widget.json".format(guild_id=guild_id) embed = self.get_guild_embed(guild_id)