Closed shjee-afridi closed 1 year ago
I have so many questions to your code...
First of all, from docs:
In order to properly initialize client, build() function must be called.
Just doing client = Client()
won't do the job. You need to call build()
function otherwise you won't be able to use client.
If you want your bot to receive prefixed commands like !newest
, you need to enable Message content intent in Discord developers portal > Your application > Bot. Then add intents.message_content = True
in your code since it is not a default one.
client.search
method does not have sort_by, order and limit arguments. Where did you find them?? They are simply not present in HH's API. However, I can add these to the library, if you really need it.
In order to get latest episode, better use episode = await home.last_episodes[0].full()
.
Make sure you installed m3u8_To_MP4 and all it's dependencies properly (e.g. ffmpeg).
I really do not recommend to use m3u8_To_MP4's multithread_download
with async libraries like discord.py because it is a blocking function. Your bot will probably throw tons of errors because of code blockage.
After all these changes, your code should look like this:
from discord.ext import commands
import discord, m3u8_To_MP4,
from hhaven import Client
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
@bot.command()
async def newest(ctx):
try:
await ctx.send("Fetching newest hentai video...")
client = await Client().build()
home = await client.home()
episode = await home.last_episodes[0].full()
m3u8_To_MP4.multithread_download(episode.content)
await ctx.send(f"Downloaded the newest video: {episode.hentai_title} - {episode.name}")
except Exception as e:
await ctx.send(f"An error occurred: {e}")
bot.run('')
Since no more questions or comments from you on this issue, I assume the problem is solved. Closing as completed.
Originally posted by @BlackReaper33 in https://github.com/JokelBaf/hhaven/issues/8#issuecomment-1678710773