diff options
| author | 2018-02-16 16:08:48 +0000 | |
|---|---|---|
| committer | 2018-02-16 16:08:48 +0000 | |
| commit | 8335fe029042d88bf6f09d5cc1fa11686ce4d721 (patch) | |
| tree | 2aa33d189ff529557150076f2e9047612793e352 | |
| parent | Better output on_ready with role updates (diff) | |
Automatically close aiohttp session
| -rw-r--r-- | bot/cogs/events.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/bot/cogs/events.py b/bot/cogs/events.py index 42f254a0c..325675039 100644 --- a/bot/cogs/events.py +++ b/bot/cogs/events.py @@ -22,16 +22,13 @@ class Events: self.bot = bot async def send_updated_users(self, *users): - session = ClientSession( - headers={"X-API-Key": SITE_API_KEY} - ) - - response = await session.post( - url=SITE_API_USER_URL, - json=list(users) - ) + with ClientSession(headers={"X-API-Key": SITE_API_KEY}) as session: + response = await session.post( + url=SITE_API_USER_URL, + json=list(users) + ) - return await response.json() + return await response.json() async def on_command_error(self, ctx: Context, e: CommandError): command = ctx.command |