'How can i make an NSFW command in discord.py
I've been following a discord bot tutorial, here is the video - https://www.youtube.com/watch?v=zu6HuEUIuxI
Here is my current code:
@client.command()
@commands.is_nsfw()
async def hentai(ctx):
r = requests.get("https://nekos.life/api/v2/img/hentai")
res = r.json()
em = discord.Embed()
em.set_image(url=res['url'])
await ctx.send(embed=em)
The error I get is as followed:
Traceback (most recent call last):
File "C:\Users\.\PycharmProjects\Kushina 2.0\venv\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\.\PycharmProjects\Kushina 2.0\venv\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\.\PycharmProjects\Kushina 2.0\venv\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'url'
Does anyone have a way of writing code for this command that works?
Solution 1:[1]
If you would watch video carefully then you should see (at time 1:50) that author tests link
https://nekos.life/api/v2/endpoints
and this page shows allowed links in API.
If you test this link now in browser then you will see it still works but there is NO hentai on this list.
But there are other still working links. smug', 'woof', 'gasm', '8ball', 'goose', 'cuddle', 'avatar', 'slap', 'v3', 'pat', 'gecg', 'feed', 'fox_girl', 'lizard', 'neko', 'hug', 'meow', 'kiss', 'wallpaper', 'tickle', 'spank', 'waifu', 'lewd', 'ngif
ie.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | furas |
