mirror of
https://github.com/weyne85/discord_music_bot.git
synced 2025-10-29 16:58:27 +00:00
Adding Reset and Shuffle Controller and some fix
This commit is contained in:
26
Controllers/ShuffleController.py
Normal file
26
Controllers/ShuffleController.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from discord.ext.commands import Context
|
||||
from discord import Client
|
||||
from Controllers.AbstractController import AbstractController
|
||||
from Controllers.ControllerResponse import ControllerResponse
|
||||
from Exceptions.Exceptions import UnknownError
|
||||
from Music.Downloader import Downloader
|
||||
|
||||
|
||||
class ShuffleController(AbstractController):
|
||||
def __init__(self, ctx: Context, bot: Client) -> None:
|
||||
super().__init__(ctx, bot)
|
||||
self.__down = Downloader()
|
||||
|
||||
async def run(self) -> ControllerResponse:
|
||||
try:
|
||||
self.player.playlist.shuffle()
|
||||
songs = self.player.playlist.songs_to_preload
|
||||
|
||||
await self.__down.preload(songs)
|
||||
embed = self.embeds.SONGS_SHUFFLED()
|
||||
return ControllerResponse(self.ctx, embed)
|
||||
except Exception as e:
|
||||
print(f'DEVELOPER NOTE -> Error Shuffling: {e}')
|
||||
error = UnknownError()
|
||||
embed = self.embeds.ERROR_SHUFFLING()
|
||||
return ControllerResponse(self.ctx, embed, error)
|
||||
Reference in New Issue
Block a user