Browse Source

Add support for guild banners

This is a new asset displayed in the top left corner visually under the guild name.
pull/128/head
andrei 6 years ago
parent
commit
669c8348c2
  1. 15
      disco/types/guild.py

15
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)

Loading…
Cancel
Save