update fun.py to use the bot's ClientSession instance
@@ -14,11 +14,6 @@ class Fun(commands.Cog):
self.d = bot.d
self.k = bot.k
- self.ses = aiohttp.ClientSession(loop=bot.loop)
-
- def cog_unload(self):
- self.bot.loop.create_task(self.ses.close())
-
async def lang_convert(self, msg, lang):
keys = list(lang)
@@ -51,7 +46,7 @@ class Fun(commands.Cog):
async with ctx.typing():
while meme["spoiler"] or (not do_nsfw and meme["nsfw"]) or meme.get("image") is None:
- resp = await self.ses.get(
+ resp = await self.bot.aiohttp.get(
"https://api.iapetus11.me/reddit/gimme/meme+memes+me_irl+dankmemes+wholesomememes+prequelmemes",
headers={"Authorization": self.k.vb_api},
)
@@ -81,7 +76,7 @@ class Fun(commands.Cog):
async with ctx.typing():
while (not do_nsfw and jj["nsfw"]) or jj.get("image") is None:
- resp = await self.ses.get(
+ resp = await self.bot.aiohttp.get(
"https://api.iapetus11.me/reddit/gimme/4chan+greentext", headers={"Authorization": self.k.vb_api}
)
@@ -105,7 +100,7 @@ class Fun(commands.Cog):
async with ctx.typing():
while comic["spoiler"] or (not do_nsfw and comic["nsfw"]) or comic.get("image") is None:
- resp = await self.ses.get(
+ resp = await self.bot.aiohttp.get(
"https://api.iapetus11.me/reddit/gimme/comics",
headers={"Authorization": self.k.vb_api},
)
@@ -130,7 +125,7 @@ class Fun(commands.Cog):
async with ctx.typing():
while meme["spoiler"] or meme["nsfw"] or meme.get("image") is None:
- resp = await self.ses.get(
+ resp = await self.bot.aiohttp.get(
"https://api.iapetus11.me/reddit/gimme/CursedMinecraft",
headers={"Authorization": self.k.vb_api},
)
@@ -319,7 +314,7 @@ class Fun(commands.Cog):
else:
thing = ctx.message.clean_content[len(ctx.prefix) + 4 :]
- resp = await self.ses.get("https://rra.ram.moe/i/r?type=pat")
+ resp = await self.bot.aiohttp.get("https://rra.ram.moe/i/r?type=pat")
image_url = "https://rra.ram.moe" + (await resp.json())["path"]
embed = discord.Embed(color=self.d.cc, title=f"{ctx.author.display_name} pats {thing[:200]}")
