Skip to content
This repository has been archived by the owner on Jul 31, 2018. It is now read-only.

Commit

Permalink
Merge pull request #190 from SharpBit/patch-1
Browse files Browse the repository at this point in the history
Gif command (please add safygiphy to requirements.txt)
  • Loading branch information
fourjr authored Nov 15, 2017
2 parents 557fbb1 + ec7cefc commit ca4829f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cogs/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
from urllib.request import urlopen
from sympy import solve
from PIL import Image
import safygiphy
from ext import embedtobox


class NumericStringParserForPython3(object):
Expand Down Expand Up @@ -152,6 +154,21 @@ def __init__(self, bot):
self.bot = bot
self.emoji_converter = commands.EmojiConverter()
self.nsp=NumericStringParserForPython3()

@commands.command()
async def gif(self, ctx, *, tag):
''' Get a random gif. Usage: gif <tag> '''
g = safygiphy.Giphy()
gif = g.random(tag=tag)
color = await ctx.get_dominant_color(ctx.author.avatar_url)
em = discord.Embed(color=color)
em.set_image(url=str(gif.get('data', {}).get('image_original_url')))
try:
await ctx.send(embed=em)
except discord.HTTPException:
em_list = await embedtobox.etb(em)
for page in em_list:
await ctx.send(page)

@commands.command()
async def embedsay(self, ctx, *, message):
Expand Down

0 comments on commit ca4829f

Please sign in to comment.