diff options
Diffstat (limited to 'discord/utils')
-rw-r--r-- | discord/utils/__init__.py | 2 | ||||
-rw-r--r-- | discord/utils/event_emitter.py | 9 | ||||
-rw-r--r-- | discord/utils/exceptions.py | 1 | ||||
-rw-r--r-- | discord/utils/rest.py | 4 |
4 files changed, 7 insertions, 9 deletions
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() |