diff --git a/Config/Configs.py b/Config/Configs.py index 8949ab7..ef3eecc 100644 --- a/Config/Configs.py +++ b/Config/Configs.py @@ -5,13 +5,18 @@ from Config.Singleton import Singleton class Configs(Singleton): def __init__(self) -> None: if not super().created: - self.COMMANDS_PATH = 'Commands' - self.BOT_TOKEN = config('BOT_TOKEN') - self.SPOTIFY_ID = config('SPOTIFY_ID') - self.SPOTIFY_SECRET = config('SPOTIFY_SECRET') - self.CLEANER_MESSAGES_QUANT = 5 - self.BOT_PREFIX = '!' + try: + self.BOT_TOKEN = config('BOT_TOKEN') + self.SPOTIFY_ID = config('SPOTIFY_ID') + self.SPOTIFY_SECRET = config('SPOTIFY_SECRET') + self.BOT_PREFIX = config('BOT_PREFIX') + except: + print( + '[ERROR] -> You must create and .env file with all required fields, see documentation for help') + + self.CLEANER_MESSAGES_QUANT = 5 + self.COMMANDS_PATH = 'Commands' self.VC_TIMEOUT = 600 self.MAX_PLAYLIST_LENGTH = 50 diff --git a/Config/Helper.py b/Config/Helper.py index 3521c48..656bfa6 100644 --- a/Config/Helper.py +++ b/Config/Helper.py @@ -29,8 +29,8 @@ class Helper(Singleton): self.HELP_PREV_LONG = 'Play the previous song. If playing, the current song will return to queue.\n\nRequire: Loop to be disable.\nArguments: None.' self.HELP_SHUFFLE = 'Shuffle the songs playing.' self.HELP_SHUFFLE_LONG = 'Randomly shuffle the songs in the queue.\n\nArguments: None.' - self.HELP_PLAY = 'Plays a song.' - self.HELP_PLAY_LONG = 'Play a song in discord. \n\nRequire: You to be connected to a voice channel.\nArguments: Youtube or Spotify song/playlist link or the title of the song to be searched in Youtube.' + self.HELP_PLAY = 'Plays a song from URL' + self.HELP_PLAY_LONG = 'Play a song in discord. \n\nRequire: You to be connected to a voice channel.\nArguments: Youtube, Spotify or Deezer song/playlist link or the title of the song to be searched in Youtube.' self.HELP_HISTORY = f'Show the history of played songs.' self.HELP_HISTORY_LONG = f'Show the last {config.MAX_SONGS_HISTORY} played songs' self.HELP_MOVE = 'Moves a song from position x to y in queue.' diff --git a/Config/Messages.py b/Config/Messages.py index dc09f71..e89bc56 100644 --- a/Config/Messages.py +++ b/Config/Messages.py @@ -58,7 +58,7 @@ class Messages(Singleton): self.ERROR_TITLE = 'Error :-(' self.NO_CHANNEL = 'To play some music, connect to any voice channel first.' self.NO_GUILD = f'This server does not has a Player, try {configs.BOT_PREFIX}reset' - self.INVALID_INPUT = f'This type of input was too strange, try something better or type {configs.BOT_PREFIX}help play' + self.INVALID_INPUT = f'This URL was too strange, try something better or type {configs.BOT_PREFIX}help play' self.DOWNLOADING_ERROR = '❌ An error occurred while downloading' self.EXTRACTING_ERROR = '❌ An error ocurred while searching for the songs' diff --git a/Controllers/PlayController.py b/Controllers/PlayController.py index 66356ed..bb4c017 100644 --- a/Controllers/PlayController.py +++ b/Controllers/PlayController.py @@ -1,5 +1,5 @@ import asyncio -from Exceptions.Exceptions import DownloadingError, VulkanError +from Exceptions.Exceptions import DownloadingError, InvalidInput, VulkanError from discord.ext.commands import Context from discord import Client from Controllers.AbstractController import AbstractController @@ -20,6 +20,9 @@ class PlayController(AbstractController): track = " ".join(args) requester = self.ctx.author.name + if track == " ": + print('Aoba') + if not self.__user_connected(): error = ImpossibleMove() embed = self.embeds.NO_CHANNEL() @@ -34,6 +37,9 @@ class PlayController(AbstractController): try: musics = await self.__searcher.search(track) + if musics is None or len(musics) == 0: + raise InvalidInput(self.messages.INVALID_INPUT, self.messages.ERROR_TITLE) + for music in musics: song = Song(music, self.player.playlist, requester) self.player.playlist.add_song(song) @@ -64,7 +70,7 @@ class PlayController(AbstractController): return response except Exception as err: - if isinstance(err, VulkanError): # If error was already processed + if isinstance(err, VulkanError): # If error was already processed print(f'DEVELOPER NOTE -> PlayController Error: {err.message}') error = err embed = self.embeds.CUSTOM_ERROR(error) diff --git a/Music/Searcher.py b/Music/Searcher.py index 4610588..d92343e 100644 --- a/Music/Searcher.py +++ b/Music/Searcher.py @@ -70,6 +70,9 @@ class Searcher(): return trackAnalyzer.getCleanedUrl() def __identify_source(self, track: str) -> Provider: + if track == '': + return Provider.Unknown + if not Utils.is_url(track): return Provider.Name diff --git a/README.md b/README.md index fbf8aa5..e7bf7f3 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,11 @@ pip install -r requirements.txt ``` -- Installation of FFMPEG +- **Installation of FFMPEG**
+FFMPEG is a module that will be used to play music, you must have this configured in your machine +*FFMPEG must be configured in the PATH for Windows users. Check this [YoutubeVideo](https://www.youtube.com/watch?v=r1AtmY-RMyQ&t=114s&ab_channel=TroubleChute).*

+You can download the executables in this link `https://www.ffmpeg.org/download.html` and then put the .exe files inside a ffmpeg\bin folder in your C:\ folder. Do not forget to add 'ffmpeg\bin' to your PATH. - *FFMPEG must be configured in the PATH for Windows users. Check this [YoutubeVideo](https://www.youtube.com/watch?v=r1AtmY-RMyQ&t=114s&ab_channel=TroubleChute).* ### **.Env File Example** This is an example of how your .env file (located in root) should look like. @@ -72,6 +74,7 @@ This is an example of how your .env file (located in root) should look like. BOT_TOKEN=Your_Own_Bot_Token SPOTIFY_ID=Your_Own_Spotify_ID SPOTIFY_SECRET=Your_Own_Spotify_Secret +BOT_PREFIX=Your_Wanted_Prefix_For_Vulkan ``` diff --git a/requirements.txt b/requirements.txt index 9519446..65cdaf2 100644 Binary files a/requirements.txt and b/requirements.txt differ