Skip to content

Commit

Permalink
Fix(commands.py): add find_playlist function in public commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Mantouisyummy committed Aug 25, 2023
1 parent 749d493 commit 69c000c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cogs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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(
Expand Down

0 comments on commit 69c000c

Please sign in to comment.