blob: ada35ef0fe7ac74fd177e8608393479021eb7cb0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
import typing
from pydantic import BaseModel
class RoleTags(BaseModel):
"""Meta information about a discord role."""
bot_id: typing.Optional[str]
integration_id: typing.Optional[str]
premium_subscriber: bool
def __init__(self, **data) -> None:
"""
Handle the terrible discord API.
Discord only returns the premium_subscriber field if it's true,
meaning the typical validation process wouldn't work.
We manually parse the raw data to determine if the field exists, and give it a useful
bool value.
"""
data["premium_subscriber"] = "premium_subscriber" in data.keys()
super().__init__(**data)
class DiscordRole(BaseModel):
"""Schema model of Discord guild roles."""
id: str
name: str
color: int
hoist: bool
icon: typing.Optional[str]
unicode_emoji: typing.Optional[str]
position: int
permissions: str
managed: bool
mentionable: bool
tags: typing.Optional[RoleTags]
|