Reputation: 1
I tried to make a Bot that sends gifs from giphy. I made it with python and Giphy Core Client for Python. So if someone type
/OwO Giphy Spongebob
It sends a random spongebob or some other memes. The problem is that it send the metadata and gif 5 times. I hope someone can help me that the bot send only the gif and only 1 time. I have the Python Version 3.8.
if message.content.startswith("/OwO Giphy") or message.content.startswith("/OwO giphy"): try: q = message.content tag = q.replace('/OwO Giphy ', "") api_response = api_instance.gifs_random_get(api_key, tag=tag, rating='pg') await message.channel.send(api_response) except ApiException as e: print("ERROR! Exception from Api try")
Upvotes: -1
Views: 276
Reputation: 1
FINAL SOLUTION: I didn't add 'embed_url'
if message.content.startswith("/OwO Giphy"):
api_instance = giphy_client.DefaultApi()
api_key = 'TOKEN'
q = message.content tag = q.replace('/OwO Giphy ', "")
api_response = api_instance.gifs_search_get(api_key, q=tag, rating='pg13')
gif_list = list(api_response.data)
giff = random.choice(gif_list)
await message.channel.send(giff.embed_url)
Upvotes: 0