From b87e4ce24feaf84f7f82a33e4f2b266b06e4f586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=80=8CX=CE=9BOS=E3=80=8D?= <30846531+XAOS1502@users.noreply.github.com> Date: Sun, 19 Nov 2017 14:42:23 +0530 Subject: [PATCH 1/2] Moar commands :thinking: --- cogs/community/nsfw.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cogs/community/nsfw.py b/cogs/community/nsfw.py index dc59115d..bbe44f10 100644 --- a/cogs/community/nsfw.py +++ b/cogs/community/nsfw.py @@ -71,7 +71,10 @@ async def xbooru(self, ctx): try: await ctx.send(embed=em) except discord.HTTPException: - await ctx.send('Unable to send embeds here!') + em_list = await embedtobox.etb(em) + for page in em_list: + await ctx.send(page) + # await ctx.send('Unable to send embeds here!') try: async with ctx.session.get(image) as resp: image = await resp.read() @@ -106,10 +109,10 @@ async def gel(self, ctx): try: await ctx.send(embed=em) except discord.HTTPException: - # em_list = await embedtobox.etb(em) - # for page in em_list: - # await ctx.send(page) - await ctx.send('Unable to send embeds here!') + em_list = await embedtobox.etb(em) + for page in em_list: + await ctx.send(page) + # wait ctx.send('Unable to send embeds here!') try: async with ctx.session.get(image) as resp: image = await resp.read() @@ -123,7 +126,7 @@ async def gel(self, ctx): @nsfw.command() async def gif(self, ctx, *, tag): - """ Get a random lewd gif + """ Get a random lewd gif, or not Usage: gif Available tags: rule34, nsfw, hentai, tits... """ try: From c4e13a132414ea72a2ff959b22893746d200ba92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=80=8CX=CE=9BOS=E3=80=8D?= <30846531+XAOS1502@users.noreply.github.com> Date: Sun, 19 Nov 2017 14:43:29 +0530 Subject: [PATCH 2/2] Update nsfw.py --- cogs/community/nsfw.py | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/cogs/community/nsfw.py b/cogs/community/nsfw.py index bbe44f10..c36222fc 100644 --- a/cogs/community/nsfw.py +++ b/cogs/community/nsfw.py @@ -86,6 +86,49 @@ async def xbooru(self, ctx): except Exception as e: await ctx.send(f'```{e}```') + @commands.command(aliases=['nhentai']) + async def nh(self, ctx): + """Sends a random nhentai doujin""" + try: + try: + await ctx.message.delete() + except discord.Forbidden: + pass + + await ctx.channel.trigger_typing() + query = 'http://nhentai.net/random/' + hdr = {'User-Agent': 'Mozilla/5.0'} + req = Request(query, headers=hdr) + page = urlopen(req) + soup = bs.BeautifulSoup(page, 'html.parser') + + text_description = soup.find('meta', itemprop="name") + img_cover = soup.find('meta', property="og:image")['content'] + manga = soup.title.text.replace('ยป nhentai: hentai doujinshi and manga', '') + + em = discord.Embed(colour=discord.Colour(0xed791d)) + em.description = f'[Doujin Link*]({img_cover}\n\n{text_description})' + em.set_image(url=img_cover) + em.add_field(name='Title:', value=f'{manga}') + em.set_footer(text='* click link at your own risk!') + try: + await ctx.send(embed=em) + except discord.HTTPException: + em_list = await embedtobox.etb(em) + for page in em_list: + await ctx.send(page) + await ctx.send('Unable to send embeds here!') + try: + async with ctx.session.get(img_cover) as resp: + image = await resp.read() + with io.BytesIO(image) as file: + await ctx.send(file=discord.File(file, 'nhentai.png')) + except discord.HTTPException: + await ctx.send(img_cover) + + except Exception as e: + await ctx.send(f'```{e}```') + @commands.command(aliases=['gelbooru']) async def gel(self, ctx): """ Random image from Gelbooru """