Skip to content

Commit

Permalink
Added Global Name and updated discriminator (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tert0 authored Sep 29, 2023
1 parent 55270fc commit 1dc8b24
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion fastapi_discord/config.py
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 5 additions & 5 deletions fastapi_discord/models/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 14 additions & 8 deletions fastapi_discord/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@
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)
if self.avatar:
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

0 comments on commit 1dc8b24

Please sign in to comment.