From 69c000cd8f49203157ef79fa2fe9bcbebb73fab8 Mon Sep 17 00:00:00 2001 From: Mantou Date: Fri, 25 Aug 2023 11:53:36 +0800 Subject: [PATCH] Fix(commands.py): add find_playlist function in public commands --- cogs/commands.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cogs/commands.py b/cogs/commands.py index 7169d2a..c84dfa8 100644 --- a/cogs/commands.py +++ b/cogs/commands.py @@ -742,7 +742,7 @@ async def create(self, ctx: ApplicationContext, name:Option( name="public", description="切換歌單的公開狀態" ) - async def public(self, ctx: ApplicationContext, name:Option( + async def public(self, ctx: ApplicationContext, playlist:Option( str, "清單名稱", name="playlist", @@ -762,10 +762,18 @@ async def public(self, ctx: ApplicationContext, name:Option( with open(f"./playlist/{ctx.author.id}.json", "r", encoding="utf-8") as f: data = json.load(f) + name, id = await find_playlist(playlist=playlist, ctx=ctx, public=False) + data[name]["public"] = public with open(f"./playlist/{ctx.author.id}.json", "w", encoding="utf-8") as f: json.dump(data, f, indent=4) + else: + await ctx.interaction.edit_original_response( + embed=ErrorEmbed( + f"你沒有播放清單!" + ) + ) if public is True: await ctx.interaction.edit_original_response(