From d793cb2930e4b19517a244739be29f351a9deb59 Mon Sep 17 00:00:00 2001 From: tmddn3070 Date: Mon, 11 Dec 2023 02:25:45 +0900 Subject: [PATCH] update --- Christmas/Cogs/Commands_Util.py | 9 +++------ Christmas/Database/__init__.py | 3 +++ Christmas/UI/Embed.py | 7 +++++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Christmas/Cogs/Commands_Util.py b/Christmas/Cogs/Commands_Util.py index 498ad64..f45e009 100644 --- a/Christmas/Cogs/Commands_Util.py +++ b/Christmas/Cogs/Commands_Util.py @@ -27,12 +27,9 @@ class CUtil(Cog): @cooldown(1, 10, BucketType.user) @slash_command(name="서버탈퇴", description="서버에서 탈퇴합니다.") async def _leave(self, ctx: Context): - try: - if not await database.get_guild(ctx.guild.id): return await ctx.respond(embed=Default_Embed.not_register(), ephemeral=True) - #await database.leave_guild(ctx.guild.id) - await ctx.respond(embed=Default_Embed.leave_sucess()) - except Exception as e: - await ctx.respond(embed=Default_Embed.leave_failed()) + if not await database.get_guild(ctx.guild.id): return await ctx.respond(embed=Default_Embed.not_register(), ephemeral=True) + await database.leave_guild(ctx.guild.id) + await ctx.respond(embed=Default_Embed.leave_sucess()) @guild_only() diff --git a/Christmas/Database/__init__.py b/Christmas/Database/__init__.py index 4c00c21..e9cbf47 100644 --- a/Christmas/Database/__init__.py +++ b/Christmas/Database/__init__.py @@ -20,6 +20,9 @@ class database: async def register_guild(guild_id: int) -> None: conn = await MongoDBClient().connect() await conn.guild.insert_one({"_id": guild_id, "admin_run": False, "music": True}) + async def leave_guild(guild_id: int) -> None: + conn = await MongoDBClient().connect() + await conn.guild.delete_one({"_id": guild_id}) async def insert_mail(send_user_id: int, user_id: int, user_name: str, mail_title: str, mail_content: str): try: diff --git a/Christmas/UI/Embed.py b/Christmas/UI/Embed.py index dada436..0a5e334 100644 --- a/Christmas/UI/Embed.py +++ b/Christmas/UI/Embed.py @@ -69,6 +69,13 @@ class Default_Embed: def cooldown(sec): return "이 명령어는 " + f"``{round(sec, 2)}``" + "초 뒤에 다시 사용할 수 있어요!" + @staticmethod + def leave_sucess(): + embed = ChristmasEmbed(title="🎉 탈퇴 성공!", description="서버에서 탈퇴했어요!") + embed.add_field(name="안내", value="크돌이를 이용해주셔서 감사해요!", inline=False) + embed.set_footer() + return embed + @staticmethod def help(): embed = ChristmasEmbed(title="🎉 크돌이 도움말", description="크리스마스를 즐겨보세요!")