Use DiscordModelsMeta class. Set ROUTE as required class attribute for bases. Add fetch_from_api classmethod which is shorthand to return the current model

This commit is contained in:
thec0sm0s
2020-05-12 12:20:32 +05:30
parent bc22196695
commit 6365ab461a
4 changed files with 33 additions and 7 deletions

View File

@@ -36,8 +36,10 @@ class User(DiscordModelsBase):
"""
ROUTE = "/users/@me"
def __init__(self, payload):
self._payload = payload
super().__init__(payload)
self.id = int(self._payload["id"])
self.username = self._payload["username"]
self.discriminator = self._payload["discriminator"]
@@ -99,3 +101,4 @@ class User(DiscordModelsBase):
class Bot(User):
"""Class representing the client user itself."""
# TODO: What is this?