mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 03:38:53 -05:00
Merge pull request #62 from scummboy/develop
Update !gifr to use Giphy's random API call
This commit is contained in:
commit
0fc8a95158
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,4 +3,4 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
data
|
data
|
||||||
!data/trivia/*
|
!data/trivia/*
|
||||||
!data/audio/playlists/*
|
!data/audio/playlists/*
|
||||||
|
|||||||
@ -81,12 +81,11 @@ class Image:
|
|||||||
if len(text[0]) > 1 and len(text[0]) < 20:
|
if len(text[0]) > 1 and len(text[0]) < 20:
|
||||||
try:
|
try:
|
||||||
msg = "+".join(text)
|
msg = "+".join(text)
|
||||||
search = "http://api.giphy.com/v1/gifs/search?q=" + msg + "&api_key=dc6zaTOxFJmzC"
|
search = "http://api.giphy.com/v1/gifs/random?&api_key=dc6zaTOxFJmzC&tag=" + msg
|
||||||
async with aiohttp.get(search) as r:
|
async with aiohttp.get(search) as r:
|
||||||
result = await r.json()
|
result = await r.json()
|
||||||
if result["data"] != []:
|
if result["data"] != []:
|
||||||
maxarray = len(result)
|
url = result["data"]["url"]
|
||||||
url = result["data"][random.randint(0,maxarray)]["url"]
|
|
||||||
await self.bot.say(url)
|
await self.bot.say(url)
|
||||||
else:
|
else:
|
||||||
await self.bot.say("Your search terms gave no results.")
|
await self.bot.say("Your search terms gave no results.")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user