Skip to content
This repository has been archived by the owner on Jul 31, 2018. It is now read-only.

Moar commands #213

Open
wants to merge 2 commits into
base: rewrite
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 52 additions & 6 deletions cogs/community/nsfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -83,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 """
Expand All @@ -106,10 +152,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()
Expand All @@ -123,7 +169,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 <tag>
Available tags: rule34, nsfw, hentai, tits... """
try:
Expand Down