import discord 
import json
from discord.ext import commands
from datetime import datetime 

from utils import aiohttp_wrap as aw 


class Game:
    """ Cog which allows fetching of video game information """
    IG_URL = 'https://api-2445582011268.apicast.io/{}/'
    with open('data/apikeys.json') as f:
        KEY = json.load(f)['igdb']

    def __init__(self, bot):
        self.bot = bot
        self.session = bot.aio_session
    
    @commands.command(aliases=['games'])
    async def game(self, ctx, *, query: str):
        """ Search for some information about a game """
        url = self.IG_URL.format('games')
        headers = {'user-key': self.KEY}
        params = {'search': query, 
                  'fields': 'name,summary,first_release_date,aggregated_rating,cover'}
        
        resp = await aw.aio_get_json(self.session, url, headers=headers, params=params)

        await ctx.send(f'{resp}'[:500])

def setup(bot):
    bot.add_cog(Game(bot))

@@ -258,16 +258,77 @@
 io/%7B%7D/'%0A
+    IG_ICON_URL = 'https://www.igdb.com/favicon-196x196.png'%0A
     with
@@ -952,38 +952,479 @@
     
-await ctx.send(f'%7Bresp%7D'%5B:500%5D
+# Create embed%0A        em = discord.Embed(timestamp=datetime.fromtimestamp(resp%5B'first_released_date'%5D), %0A                           url=resp%5B'url'%5D,%0A                           color=discord.Color.green())%0A        em.set_author(name=resp%5B'name'%5D, icon_url=self.IG_ICON_URL)%0A        em.set_thumbnail(url=resp%5B'cover'%5D%5B'url'%5D)%0A        em.add_field(name='Rating', value=resp%5B'aggregated_rating'%5D)%0A        em.set_footer(text='First released')%0A%0A        await ctx.send(embed=em
 )%0A%0Ad

embed for game cog