Let's not be deprecated again
Changed `aiohttp.get` to use `aiohttp.ClientSession()`
This commit is contained in:
@@ -56,6 +56,10 @@ class ImgWelcome:
|
||||
self.bot = bot
|
||||
self.settings = dataIO.load_json('data/imgwelcome/settings.json')
|
||||
self.version = "0.1.6"
|
||||
self.session = aiohttp.ClientSession()
|
||||
|
||||
def __unload(self):
|
||||
self.session.close()
|
||||
|
||||
async def save_settings(self):
|
||||
dataIO.save_json('data/imgwelcome/settings.json', self.settings)
|
||||
@@ -220,7 +224,7 @@ class ImgWelcome:
|
||||
await self.save_settings()
|
||||
|
||||
async def _get_profile(self, url):
|
||||
async with aiohttp.get(url) as r:
|
||||
async with self.session.get(url) as r:
|
||||
image = await r.content.read()
|
||||
with open('data/imgwelcome/profilepic.png', 'wb') as f:
|
||||
f.write(image)
|
||||
@@ -407,7 +411,7 @@ class ImgWelcome:
|
||||
|
||||
if success:
|
||||
try:
|
||||
async with aiohttp.get(bg_url) as r:
|
||||
async with self.session.get(bg_url) as r:
|
||||
image = await r.content.read()
|
||||
if not os.path.exists('data/imgwelcome/{}'.format(server.id)):
|
||||
os.makedirs('data/imgwelcome/{}'.format(server.id))
|
||||
|
||||
Reference in New Issue
Block a user