From 09079e95cdd51c3bdeec8c1a8c098448890596de Mon Sep 17 00:00:00 2001 From: franchioping Date: Thu, 25 Jul 2024 00:35:18 +0100 Subject: [PATCH] README.md + various fixes --- README.md | 29 +++++++++++++++++++++++++++-- main.py | 14 ++++---------- manager.py | 7 +++++++ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3ccba47..78249a3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,28 @@ -# MangaBot +# Manga Bot + +### 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 + -A discord bot that tells you when manga comes out \ No newline at end of file diff --git a/main.py b/main.py index 725e95b..0521c70 100644 --- a/main.py +++ b/main.py @@ -21,16 +21,6 @@ tree = app_commands.CommandTree(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]): chanel = await interaction.user.create_dm() 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", ) @app_commands.describe(title='Title of the manga to search for') +@app_commands.user_install() +@discord.app_commands.guild_install() async def search_command( interaction: discord.Interaction, title: str @@ -83,6 +75,8 @@ async def search_command( name="list", description="List the manga you follow", ) +@app_commands.user_install() +@discord.app_commands.guild_install() async def list_command(interaction: discord.Interaction): await interaction.response.defer() diff --git a/manager.py b/manager.py index 4cf00be..2c25c32 100644 --- a/manager.py +++ b/manager.py @@ -38,6 +38,8 @@ class Manager: self.manga[manga.id].remove(user.id) if len(self.manga[manga.id]) == 0: self.manga.pop(manga.id) + if manga.id in self.chapters.keys(): + self.chapters.pop(manga.id) else: self.manga[manga.id] = [] @@ -95,6 +97,11 @@ class Manager: self.chapters = data["chapters"] 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 { "manga": self.manga, "chapters": self.chapters