diff --git a/vulkan/commands/Control.py b/Commands/Control.py similarity index 98% rename from vulkan/commands/Control.py rename to Commands/Control.py index 115fb61..25513e6 100644 --- a/vulkan/commands/Control.py +++ b/Commands/Control.py @@ -2,7 +2,7 @@ import discord from discord import Client from discord.ext.commands.errors import CommandNotFound, MissingRequiredArgument, UserInputError from discord.ext import commands -from Config.Config import Config +from Config.Config import Configs from Config.Helper import Helper helper = Helper() @@ -13,7 +13,7 @@ class Control(commands.Cog): def __init__(self, bot: Client): self.__bot = bot - self.__config = Config() + self.__config = Configs() self.__comandos = { 'MUSIC': ['resume', 'pause', 'loop', 'stop', 'skip', 'play', 'queue', 'clear', diff --git a/vulkan/commands/Music.py b/Commands/Music.py similarity index 96% rename from vulkan/commands/Music.py rename to Commands/Music.py index 02987d1..417fb96 100644 --- a/vulkan/commands/Music.py +++ b/Commands/Music.py @@ -2,13 +2,13 @@ from typing import Dict from discord import Guild, Client, Embed from discord.ext import commands from discord.ext.commands import Context -from Config.Config import Config +from Config.Config import Configs from Config.Helper import Helper -from Vulkan.Music.Player import Player -from Vulkan.Music.utils import is_connected -from Vulkan.Controllers.SkipController import SkipController -from Vulkan.Views.EmoteView import EmoteView -from Vulkan.Views.EmbedView import EmbedView +from Music.Player import Player +from Music.utils import is_connected +from Controllers.SkipController import SkipController +from Views.EmoteView import EmoteView +from Views.EmbedView import EmbedView helper = Helper() @@ -18,7 +18,7 @@ class Music(commands.Cog): def __init__(self, bot) -> None: self.__guilds: Dict[Guild, Player] = {} self.__bot: Client = bot - self.__config = Config() + self.__config = Configs() @commands.Cog.listener() async def on_ready(self) -> None: @@ -197,7 +197,7 @@ class Music(commands.Cog): player = self.__get_player(ctx) await player.force_stop() except Exception as e: - print(f'Reset Error: {e}') + print(f'DEVELOPER NOTE -> Reset Error: {e}') self.__guilds[ctx.guild] = Player(self.__bot, ctx.guild) player = self.__get_player(ctx) diff --git a/vulkan/commands/Random.py b/Commands/Random.py similarity index 97% rename from vulkan/commands/Random.py rename to Commands/Random.py index 2c1c763..7955be9 100644 --- a/vulkan/commands/Random.py +++ b/Commands/Random.py @@ -1,7 +1,7 @@ from random import randint, random import discord from discord.ext import commands -from Config.Config import Config +from Config.Config import Configs from Config.Helper import Helper helper = Helper() @@ -12,7 +12,7 @@ class Random(commands.Cog): def __init__(self, bot): self.__bot = bot - self.__config = Config() + self.__config = Configs() @commands.command(name='random', help=helper.HELP_RANDOM, description=helper.HELP_RANDOM_LONG) async def random(self, ctx, arg: str) -> None: diff --git a/vulkan/controllers/AbstractController.py b/Controllers/AbstractController.py similarity index 79% rename from vulkan/controllers/AbstractController.py rename to Controllers/AbstractController.py index ae9bd07..7c0ba20 100644 --- a/vulkan/controllers/AbstractController.py +++ b/Controllers/AbstractController.py @@ -1,12 +1,12 @@ from abc import ABC, abstractmethod from discord.ext.commands import Context from discord import Client, Guild -from Vulkan.Controllers.PlayerController import PlayersController -from Vulkan.Music.Player import Player -from Vulkan.Controllers.ControllerResponse import ControllerResponse -from Config.Config import Config +from Controllers.PlayerController import PlayersController +from Music.Player import Player +from Controllers.ControllerResponse import ControllerResponse +from Config.Config import Configs from Config.Helper import Helper -from Vulkan.Views.Embeds.Embeds import Embeds +from Views.Embeds import Embeds class AbstractController(ABC): @@ -16,7 +16,7 @@ class AbstractController(ABC): self.__player: Player = self.__controller.get_player(ctx.guild) self.__guild: Guild = ctx.guild self.__ctx: Context = ctx - self.__config = Config() + self.__config = Configs() self.__helper = Helper() self.__embeds = Embeds() @@ -41,7 +41,7 @@ class AbstractController(ABC): return self.__bot @property - def config(self) -> Config: + def config(self) -> Configs: return self.__config @property diff --git a/vulkan/controllers/ControllerResponse.py b/Controllers/ControllerResponse.py similarity index 93% rename from vulkan/controllers/ControllerResponse.py rename to Controllers/ControllerResponse.py index d27839d..9aa6da1 100644 --- a/vulkan/controllers/ControllerResponse.py +++ b/Controllers/ControllerResponse.py @@ -1,6 +1,6 @@ from typing import Union from discord.ext.commands import Context -from Vulkan.Exceptions.Exceptions import Error +from Exceptions.Exceptions import Error from discord import Embed diff --git a/vulkan/controllers/PlayerController.py b/Controllers/PlayerController.py similarity index 97% rename from vulkan/controllers/PlayerController.py rename to Controllers/PlayerController.py index 62878f8..6addff1 100644 --- a/vulkan/controllers/PlayerController.py +++ b/Controllers/PlayerController.py @@ -1,7 +1,7 @@ from typing import Dict, List, Union from Config.Singleton import Singleton from discord import Guild, Client, VoiceClient -from Vulkan.Music.Player import Player +from Music.Player import Player class PlayersController(Singleton): diff --git a/vulkan/controllers/SkipController.py b/Controllers/SkipController.py similarity index 79% rename from vulkan/controllers/SkipController.py rename to Controllers/SkipController.py index dc36651..378079e 100644 --- a/vulkan/controllers/SkipController.py +++ b/Controllers/SkipController.py @@ -1,8 +1,8 @@ from discord.ext.commands import Context from discord import Client -from Vulkan.Controllers.AbstractController import AbstractController -from Vulkan.Exceptions.Exceptions import BadCommandUsage -from Vulkan.Controllers.ControllerResponse import ControllerResponse +from Controllers.AbstractController import AbstractController +from Exceptions.Exceptions import BadCommandUsage +from Controllers.ControllerResponse import ControllerResponse class SkipController(AbstractController): diff --git a/vulkan/database/Database.py b/Database/Database.py similarity index 100% rename from vulkan/database/Database.py rename to Database/Database.py diff --git a/vulkan/Exceptions/Exceptions.py b/Exceptions/Exceptions.py similarity index 94% rename from vulkan/Exceptions/Exceptions.py rename to Exceptions/Exceptions.py index 1705b4d..efcb084 100644 --- a/vulkan/Exceptions/Exceptions.py +++ b/Exceptions/Exceptions.py @@ -1,4 +1,4 @@ -from config.Config import Config +from Config.Config import Configs class Error(Exception): @@ -18,7 +18,7 @@ class Error(Exception): class ImpossibleMove(Error): def __init__(self, message='', title='', *args: object) -> None: - config = Config() + config = Configs() if title == '': title = config.IMPOSSIBLE_MOVE super().__init__(message, title, *args) diff --git a/vulkan/music/Downloader.py b/Music/Downloader.py similarity index 97% rename from vulkan/music/Downloader.py rename to Music/Downloader.py index fa504b8..b4cb45e 100644 --- a/vulkan/music/Downloader.py +++ b/Music/Downloader.py @@ -1,15 +1,15 @@ import asyncio from typing import List -from Config.Config import Config +from Config.Config import Configs from yt_dlp import YoutubeDL from concurrent.futures import ThreadPoolExecutor -from Vulkan.Music.Song import Song -from Vulkan.Music.utils import is_url, run_async +from Music.Song import Song +from Music.utils import is_url, run_async class Downloader(): """Download musics direct URL and title or Source from Youtube using a music name or Youtube URL""" - config = Config() + config = Configs() __YDL_OPTIONS = {'format': 'bestaudio/best', 'default_search': 'auto', 'playliststart': 0, @@ -31,7 +31,7 @@ class Downloader(): __BASE_URL = 'https://www.youtube.com/watch?v={}' def __init__(self) -> None: - self.__config = Config() + self.__config = Configs() self.__music_keys_only = ['resolution', 'fps', 'quality'] self.__not_extracted_keys_only = ['ie_key'] self.__not_extracted_not_keys = ['entries'] diff --git a/vulkan/music/Interfaces.py b/Music/Interfaces.py similarity index 100% rename from vulkan/music/Interfaces.py rename to Music/Interfaces.py diff --git a/vulkan/music/Player.py b/Music/Player.py similarity index 97% rename from vulkan/music/Player.py rename to Music/Player.py index 3fb61a5..75b6712 100644 --- a/vulkan/music/Player.py +++ b/Music/Player.py @@ -1,14 +1,14 @@ from discord.ext import commands -from Config.Config import Config +from Config.Config import Configs from discord import Client, Guild, FFmpegPCMAudio, Embed from discord.ext.commands import Context from datetime import timedelta -from Vulkan.Music.Downloader import Downloader -from Vulkan.Music.Playlist import Playlist -from Vulkan.Music.Searcher import Searcher -from Vulkan.Music.Song import Song -from Vulkan.Music.Types import Provider -from Vulkan.Music.utils import * +from Music.Downloader import Downloader +from Music.Playlist import Playlist +from Music.Searcher import Searcher +from Music.Song import Song +from Music.Types import Provider +from Music.utils import * class Player(commands.Cog): @@ -21,7 +21,7 @@ class Player(commands.Cog): self.__timer = Timer(self.__timeout_handler) self.__playing = False - self.__config = Config() + self.__config = Configs() # Flag to control if the player should stop totally the playing self.__force_stop = False @@ -249,7 +249,7 @@ class Player(commands.Cog): self.__playlist.clear() self.__playlist.loop_off() except Exception as e: - print(f'Force Stop Error: {e}') + print(f'DEVELOPER NOTE -> Force Stop Error: {e}') async def pause(self) -> bool: if self.__guild.voice_client == None: diff --git a/vulkan/music/Playlist.py b/Music/Playlist.py similarity index 97% rename from vulkan/music/Playlist.py rename to Music/Playlist.py index 143b1db..2d7c3bc 100644 --- a/vulkan/music/Playlist.py +++ b/Music/Playlist.py @@ -1,8 +1,8 @@ from collections import deque from typing import List -from Config.Config import Config -from Vulkan.Music.Interfaces import IPlaylist -from Vulkan.Music.Song import Song +from Config.Config import Configs +from Music.Interfaces import IPlaylist +from Music.Song import Song import random @@ -10,7 +10,7 @@ class Playlist(IPlaylist): """Class to manage and control the songs to play and played""" def __init__(self) -> None: - self.__config = Config() + self.__config = Configs() self.__queue = deque() # Store the musics to play self.__songs_history = deque() # Store the musics played diff --git a/vulkan/music/Searcher.py b/Music/Searcher.py similarity index 87% rename from vulkan/music/Searcher.py rename to Music/Searcher.py index 8240ebc..fe6581d 100644 --- a/vulkan/music/Searcher.py +++ b/Music/Searcher.py @@ -1,6 +1,6 @@ -from Vulkan.Music.Types import Provider -from Vulkan.Music.Spotify import SpotifySearch -from Vulkan.Music.utils import is_url +from Music.Types import Provider +from Music.Spotify import SpotifySearch +from Music.utils import is_url class Searcher(): @@ -16,7 +16,6 @@ class Searcher(): Return -> A list of musics names and Provider Type """ provider = self.__identify_source(music) - print(provider) if provider == Provider.YouTube: return [music], Provider.YouTube @@ -26,7 +25,7 @@ class Searcher(): musics = self.__Spotify.search(music) return musics, Provider.Name else: - print('Spotify Not Connected') + print('DEVELOPER NOTE -> Spotify Not Connected') return [], Provider.Unknown elif provider == Provider.Name: diff --git a/vulkan/music/Song.py b/Music/Song.py similarity index 97% rename from vulkan/music/Song.py rename to Music/Song.py index 95df967..9cdabcb 100644 --- a/vulkan/music/Song.py +++ b/Music/Song.py @@ -1,4 +1,4 @@ -from Vulkan.Music.Interfaces import ISong, IPlaylist +from Music.Interfaces import ISong, IPlaylist class Song(ISong): diff --git a/vulkan/music/Spotify.py b/Music/Spotify.py similarity index 98% rename from vulkan/music/Spotify.py rename to Music/Spotify.py index 09f1438..abeef8f 100644 --- a/vulkan/music/Spotify.py +++ b/Music/Spotify.py @@ -1,13 +1,13 @@ import spotipy from spotipy.oauth2 import SpotifyClientCredentials -from Config.Config import Config +from Config.Config import Configs class SpotifySearch(): """Search a Spotify music or playlist and return the musics names""" def __init__(self) -> None: - self.__config = Config() + self.__config = Configs() self.__connected = False self.__connect() diff --git a/vulkan/music/Types.py b/Music/Types.py similarity index 100% rename from vulkan/music/Types.py rename to Music/Types.py diff --git a/vulkan/music/utils.py b/Music/utils.py similarity index 96% rename from vulkan/music/utils.py rename to Music/utils.py index 80291c3..d1cb497 100644 --- a/vulkan/music/utils.py +++ b/Music/utils.py @@ -1,8 +1,8 @@ import re import asyncio -from Config.Config import Config +from Config.Config import Configs from functools import wraps, partial -config = Config() +config = Configs() def is_connected(ctx): diff --git a/vulkan/views/AbstractView.py b/Views/AbstractView.py similarity index 91% rename from vulkan/views/AbstractView.py rename to Views/AbstractView.py index eae50ee..8a3fd82 100644 --- a/vulkan/views/AbstractView.py +++ b/Views/AbstractView.py @@ -1,5 +1,5 @@ from abc import ABC, abstractmethod -from Vulkan.Controllers.ControllerResponse import ControllerResponse +from Controllers.ControllerResponse import ControllerResponse from discord.ext.commands import Context from discord import Client, Message diff --git a/vulkan/views/EmbedView.py b/Views/EmbedView.py similarity index 68% rename from vulkan/views/EmbedView.py rename to Views/EmbedView.py index ccabdb1..6be0b33 100644 --- a/vulkan/views/EmbedView.py +++ b/Views/EmbedView.py @@ -1,5 +1,5 @@ -from Vulkan.Views.AbstractView import AbstractView -from Vulkan.Controllers.ControllerResponse import ControllerResponse +from Views.AbstractView import AbstractView +from Controllers.ControllerResponse import ControllerResponse class EmbedView(AbstractView): diff --git a/vulkan/views/Embeds/Embeds.py b/Views/Embeds.py similarity index 98% rename from vulkan/views/Embeds/Embeds.py rename to Views/Embeds.py index cad5e6d..333f09e 100644 --- a/vulkan/views/Embeds/Embeds.py +++ b/Views/Embeds.py @@ -1,12 +1,12 @@ from discord import Embed -from Config.Config import Config +from Config.Config import Configs from Config.Colors import Colors from datetime import timedelta class Embeds: def __init__(self) -> None: - self.__config = Config() + self.__config = Configs() self.__colors = Colors() @property diff --git a/vulkan/views/EmoteView.py b/Views/EmoteView.py similarity index 72% rename from vulkan/views/EmoteView.py rename to Views/EmoteView.py index 283519d..12ba8f7 100644 --- a/vulkan/views/EmoteView.py +++ b/Views/EmoteView.py @@ -1,5 +1,5 @@ -from Vulkan.Views.AbstractView import AbstractView -from Vulkan.Controllers.ControllerResponse import ControllerResponse +from Views.AbstractView import AbstractView +from Controllers.ControllerResponse import ControllerResponse class EmoteView(AbstractView): diff --git a/config/Helper.py b/config/Helper.py index 44a309c..c704f50 100644 --- a/config/Helper.py +++ b/config/Helper.py @@ -1,11 +1,11 @@ from Config.Singleton import Singleton -from Config.Config import Config +from Config.Config import Configs class Helper(Singleton): def __init__(self) -> None: if not super().created: - config = Config() + config = Configs() self.HELP_SKIP = 'Skip the current playing song.' self.HELP_SKIP_LONG = 'Skip the playing of the current song, does not work if loop one is activated. \n\nArguments: None.' self.HELP_RESUME = 'Resumes the song player.' diff --git a/config/Messages.py b/config/Messages.py new file mode 100644 index 0000000..061f830 --- /dev/null +++ b/config/Messages.py @@ -0,0 +1,71 @@ +from Config.Singleton import Singleton +from Config.Config import Configs + + +class Messages(Singleton): + def __init__(self) -> None: + if not super().created: + configs = Configs() + self.STARTUP_MESSAGE = 'Starting Vulkan...' + self.STARTUP_COMPLETE_MESSAGE = 'Vulkan is now operating.' + + self.INVITE_MESSAGE = 'To invite Vulkan to your own server, click [here]({})' + + self.SONGINFO_UPLOADER = "Uploader: " + self.SONGINFO_DURATION = "Duration: " + self.SONGINFO_REQUESTER = 'Requester: ' + self.SONGINFO_POSITION = 'Position: ' + + self.SONGS_ADDED = 'You added {} songs to the queue' + self.SONG_ADDED = 'You added the song `{}` to the queue' + self.SONG_ADDED_TWO = '🎧 Song added to the queue' + self.SONG_PLAYING = '🎧 Song playing now' + self.SONG_PLAYER = '🎧 Song Player' + self.QUEUE_TITLE = '🎧 Songs in Queue' + self.ONE_SONG_LOOPING = '🎧 Looping One Song' + self.ALL_SONGS_LOOPING = '🎧 Looping All Songs' + self.SONG_PAUSED = '⏸️ Song paused' + self.SONG_RESUMED = '▢️ Song playing' + self.EMPTY_QUEUE = f'πŸ“œ Song queue is empty, use {configs.BOT_PREFIX}play to add new songs' + self.SONG_DOWNLOADING = 'πŸ“₯ Downloading...' + + self.HISTORY_TITLE = '🎧 Played Songs' + self.HISTORY_EMPTY = 'πŸ“œ There is no musics in history' + + self.SONG_MOVED_SUCCESSFULLY = 'Song `{}` in position `{}` moved to the position `{}` successfully' + self.SONG_REMOVED_SUCCESSFULLY = 'Song `{}` removed successfully' + + self.LOOP_ALL_ON = f'❌ Vulkan is looping all songs, use {configs.BOT_PREFIX}loop off to disable this loop first' + self.LOOP_ONE_ON = f'❌ Vulkan is looping one song, use {configs.BOT_PREFIX}loop off to disable this loop first' + self.LOOP_ALL_ALREADY_ON = 'πŸ” Vulkan is already looping all songs' + self.LOOP_ONE_ALREADY_ON = 'πŸ”‚ Vulkan is already looping the current song' + self.LOOP_ALL_ACTIVATE = 'πŸ” Looping all songs' + self.LOOP_ONE_ACTIVATE = 'πŸ”‚ Looping the current song' + self.LOOP_DISABLE = '➑️ Loop disabled' + self.LOOP_ALREADY_DISABLE = '❌ Loop is already disabled' + self.LOOP_ON = f'❌ This command cannot be invoked with any loop activated. Use {configs.BOT_PREFIX}loop off to disable loop' + + self.SONGS_SHUFFLED = 'πŸ”€ Songs shuffled successfully' + self.ERROR_SHUFFLING = '❌ Error while shuffling the songs' + self.ERROR_MOVING = '❌ Error while moving the songs' + self.LENGTH_ERROR = '❌ Numbers must be between 1 and queue length, use -1 for the last song' + self.ERROR_NUMBER = '❌ This command require a number' + self.ERROR_PLAYING = '❌ Error while playing songs' + self.COMMAND_NOT_FOUND = f'❌ Command not found, type {configs.BOT_PREFIX}help to see all commands' + self.UNKNOWN_ERROR = f'❌ Unknown Error, if needed, use {configs.BOT_PREFIX}reset to reset the player of your server' + self.ERROR_MISSING_ARGUMENTS = f'❌ Missing arguments in this command. Type {configs.BOT_PREFIX}help "command" to see more info about this command' + self.NOT_PREVIOUS = '❌ There is none previous song to play' + self.PLAYER_NOT_PLAYING = f'❌ No song playing. Use {configs.BOT_PREFIX}play to start the player' + self.IMPOSSIBLE_MOVE = 'That is impossible :(' + 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.DOWNLOADING_ERROR = '❌ An error occurred while downloading' + self.EXTRACTING_ERROR = '❌ An error ocurred while searching for the songs' + + self.MY_ERROR_BAD_COMMAND = 'This string serves to verify if some error was raised by myself on purpose' + self.BAD_COMMAND_TITLE = 'Misuse of command' + self.BAD_COMMAND = f'❌ Bad usage of this command, type {configs.BOT_PREFIX}help "command" to understand the command better' + self.INVITE_URL = 'https://discordapp.com/oauth2/authorize?client_id={}&scope=bot>' + self.VIDEO_UNAVAILABLE = '❌ Sorry. This video is unavailable for download.' diff --git a/config/config.py b/config/config.py index da4161e..817d315 100644 --- a/config/config.py +++ b/config/config.py @@ -2,7 +2,7 @@ from decouple import config from Config.Singleton import Singleton -class Config(Singleton): +class Configs(Singleton): def __init__(self) -> None: if not super().created: self.BOT_TOKEN = config('BOT_TOKEN') @@ -80,10 +80,10 @@ class Config(Singleton): self.INVITE_URL = 'https://discordapp.com/oauth2/authorize?client_id={}&scope=bot>' self.VIDEO_UNAVAILABLE = '❌ Sorry. This video is unavailable for download.' - self.COLOURS = { - 'red': 0xDC143C, - 'green': 0x1F8B4C, - 'grey': 0x708090, - 'blue': 0x206694, - 'black': 0x23272A - } + self.COLOURS = { + 'red': 0xDC143C, + 'green': 0x1F8B4C, + 'grey': 0x708090, + 'blue': 0x206694, + 'black': 0x23272A + } diff --git a/main.py b/main.py index 495a193..693ad04 100644 --- a/main.py +++ b/main.py @@ -1,12 +1,12 @@ import discord import os -from config.Config import Config +from Config.Config import Configs from discord.ext import commands intents = discord.Intents.default() intents.members = True -config = Config() +config = Configs() bot = commands.Bot(command_prefix=config.BOT_PREFIX, pm_help=True, case_insensitive=True, intents=intents) @@ -15,9 +15,9 @@ bot.remove_command('help') if config.BOT_TOKEN == "": exit() -for filename in os.listdir('./vulkan/commands'): +for filename in os.listdir('./Commands'): if filename.endswith('.py'): - bot.load_extension(f'vulkan.commands.{filename[:-3]}') + bot.load_extension(f'Commands.{filename[:-3]}') bot.run(config.BOT_TOKEN, bot=True, reconnect=True) diff --git a/vulkan/views/MessageView.py b/vulkan/views/MessageView.py deleted file mode 100644 index 2482bb9..0000000 --- a/vulkan/views/MessageView.py +++ /dev/null @@ -1,10 +0,0 @@ -from Vulkan.Views.AbstractView import AbstractView -from Vulkan.Controllers.ControllerResponse import ControllerResponse - - -class MessageView(AbstractView): - def __init__(self, response: ControllerResponse) -> None: - super().__init__(response) - - async def run(self) -> None: - return super().run()