README.md + various fixes

This commit is contained in:
franchioping 2024-07-25 00:35:18 +01:00
parent 3cd3e44430
commit 09079e95cd
3 changed files with 38 additions and 12 deletions

View File

@ -1,3 +1,28 @@
# Manga Bot # Manga Bot
A discord bot that tells you when manga comes out ### A discord bot that tells you when manga comes out!!!
# How To Use
### Option 1:
Add it to your server or do a user install here: [Discord Invite](https://discord.com/oauth2/authorize?client_id=1265022463964610721)
### Option 2:
Join my testing server and give it a shot: [My Server](https://discord.gg/q3SevqVHN5)
# Commands
## /list
> will list the manga you are currently following
## /search *title*
> Will search for the manga, allowing you to follow it.
>
> Title doesnt need to be perfect

14
main.py
View File

@ -21,16 +21,6 @@ tree = app_commands.CommandTree(client)
man = manager.Manager(client) man = manager.Manager(client)
@tree.command(
name="ping",
description="My first application Command",
guild=discord.Object(id=1042133536926347324)
)
async def first_command(interaction: discord.Interaction):
chanel = await interaction.user.create_dm()
await chanel.send("Hi")
async def render_manga_list_in_dm(interaction: discord.Interaction, manga_list: list[manga_api.Manga]): async def render_manga_list_in_dm(interaction: discord.Interaction, manga_list: list[manga_api.Manga]):
chanel = await interaction.user.create_dm() chanel = await interaction.user.create_dm()
await interaction.followup.send("Check your DM's") await interaction.followup.send("Check your DM's")
@ -70,6 +60,8 @@ async def render_manga_list_in_dm(interaction: discord.Interaction, manga_list:
description="Search for manga to follow", description="Search for manga to follow",
) )
@app_commands.describe(title='Title of the manga to search for') @app_commands.describe(title='Title of the manga to search for')
@app_commands.user_install()
@discord.app_commands.guild_install()
async def search_command( async def search_command(
interaction: discord.Interaction, interaction: discord.Interaction,
title: str title: str
@ -83,6 +75,8 @@ async def search_command(
name="list", name="list",
description="List the manga you follow", description="List the manga you follow",
) )
@app_commands.user_install()
@discord.app_commands.guild_install()
async def list_command(interaction: discord.Interaction): async def list_command(interaction: discord.Interaction):
await interaction.response.defer() await interaction.response.defer()

View File

@ -38,6 +38,8 @@ class Manager:
self.manga[manga.id].remove(user.id) self.manga[manga.id].remove(user.id)
if len(self.manga[manga.id]) == 0: if len(self.manga[manga.id]) == 0:
self.manga.pop(manga.id) self.manga.pop(manga.id)
if manga.id in self.chapters.keys():
self.chapters.pop(manga.id)
else: else:
self.manga[manga.id] = [] self.manga[manga.id] = []
@ -95,6 +97,11 @@ class Manager:
self.chapters = data["chapters"] self.chapters = data["chapters"]
def to_dict(self): def to_dict(self):
for manga_id in self.manga.keys():
if len(self.manga[manga_id]) == 0:
self.manga.pop(manga_id)
if manga_id in self.chapters.keys():
self.chapters.pop(manga_id)
return { return {
"manga": self.manga, "manga": self.manga,
"chapters": self.chapters "chapters": self.chapters