From 1dc8b2414068dab0dd2a55e2231c04a53a476334 Mon Sep 17 00:00:00 2001 From: Tert0 <62036464+Tert0@users.noreply.github.com> Date: Fri, 29 Sep 2023 15:18:57 +0200 Subject: [PATCH] Added Global Name and updated discriminator (#107) --- fastapi_discord/config.py | 2 +- fastapi_discord/models/guild.py | 10 +++++----- fastapi_discord/models/user.py | 22 ++++++++++++++-------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/fastapi_discord/config.py b/fastapi_discord/config.py index 1c9f120..fa0edf3 100644 --- a/fastapi_discord/config.py +++ b/fastapi_discord/config.py @@ -1,5 +1,5 @@ DISCORD_URL = "https://discord.com" -DISCORD_API_URL = f"{DISCORD_URL}/api/v8" +DISCORD_API_URL = f"{DISCORD_URL}/api/v10" DISCORD_OAUTH_URL = f"{DISCORD_URL}/api/oauth2" DISCORD_TOKEN_URL = f"{DISCORD_OAUTH_URL}/token" DISCORD_OAUTH_AUTHENTICATION_URL = f"{DISCORD_OAUTH_URL}/authorize" diff --git a/fastapi_discord/models/guild.py b/fastapi_discord/models/guild.py index ffb964d..4b7bf5f 100644 --- a/fastapi_discord/models/guild.py +++ b/fastapi_discord/models/guild.py @@ -8,14 +8,14 @@ class GuildPreview(BaseModel): id: str name: str - icon: Optional[str] + icon: Optional[str] = None owner: bool permissions: int features: List[str] class Guild(GuildPreview): - owner_id: Optional[int] - verification_level: Optional[int] - default_message_notifications: Optional[int] - roles: Optional[List[Role]] + owner_id: Optional[int] = None + verification_level: Optional[int] = None + default_message_notifications: Optional[int] = None + roles: Optional[List[Role]] = None diff --git a/fastapi_discord/models/user.py b/fastapi_discord/models/user.py index 009fb04..2a3bd63 100644 --- a/fastapi_discord/models/user.py +++ b/fastapi_discord/models/user.py @@ -6,16 +6,20 @@ class User(BaseModel): id: str username: str - discriminator: str + discriminator: Optional[int] = None + global_name: Optional[str] = None avatar: Optional[str] - avatar_url: Optional[str] + avatar_url: Optional[str] = None locale: str - email: Optional[str] - bot: Optional[bool] - mfa_enabled: bool - flags: int - premium_type: Optional[int] - public_flags: int + email: Optional[str] = None + mfa_enabled: Optional[bool] = None + flags: Optional[int] = None + premium_type: Optional[int] = None + public_flags: Optional[int] = None + banner: Optional[str] = None + accent_color: Optional[int] = None + verified: Optional[bool] = None + avatar_decoration: Optional[str] = None def __init__(self, **data: Any): super().__init__(**data) @@ -23,3 +27,5 @@ def __init__(self, **data: Any): self.avatar_url = f"https://cdn.discordapp.com/avatars/{self.id}/{self.avatar}.png" else: self.avatar_url = "https://cdn.discordapp.com/embed/avatars/1.png" + if self.discriminator == 0: + self.discriminator = None