Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Stacer-Varien committed Dec 10, 2022
1 parent 9e46e7b commit 719ee77
Show file tree
Hide file tree
Showing 7 changed files with 262 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.idea/
.env
nextcord/venv
discord/venv

209 changes: 209 additions & 0 deletions discord/hentaibot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
import json
import os
import requests
import random
import nekos_fun
import discord
from discord.ext import commands
from discord import app_commands
from typing import Optional, Literal


class Bot(discord.Client):
def __init__(self, *, intents: discord.Intents):
super().__init__(intents=intents)
self.tree = app_commands.CommandTree(self)
async def setup_hook(self):
await self.tree.sync()


intents=discord.Intents(messages = True, members = True, typing = True, guilds = True)
bot = Bot(intents=intents)
game = discord.Game("Naughty")

token = os.environ["TOKEN"]

@bot.event
async def on_ready():
print(bot.user.name)
await bot.change_presence(status=discord.Status.idle, activity=game)


@bot.tree.command(description="Shows the help menu", nsfw=True)
async def help(ctx:discord.Interaction):
await ctx.response.defer()
ret = "```\n"
ret += "gelbooru [tags]\n"
ret += "Get image/video from Gelbooru.\n"
ret += "yandere [tags]\n"
ret += "Get image from Yandere.\n"
ret += "konachan [tags]\n"
ret += "Get image from Konachan.\n"
ret += "danbooru [tags]\n"
ret += "Get image from danbooru.\n"
ret += "nekolewd\n"
ret += "Get lewded nekos from NekoLove.\n"
ret += "nekosfun\n"
ret += "Get images/gifs from NekosLife.\n"
ret += "```"
await ctx.followup.send(ret)

@bot.tree.command(description="Get hentai from Gelbooru", nsfw=True)
@app_commands.describe(tag="Add a tag")
async def gelbooru(ctx:discord.Interaction, tag:Optional[str]=None)->None:
await ctx.response.defer()
formated_tag = tag.replace(" ", "_")
if tag == None:
api="https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&limit=100&tags=rating:explicit+-loli+-shota+-cub"
response = requests.get(api)
ret = json.loads(response.text)
post = random.choice(ret["post"])
else:
api="https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&limit=100&tags=rating:explicit+-loli+-shota+-cub" + formated_tag
response = requests.get(api)
ret = json.loads(response.text)
post = random.choice(ret["post"])
source = post["source"]
owner = post["owner"]
score = post["score"]
image:str=post["file_url"]
created_at=post["created_at"]
if image.endswith(".mp4"):
await ctx.followup.send(image)
else:
embed = discord.Embed(title="Created by {}".format(owner))
embed.add_field(name="Source", value="[Click here]({})".format(source), inline=True)
embed.add_field(name="Score", value=score, inline=True)
embed.set_image(url=image)
embed.set_footer(text="Fetched from Gelbooru\nCreated at {}".format(created_at))
await ctx.followup.send(embed=embed)


@bot.tree.command(description="Get hentai from Yandere", nsfw=True)
@app_commands.describe(tag="Add a tag")
async def yandere(ctx: discord.Interaction, tag:Optional[str]=None)->None:
await ctx.response.defer()
if tag == None:
ret = random.choice(requests.get(
"https://yande.re/post.json?limit=100&tags=rating:explicit+-loli+-shota+-cub").json())
else:
tag = tag.replace(" ", "_")
ret = random.choice(requests.get(
"https://yande.re/post.json?limit=100&tags=rating:explicit+-loli+-shota+-cub" + tag).json())
created_at = ret["created_at"]
file=ret["file_url"]
author=ret["author"]
source=ret["source"]
score=ret["score"]
embed = discord.Embed(title="Created by {}".format(author))
embed.add_field(name="Source", value="[Click here]({})".format(source), inline=True)
embed.add_field(name="Score", value=score, inline=True)
embed.set_image(url=file)
embed.set_footer(text="Fetched from Yande.re\nCreated at {}".format(created_at))
await ctx.followup.send(embed=embed)


@bot.tree.command(description="Get hentai from Konachan", nsfw=True)
@app_commands.describe(tag="Add a tag")
async def konachan(ctx:discord.Interaction, tag:Optional[str]=None)->None:
await ctx.response.defer()
if tag == None:
ret = random.choice(requests.get("https://konachan.com/post.json?s=post&q=index&limit=100&tags=rating:explicit+-loli+-shota+-cub").json())

else:
tag = tag.replace(" ", "_")
ret = random.choice(requests.get(f"https://konachan.com/post.json?s=post&q=index&limit=100&tags=rating:explicit+-loli+-shota+-cub" + tag).json())

created_at = ret["created_at"]
file = ret["file_url"]
author = ret["author"]
source = ret["source"]
score = ret["score"]
embed = discord.Embed(title="Created by {}".format(author))
embed.add_field(
name="Source", value="[Click here]({})".format(source), inline=True)
embed.add_field(name="Score", value=score, inline=True)
embed.set_image(url=file)
embed.set_footer(
text="Fetched from Konachan\nCreated at {}".format(created_at))
await ctx.followup.send(embed=embed)


@bot.tree.command(description="Get hentai from Danbooru", nsfw=True)
@app_commands.describe(tag="Add a tag")
async def danbooru(ctx: discord.Interaction, tag:Optional[str]=None)->None:
await ctx.response.defer()
if tag == None:
ret = random.choice(requests.get(
"https://danbooru.donmai.us/posts.json?limit=100&tags=rating:explicit-loli-shota-cub").json())

else:
tag = tag.replace(" ", "_")
ret = random.choice(requests.get(
"https://danbooru.donmai.us/posts.json?limit=100&tags=rating:explicit-loli-shota-cub" + tag).json())

created_at = ret["created_at"]
file = ret["file_url"]
author = ret["tag_string_artist"]
source = ret["source"]
score = ret["score"]
embed = discord.Embed(title="Created by {}".format(author))
embed.add_field(
name="Source", value="[Click here]({})".format(source), inline=True)
embed.add_field(name="Score", value=score, inline=True)
embed.set_image(url=file)
embed.set_footer(
text="Fetched from Danbooru\nCreated at {}".format(created_at))
await ctx.followup.send(embed=embed)


@bot.tree.command(description="Get lewded nekos from NekoLove", nsfw=True)
async def nekolewd(ctx:discord.Interaction):
await ctx.response.defer()
ret = requests.get("https://neko-love.xyz/api/v1/nekolewd").json()
response=ret["code"]
image=ret["url"]

if response !=200:
embed = discord.Embed(description="Error with API!\nPlease contact the neko-love.xyz team. If the fault is not on their side, please reach up to me")
await ctx.followup.send(embed=embed)
else:
embed = discord.Embed()
embed.set_image(url=image)
embed.set_footer(
text="Fetched from NekoLove")
await ctx.followup.send(embed=embed)


@bot.tree.command(description="Get an image/gif from NekosLife", nsfw=True)
@app_commands.describe(tag="Which tag?")
async def nekosfun(ctx:discord.Interaction, tag:Optional[Literal["ass", "bj", "boobs", "cum", "hentai", "spank", "gasm", "lesbian", "pussy"]]):
if tag == None:
tags = ["ass", "bj", "boobs", "cum", "hentai",
"spank", "gasm", "lesbian", "pussy"]
image = nekos_fun.nekofun(random.choice(tags))

else:
image = nekos_fun.nekofun(str(tag))

if image != 200:
await ctx.followup.send(image)
else:
embed = discord.Embed()
embed.set_image(url=image)
embed.set_footer(
text="Fetched from Nekos.Fun")
await ctx.followup.send(embed=embed)

@bot.tree.command(description="Ask a member if you can f*ck them")
@app_commands.describe(member="Which member?")
async def f_ck(ctx:discord.Integration, member:Member)

@bot.event
async def on_application_command_error(ctx:discord.Interaction, error:app_commands.AppCommandError):
if isinstance(error, KeyError):
embed = discord.Embed(title="Hentai Failed", description="Hentai couldn't be sent in this channel",
color=0xff0000).add_field(name="Reason", value="Tag not found")
await ctx.followup.send(embed=embed)

bot.run(token)
File renamed without changes.
13 changes: 13 additions & 0 deletions discord/requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os
import platform

pip_install = 'pip install -U pip'
packages = 'pip install -U discord requests'

if platform.system == 'Windows': # if OS is Windows
os.system('python.exe -m' + pip_install)

elif platform.system=='Linux': # if OS is Linux
os.system('python3 -m' + pip_install)

os.system(packages)
44 changes: 14 additions & 30 deletions run.py → nextcord/hentaibot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import os
import math
import requests
import random
import nextcord
Expand All @@ -16,28 +15,6 @@

token = os.environ["TOKEN"]


def toHHMMSS(this):
myNum = int(this)
hours = math.floor(myNum / 3600000)
minutes = math.floor((myNum - (hours * 3600000)) / 60000)
seconds = math.floor((myNum - (hours * 3600000) - (minutes * 60000)) / 1000)

if (hours < 10):
hours = "0" + str(hours)
else:
hours = str(hours)
if (minutes < 10):
minutes = "0" + str(minutes)
else:
minutes = str(minutes)
if (seconds < 10):
seconds = "0" + str(seconds)
else:
seconds = str(seconds)
return hours + ":" + minutes + ":" + seconds


@bot.event
async def on_ready():
print(bot.user.name)
Expand All @@ -49,11 +26,17 @@ async def help(ctx:nextcord.Interaction):
await ctx.response.defer()
ret = "```\n"
ret += "gelbooru [tags]\n"
ret += "Get image from Gelbooru.\n"
ret += "Get image/video from Gelbooru.\n"
ret += "yandere [tags]\n"
ret += "Get image from Yandere.\n"
ret += "hanime [title]\n"
ret += "Retrieve adult animation information from HTV (tag required).\n"
ret += "konachan [tags]\n"
ret += "Get image from Konachan.\n"
ret += "danbooru [tags]\n"
ret += "Get image from danbooru.\n"
ret += "nekolewd\n"
ret += "Get lewded nekos from NekoLove.\n"
ret += "nekosfun\n"
ret += "Get images/gifs from NekosLife.\n"
ret += "```"
await ctx.followup.send(ret)

Expand Down Expand Up @@ -135,7 +118,6 @@ async def konachan(ctx:nextcord.Interaction, tag=nextcord.SlashOption(required=F
text="Fetched from Konachan\nCreated at {}".format(created_at))
await ctx.followup.send(embed=embed)


@bot.slash_command()
@is_nsfw()
async def danbooru(ctx: nextcord.Interaction, tag=nextcord.SlashOption(required=False)):
Expand Down Expand Up @@ -201,13 +183,15 @@ async def nekosfun(ctx:nextcord.Interaction, tag=nextcord.SlashOption(choices=["
text="Fetched from Nekos.Fun")
await ctx.followup.send(embed=embed)



@bot.event
async def on_application_command_error(ctx:nextcord.Interaction, error):
async def on_application_command_error(ctx:nextcord.Interaction, error:Appli):
if isinstance(error, ApplicationNSFWChannelRequired):
await ctx.response.defer()
embed = nextcord.Embed(title="Hentai Failed", description="Hentai couldn't be sent in this channel", color=0xff0000).add_field(name="Reason", value="Channel is not NSFW enabled")
await ctx.followup.send(embed=embed)
if isinstance(error, KeyError):
embed = nextcord.Embed(title="Hentai Failed", description="Hentai couldn't be sent in this channel",
color=0xff0000).add_field(name="Reason", value="Tag not found")
await ctx.followup.send(embed=embed)

bot.run(token)
10 changes: 10 additions & 0 deletions nextcord/nekos_fun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import requests


def nekofun(endpoint:str):
r = requests.get("http://api.nekos.fun:8080/api/" + endpoint)
if r.status_code != 200:
return("An error has occurred")
else:
return(r.json()["url"])

13 changes: 13 additions & 0 deletions nextcord/requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os
import platform

pip_install = 'pip install -U pip'
packages = 'pip install -U nextcord requests'

if platform.system == 'Windows': # if OS is Windows
os.system('python.exe -m' + pip_install)

elif platform.system=='Linux': # if OS is Linux
os.system('python3 -m' + pip_install)

os.system(packages)

0 comments on commit 719ee77

Please sign in to comment.