1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-12-24 22:27:28 +00:00

Add text argument to fetch util

This commit is contained in:
Myned 2019-09-24 19:11:29 -04:00
parent 9ab357e26f
commit 3741b0e694
No known key found for this signature in database
GPG key ID: BC58C09870A63E59

View file

@ -85,14 +85,17 @@ color = d.Color(0x1A1A1A)
last_commands = {} last_commands = {}
async def fetch(url, *, params={}, json=False, response=False): async def fetch(url, *, params={}, json=False, response=False, text=False):
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.get(url, params=params, headers={'User-Agent': 'Myned/Modufur'}, ssl=False) as r: async with session.get(url, params=params, headers={'User-Agent': 'Myned/Modufur'}, ssl=False) as r:
if response: if json:
return r
elif json:
return await r.json() return await r.json()
return await r.read() elif response:
return r
elif text:
return await r.text()
else:
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=[]):