Browse Source

hash on USERS_ME_GUILDS_LIST and add owner check to Application.

pull/161/head
Luke 6 years ago
parent
commit
41271251c5
  1. 4
      disco/api/client.py
  2. 10
      disco/types/oauth.py

4
disco/api/client.py

@ -565,7 +565,7 @@ class APIClient(LoggingClass):
expire_behavior=expire_behavior,
expire_grace_period=expire_grace_period,
enable_emoticons=enable_emoticons,
))
))
def guilds_integrations_delete(self, guild, integration):
self.http(Routes.GUILDS_INTEGRATIONS_DELETE, dict(guild=guild, integration=integration))
@ -639,7 +639,7 @@ class APIClient(LoggingClass):
def users_me_guilds_list(self, bearer_token=None):
r = self.http(Routes.USERS_ME_GUILDS_LIST, headers=_oauth2_header(bearer_token))
return Guild.create_map(self.client, r.json())
return Guild.create_hash(self.client, 'id', r.json())
def users_me_guilds_delete(self, guild):
self.http(Routes.USERS_ME_GUILDS_DELETE, dict(guild=guild))

10
disco/types/oauth.py

@ -1,8 +1,9 @@
from disco.types.base import (
SlottedModel, Field, ListField, snowflake, text, enum,
SlottedModel, Field, ListField, AutoDictField, snowflake, text, enum,
)
from disco.types.guild import Integration
from disco.types.user import User
from disco.util.snowflake import to_snowflake
class AccessToken(SlottedModel):
@ -49,6 +50,13 @@ class Application(SlottedModel):
slug = Field(text)
cover_image = Field(text)
def user_is_owner(self, user):
user = to_snowflake(user)
if user == self.owner.id:
return True
return any(user == member.user.id for member in self.team.members)
def get_icon_url(self, fmt='webp', size=1024):
if not self.icon:
return ''

Loading…
Cancel
Save