about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorNoah <mounderfod@gmail.com>2022-07-09 19:03:31 +0100
committerNoah <mounderfod@gmail.com>2022-07-09 19:03:31 +0100
commitfabbc3ac7a6a39dbb6c44512ec4bf17ac2745126 (patch)
tree2f2dbcc9de4646211bffe789587df31e45a0c138
parent5d1b2e09c330f39bdb98e7e906f8a72bcf9c90ab (diff)
downloaddiscobra-fabbc3ac7a6a39dbb6c44512ec4bf17ac2745126.tar.gz
chore: Reformat code
-rw-r--r--discord/client.py35
-rw-r--r--discord/flags.py2
-rw-r--r--discord/premium_type.py2
-rw-r--r--discord/utils/__init__.py2
-rw-r--r--discord/utils/event_emitter.py9
-rw-r--r--discord/utils/exceptions.py1
-rw-r--r--discord/utils/rest.py4
7 files changed, 27 insertions, 28 deletions
diff --git a/discord/client.py b/discord/client.py
index bd46bfc..7ba1f96 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -14,20 +14,22 @@ from .utils.rest import RESTClient
 from .intents import Intents, get_number
 from .user import User
 
+
 class GatewayEvents(IntEnum):
-    DISPATCH           = 0
-    HEARTBEAT          = 1
-    IDENTIFY           = 2
-    PRESENCE           = 3
-    VOICE_STATE        = 4
-    VOICE_PING         = 5
-    RESUME             = 6
-    RECONNECT          = 7
-    REQUEST_MEMBERS    = 8
+    DISPATCH = 0
+    HEARTBEAT = 1
+    IDENTIFY = 2
+    PRESENCE = 3
+    VOICE_STATE = 4
+    VOICE_PING = 5
+    RESUME = 6
+    RECONNECT = 7
+    REQUEST_MEMBERS = 8
     INVALIDATE_SESSION = 9
-    HELLO              = 10
-    HEARTBEAT_ACK      = 11
-    GUILD_SYNC         = 12
+    HELLO = 10
+    HEARTBEAT_ACK = 11
+    GUILD_SYNC = 12
+
 
 class Client:
     """
@@ -77,7 +79,7 @@ class Client:
             threading.Thread(target=self.loop.run_forever).start()
             while True:
                 await self.poll_event()
-    
+
     async def send(self, data: dict):
         """
         Send data to the gateway.
@@ -86,7 +88,7 @@ class Client:
         - data: The data to send to the gateway.
         """
         await self.gateway.send(json.dumps(data))
-    
+
     async def recv(self, msg):
         """
         Receive data from the gateway.
@@ -126,7 +128,6 @@ class Client:
 
         self.event_emitter.emit('on_' + event.lower())
 
-
     async def close(self):
         """
         Close the client.
@@ -138,7 +139,6 @@ class Client:
         msg = await self.gateway.recv()
         await self.recv(msg)
 
-
     async def heartbeat(self, interval: int):
         """
         Sends a heartbeat through the gateway to keep the connection active.
@@ -172,7 +172,8 @@ class Client:
             }
         }
 
-    def event(self, coro: Optional[Callable[..., Coroutine[Any, Any, Any]]]=None, /) -> Optional[Callable[..., Coroutine[Any, Any, Any]]]:
+    def event(self, coro: Optional[Callable[..., Coroutine[Any, Any, Any]]] = None, /) -> Optional[
+        Callable[..., Coroutine[Any, Any, Any]]]:
         """
         Registers a coroutine to be called when an event is emitted.
 
diff --git a/discord/flags.py b/discord/flags.py
index 65a9253..6f2ace7 100644
--- a/discord/flags.py
+++ b/discord/flags.py
@@ -24,6 +24,7 @@ def get_number(flags: list[Flags]):
         number += i.value
     return number
 
+
 def get_flags(number: int):
     flags = []
     while number != 0:
@@ -32,4 +33,3 @@ def get_flags(number: int):
                 flags.append(i)
                 number -= i.value
     return flags
-
diff --git a/discord/premium_type.py b/discord/premium_type.py
index 3549f92..5a03d0c 100644
--- a/discord/premium_type.py
+++ b/discord/premium_type.py
@@ -5,4 +5,4 @@ from enum import Enum, unique
 class PremiumType(Enum):
     NONE = 0,
     NITRO_CLASSIC = 1,
-    NITRO = 2
\ No newline at end of file
+    NITRO = 2
diff --git a/discord/utils/__init__.py b/discord/utils/__init__.py
index 7fdb52b..337f2e6 100644
--- a/discord/utils/__init__.py
+++ b/discord/utils/__init__.py
@@ -1 +1 @@
-from .event_emitter import *
\ No newline at end of file
+from .event_emitter import *
diff --git a/discord/utils/event_emitter.py b/discord/utils/event_emitter.py
index 08b6060..7911326 100644
--- a/discord/utils/event_emitter.py
+++ b/discord/utils/event_emitter.py
@@ -1,18 +1,19 @@
 import asyncio
 from typing import Optional, Coroutine, Any, Callable, Dict
 
-class EventEmitter():
-    def __init__(self, loop: Optional[asyncio.AbstractEventLoop]=None):
+
+class EventEmitter:
+    def __init__(self, loop: Optional[asyncio.AbstractEventLoop] = None):
         self.listeners: Dict[str, Optional[Callable[..., Coroutine[Any, Any, Any]]]] = {}
         self.loop = loop if loop else asyncio.get_event_loop()
 
-    def add_listener(self, event_name: str, func: Optional[Callable[..., Coroutine[Any, Any, Any]]]=None):
+    def add_listener(self, event_name: str, func: Optional[Callable[..., Coroutine[Any, Any, Any]]] = None):
         if not self.listeners.get(event_name, None):
             self.listeners[event_name] = {func}
         else:
             self.listeners[event_name].add(func)
 
-    def remove_listener(self, event_name: str, func: Optional[Callable[..., Coroutine[Any, Any, Any]]]=None):
+    def remove_listener(self, event_name: str, func: Optional[Callable[..., Coroutine[Any, Any, Any]]] = None):
         self.listeners[event_name].remove(func)
         if len(self.listeners[event_name]) == 0:
             del self.listeners[event_name]
diff --git a/discord/utils/exceptions.py b/discord/utils/exceptions.py
index a7f035c..d3e5748 100644
--- a/discord/utils/exceptions.py
+++ b/discord/utils/exceptions.py
@@ -1,3 +1,2 @@
 class APIException(Exception):
     """Raised when the Discord API returns an error."""
-
diff --git a/discord/utils/rest.py b/discord/utils/rest.py
index 919d54d..53853ed 100644
--- a/discord/utils/rest.py
+++ b/discord/utils/rest.py
@@ -2,6 +2,7 @@ import aiohttp
 
 from discord.utils.exceptions import APIException
 
+
 class RESTClient:
     def __init__(self, token: str, session: aiohttp.ClientSession):
         self.token = token
@@ -16,7 +17,6 @@ class RESTClient:
                 case other:
                     raise APIException(data['message'])
 
-
     async def post(self, url: str, data):
         async with self.session.post(url='https://discord.com/api/v10' + url, data=data) as r:
             data = await r.json()
@@ -26,7 +26,6 @@ class RESTClient:
                 case other:
                     raise APIException(data['message'])
 
-
     async def patch(self, url, data):
         async with self.session.patch(url='https://discord.com/api/v10' + url, data=data) as res:
             data = await res.json()
@@ -36,7 +35,6 @@ class RESTClient:
                 case other:
                     raise APIException(data['message'])
 
-
     async def delete(self, url):
         async with self.session.delete(url='https://discord.com/api/v10' + url) as r:
             data = await r.json()