Added forward and rewind button

This commit is contained in:
Choco
2023-05-04 19:52:04 +08:00
parent 2f5e4759f0
commit 6bb2180c6b
7 changed files with 54 additions and 1 deletions

View File

@@ -120,6 +120,8 @@
"buttonVolumeUnmute": "取消靜音",
"buttonAutoPlay": "自動播放",
"buttonShuffle": "隨機播放",
"buttonForward": "前進",
"buttonRewind": "後退",
"nowplayingDesc": "**現在播放:**\n```{0}```",
"nowplayingField": "接下來播放:",

View File

@@ -120,6 +120,8 @@
"buttonVolumeUnmute": "Stummschaltung aufheben",
"buttonAutoPlay": "Autoplay",
"buttonShuffle": "Mischen",
"buttonForward": "Vorwärts",
"buttonRewind": "Rückwärts",
"nowplayingDesc": "**Jetzt abspielen:**\n```{0}```",
"nowplayingField": "Als nächstes:",

View File

@@ -120,6 +120,8 @@
"buttonVolumeUnmute": "Unmute",
"buttonAutoPlay": "Autoplay",
"buttonShuffle": "Shuffle",
"buttonForward": "Forward",
"buttonRewind": "Rewind",
"nowplayingDesc": "**Now Playing:**\n```{0}```",
"nowplayingField": "Up Next:",

View File

@@ -120,6 +120,8 @@
"buttonVolumeUnmute": "Activar Sonido",
"buttonAutoPlay": "Reproducción Automática",
"buttonShuffle": "Aleatorio",
"buttonForward": "Adelante",
"buttonRewind": "Atrás",
"nowplayingDesc": "**Reproduciendo ahora:**\n```{0}```",
"nowplayingField": "A continuación:",

View File

@@ -120,6 +120,8 @@
"buttonVolumeUnmute": "消音を解除",
"buttonAutoPlay": "自動再生",
"buttonShuffle": "シャッフル",
"buttonForward": "進む",
"buttonRewind": "戻る",
"nowplayingDesc": "**現在再生中:**\n```{0}```",
"nowplayingField": "次に再生する曲:",

View File

@@ -120,6 +120,8 @@
"buttonVolumeUnmute": "음소거 해제",
"buttonAutoPlay": "자동재생",
"buttonShuffle": "셔플",
"buttonForward": "앞으로",
"buttonRewind": "뒤로",
"nowplayingDesc": "**현재 재생중인 곡:**\n```{0}```",
"nowplayingField": "다음 곡:",

View File

@@ -31,6 +31,7 @@ from function import (
update_playlist,
create_account,
checkroles,
formatTime
)
from typing import Dict
@@ -282,6 +283,44 @@ class Shuffle(discord.ui.Button):
await self.player.shuffle("queue", interaction.user)
await interaction.response.send_message(self.player.get_msg('shuffled'))
class Forward(discord.ui.Button):
def __init__(self, player, style, row):
self.player = player
super().__init__(emoji="",
label=player.get_msg('buttonForward'),
disabled=False if self.player.current else True,
style=style, row=row)
async def callback(self, interaction: discord.Interaction):
if not self.player.is_privileged(interaction.user):
return await interaction.response.send_message(self.player.get_msg('missingPerms_pos'), ephemeral=True)
if not self.player.current:
return await interaction.response.send_message(self.player.get_msg('noTrackPlaying'), ephemeral=True)
await self.player.seek(self.player.position + 10000)
await interaction.response.send_message(self.player.get_msg('forward').format(func.time(self.player.position + 10000)))
class Rewind(discord.ui.Button):
def __init__(self, player, style, row):
self.player = player
super().__init__(emoji="",
label=player.get_msg('buttonRewind'),
disabled=False if self.player.current else True,
style=style, row=row)
async def callback(self, interaction: discord.Interaction):
if not self.player.is_privileged(interaction.user):
return await interaction.response.send_message(self.player.get_msg('missingPerms_pos'), ephemeral=True)
if not self.player.current:
return await interaction.response.send_message(self.player.get_msg('noTrackPlaying'), ephemeral=True)
position = 0 if (value := (self.player.position - 10000)) <= 0 else value
await self.player.seek(position)
await interaction.response.send_message(self.player.get_msg('rewind').format(func.time(position)))
class Tracks(discord.ui.Select):
def __init__(self, player, style, row):
@@ -320,7 +359,9 @@ btnType = {
"volumemute": VolumeMute,
"tracks": Tracks,
"autoplay": AutoPlay,
"shuffle": Shuffle
"shuffle": Shuffle,
"forward": Forward,
"rewind": Rewind
}
btnColor = {