sir-lancebot
sir-lancebot copied to clipboard
KeyError: 'image_url' in spookygif command
Sentry Issue: SIR-LANCEBOT-83
KeyError: 'image_url'
File "discord/ext/commands/core.py", line 167, in wrapped
ret = await coro(*args, **kwargs)
File "bot/exts/holidays/halloween/spookygif.py", line 28, in spookygif
url = data["data"]["image_url"]
Unhandled command error: 'image_url'
This happens whenever running the .spookygif command, as image_url doesn't exist in the reponse from the API. Changing the line to url = data["data"]["url"] might work instead. See the API docs here https://developers.giphy.com/docs/api/endpoint#random
posted by wookie184
Can you please assign this to me?
@SaumyaBhushan Thanks, I've assigned you. Note that the fix I mentioned in the issue may not be right. I think Discord may need a GIF, so looking at the docs we may need one of the other URLs in the response like data["data"]["images"]["downsized_large"]["url"] for it to work.
@wookie184 how about using embed_url in gif object, its given in documentation,
they must serve the purpose rightly here if i am not wrong ?

@wookie184 how about using
embed_urlin gif object, its given in documentation, they must serve the purpose rightly here if i am not wrong ?
It does look like it should work although I think I tried it a while back and it didn't seem to. Would be fine if it does work, although any solution would need testing.
Can I please be assigned this issue?
I believe I have fixed this.
@JBarth86 it is done.