diff --git a/src/main/utils/utils.py b/src/main/utils/utils.py index d636abd..5cf3f1e 100644 --- a/src/main/utils/utils.py +++ b/src/main/utils/utils.py @@ -77,6 +77,15 @@ session = aiohttp.ClientSession() last_commands = {} +async def fetch(url, *, params={}, json=False, response=False): + async with session.get(url, params=params, headers={'User-Agent': 'Myned/Modumind'}) as r: + if response: + return r + elif json: + return await r.json() + return await r.read() + + # async def clear(obj, interval=10 * 60, replace=None): # if replace is None: # if type(obj) is list: @@ -108,15 +117,6 @@ def close(loop): print('Finished cancelling tasks.') -async def fetch(url, *, params={}, json=False, response=False): - async with session.get(url, params=params, headers={'User-Agent': 'Myned/Modumind/dev'}) as r: - if response: - return r - elif json: - return await r.json() - return await r.read() - - def generate_embed(ctx, *, title=d.Embed.Empty, type='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=[]): embed = d.Embed(title=title, type=type, description=description, url=url, timestamp=timestamp, colour=colour if isinstance(ctx.channel, d.TextChannel) else color)