mirror of
				https://github.com/TitanEmbeds/Titan.git
				synced 2025-11-04 07:47:10 +01:00 
			
		
		
		
	Right... I cannot have global variables - scratch that idea
This commit is contained in:
		@@ -5,8 +5,7 @@ import json
 | 
				
			|||||||
from cachetools import cached, TTLCache
 | 
					from cachetools import cached, TTLCache
 | 
				
			||||||
 | 
					
 | 
				
			||||||
_DISCORD_API_BASE = "https://discordapp.com/api/v6"
 | 
					_DISCORD_API_BASE = "https://discordapp.com/api/v6"
 | 
				
			||||||
get_widget_cache = TTLCache(200, 300)
 | 
					cache = TTLCache(200, 300)
 | 
				
			||||||
guild_list_cache = TTLCache(1, 300) # Pop the list if new guilds are added
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
def json_or_text(response):
 | 
					def json_or_text(response):
 | 
				
			||||||
    text = response.text
 | 
					    text = response.text
 | 
				
			||||||
@@ -140,7 +139,7 @@ class DiscordREST:
 | 
				
			|||||||
    # User
 | 
					    # User
 | 
				
			||||||
    #####################
 | 
					    #####################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @cached(guild_list_cache)
 | 
					    @cached(cache)
 | 
				
			||||||
    def get_all_guilds(self):
 | 
					    def get_all_guilds(self):
 | 
				
			||||||
        _endpoint = "/users/@me/guilds"
 | 
					        _endpoint = "/users/@me/guilds"
 | 
				
			||||||
        params = {}
 | 
					        params = {}
 | 
				
			||||||
@@ -163,7 +162,7 @@ class DiscordREST:
 | 
				
			|||||||
    # Widget Handler
 | 
					    # Widget Handler
 | 
				
			||||||
    #####################
 | 
					    #####################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @cached(get_widget_cache)
 | 
					    @cached(cache)
 | 
				
			||||||
    def get_widget(self, guild_id):
 | 
					    def get_widget(self, guild_id):
 | 
				
			||||||
        _endpoint = _DISCORD_API_BASE + "/servers/{guild_id}/widget.json".format(guild_id=guild_id)
 | 
					        _endpoint = _DISCORD_API_BASE + "/servers/{guild_id}/widget.json".format(guild_id=guild_id)
 | 
				
			||||||
        embed = self.get_guild_embed(guild_id)
 | 
					        embed = self.get_guild_embed(guild_id)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user