mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Adding Reset and Shuffle Controller and some fix
This commit is contained in:
151
Music/Player.py
151
Music/Player.py
@@ -176,62 +176,6 @@ class Player(commands.Cog):
|
||||
|
||||
await self.__play_music(ctx, song)
|
||||
|
||||
async def queue(self) -> Embed:
|
||||
if self.__playlist.looping_one:
|
||||
info = self.__playlist.current.info
|
||||
title = self.__config.ONE_SONG_LOOPING
|
||||
return self.__format_embed(info, title)
|
||||
|
||||
songs_preload = self.__playlist.songs_to_preload
|
||||
|
||||
if len(songs_preload) == 0:
|
||||
title = self.__config.SONG_PLAYER
|
||||
text = self.__config.EMPTY_QUEUE
|
||||
|
||||
else:
|
||||
if self.__playlist.looping_all:
|
||||
title = self.__config.ALL_SONGS_LOOPING
|
||||
else:
|
||||
title = self.__config.QUEUE_TITLE
|
||||
|
||||
await self.__down.preload(songs_preload)
|
||||
|
||||
total_time = format_time(sum([int(song.duration if song.duration else 0)
|
||||
for song in songs_preload]))
|
||||
total_songs = len(self.__playlist)
|
||||
|
||||
text = f'📜 Queue length: {total_songs} | ⌛ Duration: `{total_time}` downloaded \n\n'
|
||||
|
||||
for pos, song in enumerate(songs_preload, start=1):
|
||||
song_name = song.title if song.title else self.__config.SONG_DOWNLOADING
|
||||
text += f"**`{pos}` - ** {song_name} - `{format_time(song.duration)}`\n"
|
||||
|
||||
embed = Embed(
|
||||
title=title,
|
||||
description=text,
|
||||
colour=self.__config.COLOURS['blue']
|
||||
)
|
||||
|
||||
return embed
|
||||
|
||||
def history(self) -> Embed:
|
||||
history = self.__playlist.songs_history
|
||||
|
||||
if len(history) == 0:
|
||||
text = self.__config.HISTORY_EMPTY
|
||||
|
||||
else:
|
||||
text = f'\n📜 History Length: {len(history)} | Max: {self.__config.MAX_SONGS_HISTORY}\n'
|
||||
for pos, song in enumerate(history, start=1):
|
||||
text += f"**`{pos}` - ** {song.title} - `{format_time(song.duration)}`\n"
|
||||
|
||||
embed = Embed(
|
||||
title=self.__config.HISTORY_TITLE,
|
||||
description=text,
|
||||
colour=self.__config.COLOURS['blue']
|
||||
)
|
||||
return embed
|
||||
|
||||
async def stop(self) -> bool:
|
||||
if self.__guild.voice_client is None:
|
||||
return False
|
||||
@@ -255,101 +199,6 @@ class Player(commands.Cog):
|
||||
except Exception as e:
|
||||
print(f'DEVELOPER NOTE -> Force Stop Error: {e}')
|
||||
|
||||
async def pause(self) -> bool:
|
||||
if self.__guild.voice_client == None:
|
||||
return False
|
||||
|
||||
if self.__guild.voice_client.is_playing():
|
||||
self.__guild.voice_client.pause()
|
||||
return True
|
||||
|
||||
async def resume(self) -> bool:
|
||||
if self.__guild.voice_client == None:
|
||||
return False
|
||||
|
||||
if self.__guild.voice_client.is_paused():
|
||||
self.__guild.voice_client.resume()
|
||||
return True
|
||||
|
||||
async def loop(self, args: str) -> str:
|
||||
args = args.lower()
|
||||
if self.__playlist.current == None:
|
||||
return self.__config.PLAYER_NOT_PLAYING
|
||||
|
||||
if args == 'one':
|
||||
description = self.__playlist.loop_one()
|
||||
elif args == 'all':
|
||||
description = self.__playlist.loop_all()
|
||||
elif args == 'off':
|
||||
description = self.__playlist.loop_off()
|
||||
else:
|
||||
raise commands.UserInputError(self.__config.MY_ERROR_BAD_COMMAND)
|
||||
|
||||
return description
|
||||
|
||||
async def clear(self) -> None:
|
||||
self.__playlist.clear()
|
||||
|
||||
async def now_playing(self) -> Embed:
|
||||
if not self.__playing:
|
||||
embed = Embed(
|
||||
title=self.__config.SONG_PLAYER,
|
||||
description=self.__config.PLAYER_NOT_PLAYING,
|
||||
colour=self.__config.COLOURS['blue']
|
||||
)
|
||||
return embed
|
||||
|
||||
if self.__playlist.looping_one:
|
||||
title = self.__config.ONE_SONG_LOOPING
|
||||
else:
|
||||
title = self.__config.SONG_PLAYING
|
||||
|
||||
current_song = self.__playlist.current
|
||||
embed = self.__format_embed(current_song.info, title)
|
||||
|
||||
return embed
|
||||
|
||||
async def shuffle(self) -> str:
|
||||
try:
|
||||
self.__playlist.shuffle()
|
||||
songs = self.__playlist.songs_to_preload
|
||||
|
||||
await self.__down.preload(songs)
|
||||
return self.__config.SONGS_SHUFFLED
|
||||
except:
|
||||
return self.__config.ERROR_SHUFFLING
|
||||
|
||||
async def move(self, pos1, pos2='1') -> str:
|
||||
if not self.__playing:
|
||||
return self.__config.PLAYER_NOT_PLAYING
|
||||
|
||||
try:
|
||||
pos1 = int(pos1)
|
||||
pos2 = int(pos2)
|
||||
|
||||
except:
|
||||
return self.__config.ERROR_NUMBER
|
||||
|
||||
result = self.__playlist.move_songs(pos1, pos2)
|
||||
|
||||
songs = self.__playlist.songs_to_preload
|
||||
await self.__down.preload(songs)
|
||||
return result
|
||||
|
||||
async def remove(self, position) -> str:
|
||||
"""Remove a song from the queue in the position"""
|
||||
if not self.__playing:
|
||||
return self.__config.PLAYER_NOT_PLAYING
|
||||
|
||||
try:
|
||||
position = int(position)
|
||||
|
||||
except:
|
||||
return self.__config.ERROR_NUMBER
|
||||
|
||||
result = self.__playlist.remove_song(position)
|
||||
return result
|
||||
|
||||
def __format_embed(self, info: dict, title='', position='Playing Now') -> Embed:
|
||||
"""Configure the embed to show the song information"""
|
||||
embedvc = Embed(
|
||||
|
||||
Reference in New Issue
Block a user