diff --git a/disco/api/client.py b/disco/api/client.py index 912c229..187f46b 100644 --- a/disco/api/client.py +++ b/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)) diff --git a/disco/types/oauth.py b/disco/types/oauth.py index 639879f..03d5f4d 100644 --- a/disco/types/oauth.py +++ b/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 ''