No need to manually close sessions anymore

pull/9/head
sgoudham 4 years ago
parent 10e7764276
commit 7587d41851

@ -78,8 +78,6 @@ async def get_from_api(self, ctx, url):
else: else:
await self.bot.generate_embed(ctx, desc="**Something went wrong with MyWaifuList!**") await self.bot.generate_embed(ctx, desc="**Something went wrong with MyWaifuList!**")
await session.close()
return _dict return _dict
@ -419,9 +417,6 @@ class Anime(Cog):
else: else:
await self.bot.generate_embed(ctx, desc="**Something went wrong with MyWaifuList!**") await self.bot.generate_embed(ctx, desc="**Something went wrong with MyWaifuList!**")
# Close session
await session.close()
# As long as data is returned # As long as data is returned
# Store all data from the api in dict # Store all data from the api in dict
if len(api_data["data"]) > 0: if len(api_data["data"]) > 0:

@ -349,7 +349,7 @@ class Fun(Cog):
url = "https://apis.duncte123.me/kpop" url = "https://apis.duncte123.me/kpop"
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with await session.get(url=url) as response: async with await session.get(url=url) as response:
# When succesful, read data from json # When successful, read data from json
if response.status == 200: if response.status == 200:
kpop = await response.json() kpop = await response.json()
@ -367,8 +367,6 @@ class Fun(Cog):
desc="**You are being rate limited! You have spammed it too much :(**") desc="**You are being rate limited! You have spammed it too much :(**")
return return
await session.close()
embed = Embed(title=name, embed = Embed(title=name,
description=band, description=band,
colour=self.bot.random_colour(), colour=self.bot.random_colour(),
@ -421,8 +419,6 @@ class Fun(Cog):
desc="**You are being rate limited! You have spammed it too much :(**") desc="**You are being rate limited! You have spammed it too much :(**")
return return
await session.close()
# Setting bools to ticks/cross emojis # Setting bools to ticks/cross emojis
verif = self.bot.tick if verified else self.bot.cross verif = self.bot.tick if verified else self.bot.cross
priv = self.bot.tick if private else self.bot.cross priv = self.bot.tick if private else self.bot.cross

Loading…
Cancel
Save