From dc7e282943771e26ceb5d591a6905e925f5196f2 Mon Sep 17 00:00:00 2001 From: Andrei Date: Wed, 10 May 2017 15:28:49 -0700 Subject: [PATCH] Add get_icon_url/get_splash_url for Guild's --- disco/types/guild.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/disco/types/guild.py b/disco/types/guild.py index 594d56a..efbd421 100644 --- a/disco/types/guild.py +++ b/disco/types/guild.py @@ -448,3 +448,23 @@ class Guild(SlottedModel, Permissible): def get_emojis(self): return self.client.api.guilds_emojis_list(self.id) + + def get_icon_url(self, fmt='webp', size=1024): + if not self.icon: + return '' + + return 'https://cdn.discordapp.com/icons/{}/{}.{}?size={}'.format(self.id, self.icon, fmt, size) + + def get_splash_url(self, fmt='webp', size=1024): + if not self.splash: + return '' + + return 'https://cdn.discordapp.com/splashes/{}/{}.{}?size={}'.format(self.id, self.splash, fmt, size) + + @property + def icon_url(self): + return self.get_icon_url() + + @property + def splash_url(self): + return self.get_splash_url()