From beb0bc085df938f320e0e2eb6ba9b86a68174f29 Mon Sep 17 00:00:00 2001 From: Rafael Vargas Date: Wed, 27 Jul 2022 11:27:38 -0300 Subject: [PATCH] Fixing errors due to new discor d library --- DiscordCogs/ControlCog.py | 12 +++----- DiscordCogs/MusicCog.py | 37 +++++++++++------------- DiscordCogs/RandomCog.py | 5 +--- Handlers/AbstractHandler.py | 2 +- Handlers/ClearHandler.py | 2 +- Handlers/HistoryHandler.py | 2 +- Handlers/LoopHandler.py | 2 +- Handlers/MoveHandler.py | 2 +- Handlers/NowPlayingHandler.py | 2 +- Handlers/PauseHandler.py | 2 +- Handlers/PlayHandler.py | 2 +- Handlers/PrevHandler.py | 2 +- Handlers/QueueHandler.py | 2 +- Handlers/RemoveHandler.py | 2 +- Handlers/ResetHandler.py | 2 +- Handlers/ResumeHandler.py | 2 +- Handlers/ShuffleHandler.py | 2 +- Handlers/SkipHandler.py | 2 +- Handlers/StopHandler.py | 2 +- Music/{MusicBot.py => VulkanBot.py} | 6 ++-- Music/VulkanInitializer.py | 22 +++++++++++---- Parallelism/PlayerProcess.py | 2 +- Utils/Cleaner.py | 2 +- Views/AbstractView.py | 2 +- main.py | 44 +---------------------------- 25 files changed, 61 insertions(+), 103 deletions(-) rename Music/{MusicBot.py => VulkanBot.py} (96%) diff --git a/DiscordCogs/ControlCog.py b/DiscordCogs/ControlCog.py index ff6ef56..5b3ae94 100644 --- a/DiscordCogs/ControlCog.py +++ b/DiscordCogs/ControlCog.py @@ -1,10 +1,9 @@ from discord import Embed -from discord.ext import commands -from discord.ext.commands import Cog +from discord.ext.commands import Cog, command from Config.Configs import Configs from Config.Helper import Helper from Config.Colors import Colors -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot from Views.Embeds import Embeds helper = Helper() @@ -14,10 +13,7 @@ class ControlCog(Cog): """Class to handle discord events""" def __init__(self, bot: VulkanBot): - print('Eae3') self.__bot = bot - print(self.__bot) - print(bot.extensions) self.__config = Configs() self.__colors = Colors() self.__embeds = Embeds() @@ -30,7 +26,7 @@ class ControlCog(Cog): } - @commands.command(name="help", help=helper.HELP_HELP, description=helper.HELP_HELP_LONG, aliases=['h', 'ajuda']) + @command(name="help", help=helper.HELP_HELP, description=helper.HELP_HELP_LONG, aliases=['h', 'ajuda']) async def help_msg(self, ctx, command_help=''): if command_help != '': for command in self.__bot.commands: @@ -81,7 +77,7 @@ class ControlCog(Cog): embedhelp.set_thumbnail(url=self.__bot.user.avatar) await ctx.send(embed=embedhelp) - @commands.command(name='invite', help=helper.HELP_INVITE, description=helper.HELP_INVITE_LONG, aliases=['convite', 'inv', 'convidar']) + @command(name='invite', help=helper.HELP_INVITE, description=helper.HELP_INVITE_LONG, aliases=['convite', 'inv', 'convidar']) async def invite_bot(self, ctx): invite_url = self.__config.INVITE_URL.format(self.__bot.user.id) txt = self.__config.INVITE_MESSAGE.format(invite_url, invite_url) diff --git a/DiscordCogs/MusicCog.py b/DiscordCogs/MusicCog.py index 8c50f33..b54fce8 100644 --- a/DiscordCogs/MusicCog.py +++ b/DiscordCogs/MusicCog.py @@ -1,6 +1,5 @@ from discord import Guild, Client -from discord.ext import commands -from discord.ext.commands import Context +from discord.ext.commands import Context, command, Cog from Config.Helper import Helper from Handlers.ClearHandler import ClearHandler from Handlers.MoveHandler import MoveHandler @@ -23,7 +22,7 @@ from Views.EmbedView import EmbedView helper = Helper() -class MusicCog(commands.Cog): +class MusicCog(Cog): """ Class to listen to Music commands It'll listen for commands from discord, when triggered will create a specific Handler for the command @@ -33,7 +32,7 @@ class MusicCog(commands.Cog): def __init__(self, bot) -> None: self.__bot: Client = bot - @commands.command(name="play", help=helper.HELP_PLAY, description=helper.HELP_PLAY_LONG, aliases=['p', 'tocar']) + @command(name="play", help=helper.HELP_PLAY, description=helper.HELP_PLAY_LONG, aliases=['p', 'tocar']) async def play(self, ctx: Context, *args) -> None: try: controller = PlayHandler(ctx, self.__bot) @@ -47,7 +46,7 @@ class MusicCog(commands.Cog): except Exception as e: print(f'[ERROR IN COG] -> {e}') - @commands.command(name="queue", help=helper.HELP_QUEUE, description=helper.HELP_QUEUE_LONG, aliases=['q', 'fila', 'musicas']) + @command(name="queue", help=helper.HELP_QUEUE, description=helper.HELP_QUEUE_LONG, aliases=['q', 'fila', 'musicas']) async def queue(self, ctx: Context) -> None: try: controller = QueueHandler(ctx, self.__bot) @@ -58,7 +57,7 @@ class MusicCog(commands.Cog): except Exception as e: print(f'[ERROR IN COG] -> {e}') - @commands.command(name="skip", help=helper.HELP_SKIP, description=helper.HELP_SKIP_LONG, aliases=['s', 'pular', 'next']) + @command(name="skip", help=helper.HELP_SKIP, description=helper.HELP_SKIP_LONG, aliases=['s', 'pular', 'next']) async def skip(self, ctx: Context) -> None: try: controller = SkipHandler(ctx, self.__bot) @@ -73,7 +72,7 @@ class MusicCog(commands.Cog): except Exception as e: print(f'[ERROR IN COG] -> {e}') - @commands.command(name='stop', help=helper.HELP_STOP, description=helper.HELP_STOP_LONG, aliases=['parar']) + @command(name='stop', help=helper.HELP_STOP, description=helper.HELP_STOP_LONG, aliases=['parar']) async def stop(self, ctx: Context) -> None: try: controller = StopHandler(ctx, self.__bot) @@ -88,7 +87,7 @@ class MusicCog(commands.Cog): except Exception as e: print(f'[ERROR IN COG] -> {e}') - @commands.command(name='pause', help=helper.HELP_PAUSE, description=helper.HELP_PAUSE_LONG, aliases=['pausar', 'pare']) + @command(name='pause', help=helper.HELP_PAUSE, description=helper.HELP_PAUSE_LONG, aliases=['pausar', 'pare']) async def pause(self, ctx: Context) -> None: try: controller = PauseHandler(ctx, self.__bot) @@ -101,7 +100,7 @@ class MusicCog(commands.Cog): except Exception as e: print(f'[ERROR IN COG] -> {e}') - @commands.command(name='resume', help=helper.HELP_RESUME, description=helper.HELP_RESUME_LONG, aliases=['soltar', 'despausar']) + @command(name='resume', help=helper.HELP_RESUME, description=helper.HELP_RESUME_LONG, aliases=['soltar', 'despausar']) async def resume(self, ctx: Context) -> None: try: controller = ResumeHandler(ctx, self.__bot) @@ -114,7 +113,7 @@ class MusicCog(commands.Cog): except Exception as e: print(f'[ERROR IN COG] -> {e}') - @commands.command(name='prev', help=helper.HELP_PREV, description=helper.HELP_PREV_LONG, aliases=['anterior', 'return', 'previous', 'back']) + @command(name='prev', help=helper.HELP_PREV, description=helper.HELP_PREV_LONG, aliases=['anterior', 'return', 'previous', 'back']) async def prev(self, ctx: Context) -> None: try: controller = PrevHandler(ctx, self.__bot) @@ -128,7 +127,7 @@ class MusicCog(commands.Cog): except Exception as e: print(f'[ERROR IN COG] -> {e}') - @commands.command(name='history', help=helper.HELP_HISTORY, description=helper.HELP_HISTORY_LONG, aliases=['historico', 'anteriores', 'hist']) + @command(name='history', help=helper.HELP_HISTORY, description=helper.HELP_HISTORY_LONG, aliases=['historico', 'anteriores', 'hist']) async def history(self, ctx: Context) -> None: try: controller = HistoryHandler(ctx, self.__bot) @@ -141,7 +140,7 @@ class MusicCog(commands.Cog): except Exception as e: print(f'[ERROR IN COG] -> {e}') - @commands.command(name='loop', help=helper.HELP_LOOP, description=helper.HELP_LOOP_LONG, aliases=['l', 'repeat']) + @command(name='loop', help=helper.HELP_LOOP, description=helper.HELP_LOOP_LONG, aliases=['l', 'repeat']) async def loop(self, ctx: Context, args='') -> None: try: controller = LoopHandler(ctx, self.__bot) @@ -154,7 +153,7 @@ class MusicCog(commands.Cog): except Exception as e: print(f'[ERROR IN COG] -> {e}') - @commands.command(name='clear', help=helper.HELP_CLEAR, description=helper.HELP_CLEAR_LONG, aliases=['c', 'limpar']) + @command(name='clear', help=helper.HELP_CLEAR, description=helper.HELP_CLEAR_LONG, aliases=['c', 'limpar']) async def clear(self, ctx: Context) -> None: try: controller = ClearHandler(ctx, self.__bot) @@ -165,7 +164,7 @@ class MusicCog(commands.Cog): except Exception as e: print(f'[ERROR IN COG] -> {e}') - @commands.command(name='np', help=helper.HELP_NP, description=helper.HELP_NP_LONG, aliases=['playing', 'now', 'this']) + @command(name='np', help=helper.HELP_NP, description=helper.HELP_NP_LONG, aliases=['playing', 'now', 'this']) async def now_playing(self, ctx: Context) -> None: try: controller = NowPlayingHandler(ctx, self.__bot) @@ -178,7 +177,7 @@ class MusicCog(commands.Cog): except Exception as e: print(f'[ERROR IN COG] -> {e}') - @commands.command(name='shuffle', help=helper.HELP_SHUFFLE, description=helper.HELP_SHUFFLE_LONG, aliases=['aleatorio', 'misturar']) + @command(name='shuffle', help=helper.HELP_SHUFFLE, description=helper.HELP_SHUFFLE_LONG, aliases=['aleatorio', 'misturar']) async def shuffle(self, ctx: Context) -> None: try: controller = ShuffleHandler(ctx, self.__bot) @@ -191,7 +190,7 @@ class MusicCog(commands.Cog): except Exception as e: print(f'[ERROR IN COG] -> {e}') - @commands.command(name='move', help=helper.HELP_MOVE, description=helper.HELP_MOVE_LONG, aliases=['m', 'mover']) + @command(name='move', help=helper.HELP_MOVE, description=helper.HELP_MOVE_LONG, aliases=['m', 'mover']) async def move(self, ctx: Context, pos1, pos2='1') -> None: try: controller = MoveHandler(ctx, self.__bot) @@ -204,7 +203,7 @@ class MusicCog(commands.Cog): except Exception as e: print(f'[ERROR IN COG] -> {e}') - @commands.command(name='remove', help=helper.HELP_REMOVE, description=helper.HELP_REMOVE_LONG, aliases=['remover']) + @command(name='remove', help=helper.HELP_REMOVE, description=helper.HELP_REMOVE_LONG, aliases=['remover']) async def remove(self, ctx: Context, position) -> None: try: controller = RemoveHandler(ctx, self.__bot) @@ -217,7 +216,7 @@ class MusicCog(commands.Cog): except Exception as e: print(f'[ERROR IN COG] -> {e}') - @commands.command(name='reset', help=helper.HELP_RESET, description=helper.HELP_RESET_LONG, aliases=['resetar']) + @command(name='reset', help=helper.HELP_RESET, description=helper.HELP_RESET_LONG, aliases=['resetar']) async def reset(self, ctx: Context) -> None: try: controller = ResetHandler(ctx, self.__bot) @@ -232,6 +231,4 @@ class MusicCog(commands.Cog): def setup(bot): - print('Loading Music') bot.add_cog(MusicCog(bot)) - print('Voltou') diff --git a/DiscordCogs/RandomCog.py b/DiscordCogs/RandomCog.py index 02c00f3..6ec53c7 100644 --- a/DiscordCogs/RandomCog.py +++ b/DiscordCogs/RandomCog.py @@ -1,5 +1,5 @@ from random import randint, random -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot from discord.ext.commands import Context, command, Cog from Config.Helper import Helper from Views.Embeds import Embeds @@ -11,9 +11,6 @@ class RandomCog(Cog): """Class to listen to commands of type Random""" def __init__(self, bot: VulkanBot): - print('Eae2') - print(bot) - print(bot.extensions) self.__embeds = Embeds() @command(name='random', help=helper.HELP_RANDOM, description=helper.HELP_RANDOM_LONG, aliases=['rand']) diff --git a/Handlers/AbstractHandler.py b/Handlers/AbstractHandler.py index 19f81a6..de9d592 100644 --- a/Handlers/AbstractHandler.py +++ b/Handlers/AbstractHandler.py @@ -3,7 +3,7 @@ from typing import List from discord.ext.commands import Context from discord import Client, Guild, ClientUser, Member from Config.Messages import Messages -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot from Handlers.HandlerResponse import HandlerResponse from Config.Configs import Configs from Config.Helper import Helper diff --git a/Handlers/ClearHandler.py b/Handlers/ClearHandler.py index eb53a8a..85dd75b 100644 --- a/Handlers/ClearHandler.py +++ b/Handlers/ClearHandler.py @@ -1,5 +1,5 @@ from discord.ext.commands import Context -from discord import VulkanBot +from Music.VulkanBot import VulkanBot from Handlers.AbstractHandler import AbstractHandler from Handlers.HandlerResponse import HandlerResponse from Parallelism.ProcessManager import ProcessManager diff --git a/Handlers/HistoryHandler.py b/Handlers/HistoryHandler.py index 7869b6f..e4d0d07 100644 --- a/Handlers/HistoryHandler.py +++ b/Handlers/HistoryHandler.py @@ -1,5 +1,5 @@ from discord.ext.commands import Context -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot from Handlers.AbstractHandler import AbstractHandler from Handlers.HandlerResponse import HandlerResponse from Utils.Utils import Utils diff --git a/Handlers/LoopHandler.py b/Handlers/LoopHandler.py index c9e429f..a62e5cb 100644 --- a/Handlers/LoopHandler.py +++ b/Handlers/LoopHandler.py @@ -1,5 +1,5 @@ from discord.ext.commands import Context -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot from Handlers.AbstractHandler import AbstractHandler from Handlers.HandlerResponse import HandlerResponse from Config.Exceptions import BadCommandUsage diff --git a/Handlers/MoveHandler.py b/Handlers/MoveHandler.py index be0849c..8088f66 100644 --- a/Handlers/MoveHandler.py +++ b/Handlers/MoveHandler.py @@ -1,6 +1,6 @@ from typing import Union from discord.ext.commands import Context -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot from Handlers.AbstractHandler import AbstractHandler from Handlers.HandlerResponse import HandlerResponse from Config.Exceptions import BadCommandUsage, VulkanError, InvalidInput, NumberRequired, UnknownError diff --git a/Handlers/NowPlayingHandler.py b/Handlers/NowPlayingHandler.py index 500ba4d..cbaf2ad 100644 --- a/Handlers/NowPlayingHandler.py +++ b/Handlers/NowPlayingHandler.py @@ -1,7 +1,7 @@ from discord.ext.commands import Context from Handlers.AbstractHandler import AbstractHandler from Handlers.HandlerResponse import HandlerResponse -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot from Utils.Cleaner import Cleaner from Parallelism.ProcessManager import ProcessManager diff --git a/Handlers/PauseHandler.py b/Handlers/PauseHandler.py index 61a0c9d..95d698c 100644 --- a/Handlers/PauseHandler.py +++ b/Handlers/PauseHandler.py @@ -3,7 +3,7 @@ from Handlers.AbstractHandler import AbstractHandler from Handlers.HandlerResponse import HandlerResponse from Parallelism.ProcessManager import ProcessManager from Parallelism.Commands import VCommands, VCommandsType -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot class PauseHandler(AbstractHandler): diff --git a/Handlers/PlayHandler.py b/Handlers/PlayHandler.py index d1c4945..4065635 100644 --- a/Handlers/PlayHandler.py +++ b/Handlers/PlayHandler.py @@ -11,7 +11,7 @@ from Music.Song import Song from Parallelism.ProcessManager import ProcessManager from Parallelism.ProcessInfo import ProcessInfo from Parallelism.Commands import VCommands, VCommandsType -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot class PlayHandler(AbstractHandler): diff --git a/Handlers/PrevHandler.py b/Handlers/PrevHandler.py index 4ef209e..60dbf24 100644 --- a/Handlers/PrevHandler.py +++ b/Handlers/PrevHandler.py @@ -4,7 +4,7 @@ from Config.Exceptions import BadCommandUsage, ImpossibleMove from Handlers.HandlerResponse import HandlerResponse from Parallelism.ProcessManager import ProcessManager from Parallelism.Commands import VCommands, VCommandsType -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot class PrevHandler(AbstractHandler): diff --git a/Handlers/QueueHandler.py b/Handlers/QueueHandler.py index 3f691bb..79cab2a 100644 --- a/Handlers/QueueHandler.py +++ b/Handlers/QueueHandler.py @@ -4,7 +4,7 @@ from Handlers.HandlerResponse import HandlerResponse from Music.Downloader import Downloader from Utils.Utils import Utils from Parallelism.ProcessManager import ProcessManager -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot class QueueHandler(AbstractHandler): diff --git a/Handlers/RemoveHandler.py b/Handlers/RemoveHandler.py index c3a8511..86d094e 100644 --- a/Handlers/RemoveHandler.py +++ b/Handlers/RemoveHandler.py @@ -5,7 +5,7 @@ from Handlers.HandlerResponse import HandlerResponse from Config.Exceptions import BadCommandUsage, VulkanError, ErrorRemoving, InvalidInput, NumberRequired from Music.Playlist import Playlist from Parallelism.ProcessManager import ProcessManager -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot class RemoveHandler(AbstractHandler): diff --git a/Handlers/ResetHandler.py b/Handlers/ResetHandler.py index 762b849..f04d88e 100644 --- a/Handlers/ResetHandler.py +++ b/Handlers/ResetHandler.py @@ -3,7 +3,7 @@ from Handlers.AbstractHandler import AbstractHandler from Handlers.HandlerResponse import HandlerResponse from Parallelism.ProcessManager import ProcessManager from Parallelism.Commands import VCommands, VCommandsType -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot class ResetHandler(AbstractHandler): diff --git a/Handlers/ResumeHandler.py b/Handlers/ResumeHandler.py index abda613..e957be5 100644 --- a/Handlers/ResumeHandler.py +++ b/Handlers/ResumeHandler.py @@ -3,7 +3,7 @@ from Handlers.AbstractHandler import AbstractHandler from Handlers.HandlerResponse import HandlerResponse from Parallelism.ProcessManager import ProcessManager from Parallelism.Commands import VCommands, VCommandsType -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot class ResumeHandler(AbstractHandler): diff --git a/Handlers/ShuffleHandler.py b/Handlers/ShuffleHandler.py index 392923a..053873a 100644 --- a/Handlers/ShuffleHandler.py +++ b/Handlers/ShuffleHandler.py @@ -3,7 +3,7 @@ from Handlers.AbstractHandler import AbstractHandler from Handlers.HandlerResponse import HandlerResponse from Config.Exceptions import UnknownError from Parallelism.ProcessManager import ProcessManager -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot class ShuffleHandler(AbstractHandler): diff --git a/Handlers/SkipHandler.py b/Handlers/SkipHandler.py index 7603ee3..89e2ee9 100644 --- a/Handlers/SkipHandler.py +++ b/Handlers/SkipHandler.py @@ -2,7 +2,7 @@ from discord.ext.commands import Context from Handlers.AbstractHandler import AbstractHandler from Config.Exceptions import BadCommandUsage from Handlers.HandlerResponse import HandlerResponse -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot from Parallelism.ProcessManager import ProcessManager from Parallelism.Commands import VCommands, VCommandsType diff --git a/Handlers/StopHandler.py b/Handlers/StopHandler.py index 0a59cae..3c3908d 100644 --- a/Handlers/StopHandler.py +++ b/Handlers/StopHandler.py @@ -1,7 +1,7 @@ from discord.ext.commands import Context from Handlers.AbstractHandler import AbstractHandler from Handlers.HandlerResponse import HandlerResponse -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot from Parallelism.ProcessManager import ProcessManager from Parallelism.Commands import VCommands, VCommandsType diff --git a/Music/MusicBot.py b/Music/VulkanBot.py similarity index 96% rename from Music/MusicBot.py rename to Music/VulkanBot.py index 9093883..5b2ce45 100644 --- a/Music/MusicBot.py +++ b/Music/VulkanBot.py @@ -2,12 +2,12 @@ from asyncio import AbstractEventLoop from discord import Guild, Status, Game, Message from discord.ext.commands.errors import CommandNotFound, MissingRequiredArgument from Config.Configs import Configs -from discord.ext import commands +from discord.ext.commands import Bot, Context from Config.Messages import Messages from Views.Embeds import Embeds -class VulkanBot(commands.Bot): +class VulkanBot(Bot): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.__configs = Configs() @@ -68,6 +68,6 @@ class VulkanBot(commands.Bot): await self.invoke(ctx) -class Context(commands.Context): +class Context(Context): bot: VulkanBot guild: Guild diff --git a/Music/VulkanInitializer.py b/Music/VulkanInitializer.py index dcf1776..6121aeb 100644 --- a/Music/VulkanInitializer.py +++ b/Music/VulkanInitializer.py @@ -2,9 +2,10 @@ from random import choices import string from discord.bot import Bot from discord import Intents -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot from os import listdir from Config.Configs import Configs +from Config.Exceptions import VulkanError class VulkanInitializer: @@ -35,9 +36,18 @@ class VulkanInitializer: try: for filename in listdir(f'./{self.__config.COMMANDS_PATH}'): if filename.endswith('.py'): - print(f'Loading {filename}') - bot.load_extension(f'{self.__config.COMMANDS_PATH}.{filename[:-3]}') + cogPath = f'{self.__config.COMMANDS_PATH}.{filename[:-3]}' + bot.load_extension(cogPath, store=True) - bot.load_extension(f'DiscordCogs.MusicCog') - except Exception as e: - print(e) + if len(bot.cogs.keys()) != self.__getTotalCogs(): + raise VulkanError(message='Failed to load some Cog') + + except VulkanError as e: + print(f'[Error Loading Vulkan] -> {e.message}') + + def __getTotalCogs(self) -> int: + quant = 0 + for filename in listdir(f'./{self.__config.COMMANDS_PATH}'): + if filename.endswith('.py'): + quant += 1 + return quant diff --git a/Parallelism/PlayerProcess.py b/Parallelism/PlayerProcess.py index ab2bd8d..5cbc522 100644 --- a/Parallelism/PlayerProcess.py +++ b/Parallelism/PlayerProcess.py @@ -10,7 +10,7 @@ from Music.Playlist import Playlist from Music.Song import Song from Config.Configs import Configs from Config.Messages import Messages -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot from Views.Embeds import Embeds from Parallelism.Commands import VCommands, VCommandsType diff --git a/Utils/Cleaner.py b/Utils/Cleaner.py index d66a0f2..57e3457 100644 --- a/Utils/Cleaner.py +++ b/Utils/Cleaner.py @@ -2,7 +2,7 @@ from typing import List from discord.ext.commands import Context from discord import Message, Embed from Config.Singleton import Singleton -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot class Cleaner(Singleton): diff --git a/Views/AbstractView.py b/Views/AbstractView.py index a8f848b..41e71b1 100644 --- a/Views/AbstractView.py +++ b/Views/AbstractView.py @@ -2,7 +2,7 @@ from abc import ABC, abstractmethod from Handlers.HandlerResponse import HandlerResponse from discord.ext.commands import Context from discord import Message -from Music.MusicBot import VulkanBot +from Music.VulkanBot import VulkanBot class AbstractView(ABC): diff --git a/main.py b/main.py index c800823..c44bff4 100644 --- a/main.py +++ b/main.py @@ -1,46 +1,4 @@ -from random import choices -import string -from discord.bot import Bot -from discord import Intents -from Music.MusicBot import VulkanBot -from os import listdir -from Config.Configs import Configs - - -class VulkanInitializer: - def __init__(self, willListen: bool) -> None: - self.__config = Configs() - self.__intents = Intents.default() - self.__intents.message_content = True - self.__intents.members = True - self.__bot = self.__create_bot(willListen) - self.__add_cogs(self.__bot) - - def getBot(self) -> VulkanBot: - return self.__bot - - def __create_bot(self, willListen: bool) -> VulkanBot: - if willListen: - prefix = self.__config.BOT_PREFIX - else: - prefix = ''.join(choices(string.ascii_uppercase + string.digits, k=4)) - - bot = VulkanBot(command_prefix=prefix, - pm_help=True, - case_insensitive=True, - intents=self.__intents) - return bot - - def __add_cogs(self, bot: Bot) -> None: - try: - for filename in listdir(f'./{self.__config.COMMANDS_PATH}'): - if filename.endswith('.py'): - print(f'Loading {filename}') - bot.load_extension(f'{self.__config.COMMANDS_PATH}.{filename[:-3]}') - - bot.load_extension(f'DiscordCogs.MusicCog') - except Exception as e: - print(e) +from Music.VulkanInitializer import VulkanInitializer if __name__ == '__main__':