From 669c8348c2e73facef4b03c6d2cc85bc539823b3 Mon Sep 17 00:00:00 2001 From: andrei Date: Sat, 9 Mar 2019 09:09:23 -0800 Subject: [PATCH] Add support for guild banners This is a new asset displayed in the top left corner visually under the guild name. --- disco/types/guild.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/disco/types/guild.py b/disco/types/guild.py index 4c536b1..b02091d 100644 --- a/disco/types/guild.py +++ b/disco/types/guild.py @@ -276,9 +276,11 @@ class Guild(SlottedModel, Permissible): name : str Guild's name. icon : str - Guild's icon hash + Guild's icon image hash splash : str Guild's splash image hash + banner : str + Guild's banner image hash region : str Voice region. afk_timeout : int @@ -310,6 +312,7 @@ class Guild(SlottedModel, Permissible): name = Field(text) icon = Field(text) splash = Field(text) + banner = Field(text) region = Field(text) afk_timeout = Field(int) embed_enabled = Field(bool) @@ -510,6 +513,12 @@ class Guild(SlottedModel, Permissible): return 'https://cdn.discordapp.com/splashes/{}/{}.{}?size={}'.format(self.id, self.splash, fmt, size) + def get_banner_url(self, fmt='webp', size=1024): + if not self.banner: + return '' + + return 'https://cdn.discordapp.com/banners/{}/{}.{}?size={}'.format(self.id, self.banner, fmt, size) + @property def icon_url(self): return self.get_icon_url() @@ -518,6 +527,10 @@ class Guild(SlottedModel, Permissible): def splash_url(self): return self.get_splash_url() + @property + def banner_url(self): + return self.get_banner_url() + @property def system_channel(self): return self.channels.get(self.system_channel_id)