diff options
author | Noah <mounderfod@gmail.com> | 2022-07-08 21:26:49 +0100 |
---|---|---|
committer | Noah <mounderfod@gmail.com> | 2022-07-08 21:26:49 +0100 |
commit | 39bdd5e8089bd337bf775ca2ca574f1934662ba2 (patch) | |
tree | 0b3a43065bc2c01440af449d5b2ed1cddc59fb14 /discord/client.py | |
parent | ddc5a3d3fed034a04bedb24cadc5f592daff4a27 (diff) | |
download | discobra-39bdd5e8089bd337bf775ca2ca574f1934662ba2.tar.gz |
feat(gateway): Add ready data to `user` attribute of `Client`
Diffstat (limited to 'discord/client.py')
-rw-r--r-- | discord/client.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/discord/client.py b/discord/client.py index c500d1c..c61c4b9 100644 --- a/discord/client.py +++ b/discord/client.py @@ -5,6 +5,8 @@ import threading import websockets from typing import Coroutine from discord.intents import Intents, gen_number +from discord.user import User + class Client: def __init__(self, intents: list[Intents]): @@ -35,6 +37,7 @@ class Client: ready = await gateway.recv() if (hasattr(self, 'on_ready')): await getattr(self, 'on_ready')() + self.user = User(json.loads(ready)['d']['user']) async def heartbeat(self, gateway: websockets.WebSocketClientProtocol, interval: int): while True: @@ -55,4 +58,4 @@ class Client: def run(self, token: str): self.token = token - asyncio.run(self.connect(self.token, self.code)) + asyncio.run(self.connect(self.token, self.code)) \ No newline at end of file |