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

Gif command (please add safygiphy to requirements.txt) #190

Merged
merged 1 commit into from
Nov 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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