diff --git a/config/config.py b/config/config.py index 9b918cf..b4bbe79 100644 --- a/config/config.py +++ b/config/config.py @@ -44,12 +44,13 @@ HELP_PAUSE = 'Pauses the song player' HELP_SHUFFLE = 'Shuffle the songs playing' HELP_PLAY = '(title/youtube/spotify) - Plays a song' HELP_MOVE = '(x, y) - Moves a song from position x to y in queue' -HELP_WARFRAME = f'({BOT_PREFIX}warframe help for more) - Return warframe information' +HELP_REMOVE = '(x, -1) - Remove a song in the position x or -1 for the last song' +HELP_WARFRAME = f'({BOT_PREFIX}warframe help for more)' HELP_RANDOM = '(x) - Return a random number between 1 and x' -HELP_ESCOLHA = '(x, y, z...) - Choose randomly one item passed in the command' +HELP_ESCOLHA = '(x, y, z...) - Choose randomly one item passed' HELP_CARA = 'Return cara or coroa' HELP_DROP = '(user_name) - Try to remove the user from the current voice channel' -HELP_FRASE = "Send a randomly phrase, there's a chance of getting the braba" +HELP_FRASE = "Send a randomly phrase, perhaps you get the braba" HELP_HELP = 'This command :)' ABSOLUTE_PATH = '' diff --git a/config/requirements.txt b/requirements.txt similarity index 58% rename from config/requirements.txt rename to requirements.txt index 595d4e8..ce6c122 100644 --- a/config/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ discord.py discord.py[voice] -youtube_dl -spotipy \ No newline at end of file +yt_dlp +spotipy +dotenv \ No newline at end of file diff --git a/vulkanbot/general/Control.py b/vulkanbot/general/Control.py index 60a3588..f3fd04d 100644 --- a/vulkanbot/general/Control.py +++ b/vulkanbot/general/Control.py @@ -11,7 +11,7 @@ class Control(commands.Cog): def __init__(self, bot: Client): self.__bot = bot self.__comandos = { - 'MUSIC': ['resume', 'pause', 'loop', 'stop', 'skip', 'play', 'queue', 'clear', 'np', 'shuffle', 'move'], + 'MUSIC': ['resume', 'pause', 'loop', 'stop', 'skip', 'play', 'queue', 'clear', 'np', 'shuffle', 'move', 'remove'], 'WARFRAME': ['warframe'], 'RANDOM': ['escolha', 'cara', 'random'], 'HELP': ['help'], diff --git a/vulkanbot/music/Music.py b/vulkanbot/music/Music.py index 1850a91..df3e38a 100644 --- a/vulkanbot/music/Music.py +++ b/vulkanbot/music/Music.py @@ -20,8 +20,7 @@ class Music(commands.Cog): self.__vc = "" self.YDL_OPTIONS = {'format': 'bestaudio', 'noplaylist': 'True'} - self.FFMPEG_OPTIONS = {'executable': config.FFMPEG_PATH, - 'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', + self.FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'} def __play_next(self, error, ctx): @@ -217,14 +216,25 @@ class Music(commands.Cog): await ctx.send('This command require a number') return - success, reason = self.__playlist.move_songs(pos1, pos2) + result = 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) + songs = self.__playlist.songs_to_preload + await self.__downloader.preload(songs) + await ctx.send(result) + + @commands.command(name='remove', help=config.HELP_MOVE) + async def remove(self, ctx, position): + """Remove a song from the queue in the position""" + try: + position = int(position) + + except Exception as e: + print(e) + await ctx.send('This command require a number') + return + + result = self.__playlist.remove_song(position) + await ctx.send(result) async def __send_embed(self, ctx, title='', description='', colour_name='grey'): try: diff --git a/vulkanbot/music/Playlist.py b/vulkanbot/music/Playlist.py index eab8027..93babe7 100644 --- a/vulkanbot/music/Playlist.py +++ b/vulkanbot/music/Playlist.py @@ -138,14 +138,19 @@ class Playlist(IPlaylist): self.__queue.remove(song) break - def move_songs(self, pos1, pos2) -> tuple: - """Receive two position and try to chance the songs in those positions + def move_songs(self, pos1, pos2) -> str: + """Receive two position and try to change the songs in those positions, -1 is the last Positions: First music is 1 Return (Error bool, string) with the status of the function, to show to user """ + if pos1 == -1: + pos1 = len(self.__queue) + if pos2 == -1: + pos2 = len(self.__queue) + if pos2 not in range(1, len(self.__queue) + 1) or pos1 not in range(1, len(self.__queue) + 1): - return (False, 'Numbers need to be more than 0 and less than the queue length') + return 'Numbers must be between 1 and queue length, or -1 for the last song' try: song1 = self.__queue[pos1-1] @@ -153,7 +158,22 @@ class Playlist(IPlaylist): self.__queue[pos1-1] = song2 self.__queue[pos2-1] = song1 - return (True, 'Songs moved with successfully') + + song1_name = song1.title if song1.title else song1.identifier + song2_name = song2.title if song2.title else song2.identifier + + return f'Song `{song1_name}` in position `{pos1}` moved with `{song2_name}` in position `{pos2}` successfully' except Exception as e: print(e) - return (False, 'There was a problem with the moving of songs') + return 'There was a problem with the moving of songs' + + def remove_song(self, position) -> tuple: + if position not in range(1, len(self.__queue) + 1) and position != -1: + return 'Numbers must be between 1 and queue length, or -1 for the last song' + else: + song = self.__queue[position-1] + self.__queue.remove(song) + + song_name = song.title if song.title else song.identifier + + return f'Song `{song_name}` removed successfully'