Skip to content

Commit

Permalink
Merge pull request #139 from Nat1anWasTaken/137-feat-option-to-enable…
Browse files Browse the repository at this point in the history
…-shuffle-on-play-command

feat(lava/cogs/commands.py): add shuffle option to play command
  • Loading branch information
Nat1anWasTaken authored Jun 12, 2024
2 parents fd24ebb + eaf3700 commit afb99da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lava/cogs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,17 @@ async def nowplaying(self, interaction: ApplicationCommandInteraction):
description=Localized("要將歌曲放置於當前播放序列的位置", key="command.play.option.index"),
type=OptionType.integer,
required=False
),
Option(
name="shuffle",
description=Localized("是否開啟隨機播放模式", key="command.play.option.shuffle"),
type=OptionType.boolean,
required=False
)
]
)
async def play(self, interaction: ApplicationCommandInteraction, query: str, index: int = None):
async def play(self, interaction: ApplicationCommandInteraction, query: str,
index: int = None, shuffle: bool = False):
await interaction.response.defer()

await ensure_voice(interaction, should_connect=True)
Expand Down Expand Up @@ -242,6 +249,8 @@ async def play(self, interaction: ApplicationCommandInteraction, query: str, ind
if not player.is_playing:
await player.play()

player.set_shuffle(shuffle=shuffle)

await player.update_display(await interaction.original_response(), delay=5, locale=interaction.locale)

@commands.slash_command(
Expand Down
1 change: 1 addition & 0 deletions locale/zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"command.play.description": "播放音樂",
"command.play.option.query": "歌曲名稱或網址,支援 YouTube, YouTube Music, SoundCloud, Spotify",
"command.play.option.index": "要將歌曲放置於當前播放序列的位置",
"command.play.option.shuffle": "是否開啟隨機播放模式",
"command.play.error.no_results.title": "沒有找到任何歌曲",
"command.play.error.no_results.description": "如果你想要使用關鍵字搜尋,請在輸入關鍵字後等待幾秒,搜尋結果將會自動顯示在上方",
"command.play.filter_warning.title": "提醒",
Expand Down

0 comments on commit afb99da

Please sign in to comment.