[V3 Streams] Replace instances of ClientSession assignment with async context manager (#1238)

This commit is contained in:
Tobotimus
2018-01-15 14:43:06 +11:00
committed by palmtree5
parent 05c5c58eaf
commit 68800d28fc
2 changed files with 26 additions and 34 deletions

View File

@@ -293,10 +293,9 @@ class Core:
@checks.is_owner()
async def avatar(self, ctx, url: str):
"""Sets Red's avatar"""
session = aiohttp.ClientSession()
async with session.get(url) as r:
data = await r.read()
await session.close()
async with aiohttp.ClientSession() as session:
async with session.get(url) as r:
data = await r.read()
try:
await ctx.bot.user.edit(avatar=data)