mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Adding move song command
This commit is contained in:
@@ -205,6 +205,25 @@ class Music(commands.Cog):
|
|||||||
|
|
||||||
await self.__send_embed(ctx, description='Musicas embaralhadas', colour_name='blue')
|
await self.__send_embed(ctx, description='Musicas embaralhadas', colour_name='blue')
|
||||||
|
|
||||||
|
@commands.command(name='move', help='Manda uma música de uma posição para outra <from> <to>')
|
||||||
|
async def move(self, ctx, pos1, pos2='1'):
|
||||||
|
try:
|
||||||
|
pos1 = int(pos1)
|
||||||
|
pos2 = int(pos2)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
await ctx.send('This command require a number')
|
||||||
|
return
|
||||||
|
|
||||||
|
success, reason = self.__playlist.move_songs(pos1, pos2)
|
||||||
|
|
||||||
|
if not success:
|
||||||
|
songs = self.__playlist.songs_to_preload
|
||||||
|
await self.__downloader.preload(songs)
|
||||||
|
await ctx.send(reason)
|
||||||
|
else:
|
||||||
|
await ctx.send(reason)
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Music(bot))
|
bot.add_cog(Music(bot))
|
||||||
|
|||||||
@@ -139,3 +139,23 @@ class Playlist(IPlaylist):
|
|||||||
if song == song_destroy:
|
if song == song_destroy:
|
||||||
self.__queue.remove(song)
|
self.__queue.remove(song)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
def move_songs(self, pos1, pos2) -> tuple:
|
||||||
|
"""Receive two position and try to chance the songs in those positions
|
||||||
|
|
||||||
|
Positions: First music is 1
|
||||||
|
Return (Error bool, string) with the status of the function, to show to user
|
||||||
|
"""
|
||||||
|
if pos2 not in range(1, len(self.__queue)) or pos1 not in range(1, len(self.__queue)):
|
||||||
|
return (False, 'Numbers need to be more than 0 and less than the queue length')
|
||||||
|
|
||||||
|
try:
|
||||||
|
song1 = self.__queue[pos1-1]
|
||||||
|
song2 = self.__queue[pos2-1]
|
||||||
|
|
||||||
|
self.__queue[pos1-1] = song2
|
||||||
|
self.__queue[pos2-1] = song1
|
||||||
|
return (True, 'Songs moved with successfully')
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
return (False, 'There was a problem with the moving of songs')
|
||||||
Reference in New Issue
Block a user