title: Custom Search Command Discord.py
body: <p>I'm attempting to make a Custom Search command using the Custom Search API.</p>
  <p>Naturally I have no idea how to implement it.  I'm hoping someone can take a look at what I have and help me figure out how to make it work in this style?</p>
  <pre class="lang-py prettyprint-override"><code>import discord
  from discord.ext import commands
  import discord.utils
  import time
  import os
  import dotenv
  from dotenv import load_dotenv
  
  load_dotenv()
  SEARCH = os.getenv(&quot;CUSTOM_SEARCH_API_KEY&quot;)
  
  class Util(commands.Cog):
      def __init__(self, client):
          self.client = client
      
      @commands.command(name=&quot;Search&quot;, aliases=[&quot;search&quot;])
      @commands.has_permissions(embed_links=True, add_reactions=True)
      async def _search(self, ctx, *, message):
          if not ctx.author.Bot:
              guild = ctx.guild
              msg = ctx.message
              cli = self.client.user
              gold = discord.Color.dark_gold()
              embed = discord.Embed(color=gold, name=f&quot;{image.name}&quot;, description=f&quot;{image.desc}&quot;, timestamp=msg.created_at)
              embed.set_image(url=f&quot;{image.url}&quot;)
              embed.set_thumbnail(url=cli.avatar_url)
              embed.set_footer(text=guild.name, icon_url=guild.icon_url)
              await ctx.send(embed=embed)
              return
  
  
  def setup(client):
      client.add_cog(Util(client))
  </code></pre>
  <p>I'm using dotenv to store my API key</p>
  <p>Basically, I'm wanting it to be a somewhat detailed command.</p>
  <p>If searching for posts it will find the exact post. and if searching for images it will go by tag and find a random image matching the selected tag(s).</p>
  <p>I would like for it to respond via rich embed if possible.</p>
  <p>I'm fully aware my above code won't work at all. I simply put it there as a base for part of the embed that I want to try to implement.</p>
  <p>Some help would be much appreciated.</p>
  <p>I'm using discord.py rewrite and I have my commands set up through cogs.</p>
  <p>This is my <code>bot.py</code> file that contains the handler for my cogs.</p>
  <pre class="lang-py prettyprint-override"><code>import discord
  from discord.ext import commands
  import os
  import json
  import dotenv
  from dotenv import load_dotenv
  
  load_dotenv()
  TOKEN = os.getenv('DISCORD_TOKEN')
  PREFIX = os.getenv(&quot;COMMAND_PREFIX&quot;)
  
  
  client = commands.Bot(command_prefix=PREFIX)
  client.remove_command('help')
  
  for filename in os.listdir(&quot;./cogs&quot;):
      if filename.endswith(&quot;.py&quot;):
          client.load_extension(f&quot;cogs.{filename[:-3]}&quot;)
  
  
  client.run(TOKEN)
  </code></pre>