#1 add gif command
This commit is contained in:
parent
6aa7ed372d
commit
8ac8a390aa
1 changed files with 17 additions and 0 deletions
|
@ -8,12 +8,14 @@ import os
|
|||
import requests
|
||||
import aiocron
|
||||
import asyncio
|
||||
import giphy_client
|
||||
|
||||
from time import sleep
|
||||
from discord.ext import tasks, commands
|
||||
from subprocess import *
|
||||
from sys import argv
|
||||
from pathlib import Path
|
||||
from giphy_client.rest import ApiException
|
||||
|
||||
class Mybot(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
|
@ -52,6 +54,21 @@ class Mybot(commands.Cog):
|
|||
source = ctx.message.content
|
||||
self.sounds.append((source,ctx))
|
||||
|
||||
@commands.command(help='Gif me')
|
||||
async def gif(self, ctx):
|
||||
query = ctx.message.content
|
||||
api_instance = giphy_client.DefaultApi()
|
||||
api_key = "udhL9Rgdme3HpAoFhWVZoYM0l0XwkzLz"
|
||||
lang = 'fr'
|
||||
try:
|
||||
api_response = api_instance.gifs_search_get(api_key, query, lang=lang)
|
||||
api_response.to_dict()['data'][0]
|
||||
get_url = random.choice(api_response.to_dict()['data'])
|
||||
get_url['url']
|
||||
ctx.channel.send(get_url['url'])
|
||||
except ApiException as e:
|
||||
ctx.channel.send("Exception when calling DefaultApi->gifs_search_get: %s\n" % e)
|
||||
|
||||
@commands.command()
|
||||
async def welcome(self, ctx):
|
||||
#if ctx.message.author.name == self.bot.user.name:
|
||||
|
|
Loading…
Reference in a new issue