impr: Update bot to work with updated database and use tracks history.

This commit is contained in:
Lemon4ksan
2025-01-09 12:55:59 +03:00
parent 7d462442cc
commit d797fec45f
5 changed files with 130 additions and 64 deletions

View File

@@ -1,11 +1,13 @@
from typing import cast
from discord.ui import View, Button, Item
from discord import ButtonStyle, Interaction, ApplicationContext
from MusicBot.cogs.utils.voice import VoiceExtension
class PlayPauseButton(Button, VoiceExtension):
def __init__(self, **kwargs):
Button.__init__(self, **kwargs)
VoiceExtension.__init__(self)
async def callback(self, interaction: Interaction) -> None:
vc = self.get_voice_client(interaction)
if vc is not None:
@@ -16,11 +18,24 @@ class PlayPauseButton(Button, VoiceExtension):
self.resume_playing(interaction)
await interaction.edit(content="Результат возобновления.")
class NextTrackButton(Button, VoiceExtension):
class NextTrackButton(Button, VoiceExtension):
def __init__(self, **kwargs):
Button.__init__(self, **kwargs)
VoiceExtension.__init__(self)
async def callback(self, interaction: Interaction) -> None:
await self.next_track(interaction)
await interaction.edit(content='Результат переключения >.')
class PrevTrackButton(Button, VoiceExtension):
def __init__(self, **kwargs):
Button.__init__(self, **kwargs)
VoiceExtension.__init__(self)
async def callback(self, interaction: Interaction) -> None:
await self.prev_track(interaction)
await interaction.edit(content='Результат переключения <.')
class Player(View):
def __init__(self, ctx: ApplicationContext, *items: Item, timeout: float | None = 3600, disable_on_timeout: bool = False):
@@ -33,7 +48,7 @@ class Player(View):
self.queue_button = Button(style=ButtonStyle.primary, emoji='📋', row=0)
self.play_pause_button = PlayPauseButton(style=ButtonStyle.primary, emoji='', row=0)
self.next_button = NextTrackButton(style=ButtonStyle.primary, emoji='', row=0)
self.prev_button = Button(style=ButtonStyle.primary, emoji='', row=0)
self.prev_button = PrevTrackButton(style=ButtonStyle.primary, emoji='', row=0)
self.add_item(self.repeat_button)
self.add_item(self.prev_button)