mirror of
https://github.com/myned/modufur.git
synced 2024-12-24 14:27:27 +00:00
Change aiohttp session to be global instead of localized
This commit is contained in:
parent
bf7e75b0bd
commit
e399050bd0
1 changed files with 12 additions and 10 deletions
|
@ -81,18 +81,20 @@ cogs = {}
|
||||||
color = d.Color(0x1A1A1A)
|
color = d.Color(0x1A1A1A)
|
||||||
last_commands = {}
|
last_commands = {}
|
||||||
|
|
||||||
|
asession = aiohttp.ClientSession()
|
||||||
|
|
||||||
|
|
||||||
async def fetch(url, *, params={}, json=False, response=False, text=False):
|
async def fetch(url, *, params={}, json=False, response=False, text=False):
|
||||||
async with aiohttp.ClientSession() as session:
|
async with asession.get(url, params=params, headers={
|
||||||
async with session.get(url, params=params, headers={'User-Agent': 'Myned/Modufur'}, ssl=False) as r:
|
'User-Agent': 'Myned/Modufur (https://github.com/Myned/Modufur)'}, ssl=False) as r:
|
||||||
if json:
|
if json:
|
||||||
return await r.json()
|
return await r.json()
|
||||||
elif response:
|
elif response:
|
||||||
return r
|
return r
|
||||||
elif text:
|
elif text:
|
||||||
return await r.text()
|
return await r.text()
|
||||||
else:
|
else:
|
||||||
return await r.read()
|
return await r.read()
|
||||||
|
|
||||||
|
|
||||||
def generate_embed(ctx, *, title=d.Embed.Empty, kind='rich', description=d.Embed.Empty, url=d.Embed.Empty, timestamp=d.Embed.Empty, colour=color, footer={}, image=d.Embed.Empty, thumbnail=d.Embed.Empty, author={}, fields=[]):
|
def generate_embed(ctx, *, title=d.Embed.Empty, kind='rich', description=d.Embed.Empty, url=d.Embed.Empty, timestamp=d.Embed.Empty, colour=color, footer={}, image=d.Embed.Empty, thumbnail=d.Embed.Empty, author={}, fields=[]):
|
||||||
|
|
Loading…
Reference in a new issue