Add loop controller button

This commit is contained in:
Choco
2023-02-20 19:15:53 +08:00
parent a5051e0c9c
commit 23e9f3e864
6 changed files with 25 additions and 0 deletions

View File

@@ -116,6 +116,7 @@
"buttonResume": "恢復",
"buttonSkip": "跳過",
"buttonLeave": "離開",
"buttonLoop": "重複",
"nowplayingDesc": "**現在播放:**\n```{0}```",
"nowplayingField": "接下來:",

View File

@@ -116,6 +116,7 @@
"buttonResume": "Fortsetzen",
"buttonSkip": "Überspringen",
"buttonLeave": "Verlassen",
"buttonLoop": "wiederholen",
"nowplayingDesc": "**Läuft gerade:**\n```{0}```",
"nowplayingField": "Als nächstes:",

View File

@@ -116,6 +116,7 @@
"buttonResume": "Resume",
"buttonSkip": "Skip",
"buttonLeave": "Leave",
"buttonLoop": "Loop",
"nowplayingDesc": "**Now Playing:**\n```{0}```",
"nowplayingField": "Up Next:",

View File

@@ -116,6 +116,7 @@
"buttonResume": "再開",
"buttonSkip": "スキップ",
"buttonLeave": "離れる",
"buttonLoop": "繰り返す",
"nowplayingDesc": "**再生中:**\n```{0}```",
"nowplayingField": "次に:",

View File

@@ -116,6 +116,7 @@
"buttonResume": "이력서",
"buttonSkip": "거르다",
"buttonLeave": "떠나다",
"buttonLoop": "반복하다",
"nowplayingDesc": "**지금 재생 중:**\n```{0}```",
"nowplayingField": "다음으로:",

View File

@@ -185,6 +185,25 @@ class Add(discord.ui.Button):
else:
await interaction.response.send_message(self.player.get_msg("playlistAddError2"), ephemeral=True)
class Loop(discord.ui.Button):
def __init__(self, player, style, row):
self.player = player
self.loopType = {
0: "off",
1: "track",
2: "queue",
}
super().__init__(emoji="🔁", label=player.get_msg('buttonLoop'), style=style, row=row)
async def callback(self, interaction: discord.Interaction):
if not await self.player.is_privileged(interaction.user):
return await interaction.response.send_message(self.player.get_msg('missingPerms_mode'), ephemeral=True)
current_repeat = self.player.queue._repeat
mode = self.loopType.get((current_repeat + 1)%len(self.loopType), 'off')
self.player.queue.set_repeat(mode)
await interaction.response.send_message(self.player.get_msg('repeat').format(mode.capitalize()))
class Tracks(discord.ui.Select):
def __init__(self, player, style, row):
@@ -217,6 +236,7 @@ btnType = {
"skip": Skip,
"stop": Stop,
"add": Add,
"loop": Loop,
"tracks": Tracks
}