Fixing errors due to new discor d library

This commit is contained in:
Rafael Vargas 2022-07-27 11:27:38 -03:00
parent fededdbb8c
commit beb0bc085d
25 changed files with 61 additions and 103 deletions

View File

@ -1,10 +1,9 @@
from discord import Embed from discord import Embed
from discord.ext import commands from discord.ext.commands import Cog, command
from discord.ext.commands import Cog
from Config.Configs import Configs from Config.Configs import Configs
from Config.Helper import Helper from Config.Helper import Helper
from Config.Colors import Colors from Config.Colors import Colors
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
from Views.Embeds import Embeds from Views.Embeds import Embeds
helper = Helper() helper = Helper()
@ -14,10 +13,7 @@ class ControlCog(Cog):
"""Class to handle discord events""" """Class to handle discord events"""
def __init__(self, bot: VulkanBot): def __init__(self, bot: VulkanBot):
print('Eae3')
self.__bot = bot self.__bot = bot
print(self.__bot)
print(bot.extensions)
self.__config = Configs() self.__config = Configs()
self.__colors = Colors() self.__colors = Colors()
self.__embeds = Embeds() 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=''): async def help_msg(self, ctx, command_help=''):
if command_help != '': if command_help != '':
for command in self.__bot.commands: for command in self.__bot.commands:
@ -81,7 +77,7 @@ class ControlCog(Cog):
embedhelp.set_thumbnail(url=self.__bot.user.avatar) embedhelp.set_thumbnail(url=self.__bot.user.avatar)
await ctx.send(embed=embedhelp) 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): async def invite_bot(self, ctx):
invite_url = self.__config.INVITE_URL.format(self.__bot.user.id) invite_url = self.__config.INVITE_URL.format(self.__bot.user.id)
txt = self.__config.INVITE_MESSAGE.format(invite_url, invite_url) txt = self.__config.INVITE_MESSAGE.format(invite_url, invite_url)

View File

@ -1,6 +1,5 @@
from discord import Guild, Client from discord import Guild, Client
from discord.ext import commands from discord.ext.commands import Context, command, Cog
from discord.ext.commands import Context
from Config.Helper import Helper from Config.Helper import Helper
from Handlers.ClearHandler import ClearHandler from Handlers.ClearHandler import ClearHandler
from Handlers.MoveHandler import MoveHandler from Handlers.MoveHandler import MoveHandler
@ -23,7 +22,7 @@ from Views.EmbedView import EmbedView
helper = Helper() helper = Helper()
class MusicCog(commands.Cog): class MusicCog(Cog):
""" """
Class to listen to Music commands Class to listen to Music commands
It'll listen for commands from discord, when triggered will create a specific Handler for the command 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: def __init__(self, bot) -> None:
self.__bot: Client = bot 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: async def play(self, ctx: Context, *args) -> None:
try: try:
controller = PlayHandler(ctx, self.__bot) controller = PlayHandler(ctx, self.__bot)
@ -47,7 +46,7 @@ class MusicCog(commands.Cog):
except Exception as e: except Exception as e:
print(f'[ERROR IN COG] -> {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: async def queue(self, ctx: Context) -> None:
try: try:
controller = QueueHandler(ctx, self.__bot) controller = QueueHandler(ctx, self.__bot)
@ -58,7 +57,7 @@ class MusicCog(commands.Cog):
except Exception as e: except Exception as e:
print(f'[ERROR IN COG] -> {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: async def skip(self, ctx: Context) -> None:
try: try:
controller = SkipHandler(ctx, self.__bot) controller = SkipHandler(ctx, self.__bot)
@ -73,7 +72,7 @@ class MusicCog(commands.Cog):
except Exception as e: except Exception as e:
print(f'[ERROR IN COG] -> {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: async def stop(self, ctx: Context) -> None:
try: try:
controller = StopHandler(ctx, self.__bot) controller = StopHandler(ctx, self.__bot)
@ -88,7 +87,7 @@ class MusicCog(commands.Cog):
except Exception as e: except Exception as e:
print(f'[ERROR IN COG] -> {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: async def pause(self, ctx: Context) -> None:
try: try:
controller = PauseHandler(ctx, self.__bot) controller = PauseHandler(ctx, self.__bot)
@ -101,7 +100,7 @@ class MusicCog(commands.Cog):
except Exception as e: except Exception as e:
print(f'[ERROR IN COG] -> {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: async def resume(self, ctx: Context) -> None:
try: try:
controller = ResumeHandler(ctx, self.__bot) controller = ResumeHandler(ctx, self.__bot)
@ -114,7 +113,7 @@ class MusicCog(commands.Cog):
except Exception as e: except Exception as e:
print(f'[ERROR IN COG] -> {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: async def prev(self, ctx: Context) -> None:
try: try:
controller = PrevHandler(ctx, self.__bot) controller = PrevHandler(ctx, self.__bot)
@ -128,7 +127,7 @@ class MusicCog(commands.Cog):
except Exception as e: except Exception as e:
print(f'[ERROR IN COG] -> {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: async def history(self, ctx: Context) -> None:
try: try:
controller = HistoryHandler(ctx, self.__bot) controller = HistoryHandler(ctx, self.__bot)
@ -141,7 +140,7 @@ class MusicCog(commands.Cog):
except Exception as e: except Exception as e:
print(f'[ERROR IN COG] -> {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: async def loop(self, ctx: Context, args='') -> None:
try: try:
controller = LoopHandler(ctx, self.__bot) controller = LoopHandler(ctx, self.__bot)
@ -154,7 +153,7 @@ class MusicCog(commands.Cog):
except Exception as e: except Exception as e:
print(f'[ERROR IN COG] -> {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: async def clear(self, ctx: Context) -> None:
try: try:
controller = ClearHandler(ctx, self.__bot) controller = ClearHandler(ctx, self.__bot)
@ -165,7 +164,7 @@ class MusicCog(commands.Cog):
except Exception as e: except Exception as e:
print(f'[ERROR IN COG] -> {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: async def now_playing(self, ctx: Context) -> None:
try: try:
controller = NowPlayingHandler(ctx, self.__bot) controller = NowPlayingHandler(ctx, self.__bot)
@ -178,7 +177,7 @@ class MusicCog(commands.Cog):
except Exception as e: except Exception as e:
print(f'[ERROR IN COG] -> {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: async def shuffle(self, ctx: Context) -> None:
try: try:
controller = ShuffleHandler(ctx, self.__bot) controller = ShuffleHandler(ctx, self.__bot)
@ -191,7 +190,7 @@ class MusicCog(commands.Cog):
except Exception as e: except Exception as e:
print(f'[ERROR IN COG] -> {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: async def move(self, ctx: Context, pos1, pos2='1') -> None:
try: try:
controller = MoveHandler(ctx, self.__bot) controller = MoveHandler(ctx, self.__bot)
@ -204,7 +203,7 @@ class MusicCog(commands.Cog):
except Exception as e: except Exception as e:
print(f'[ERROR IN COG] -> {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: async def remove(self, ctx: Context, position) -> None:
try: try:
controller = RemoveHandler(ctx, self.__bot) controller = RemoveHandler(ctx, self.__bot)
@ -217,7 +216,7 @@ class MusicCog(commands.Cog):
except Exception as e: except Exception as e:
print(f'[ERROR IN COG] -> {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: async def reset(self, ctx: Context) -> None:
try: try:
controller = ResetHandler(ctx, self.__bot) controller = ResetHandler(ctx, self.__bot)
@ -232,6 +231,4 @@ class MusicCog(commands.Cog):
def setup(bot): def setup(bot):
print('Loading Music')
bot.add_cog(MusicCog(bot)) bot.add_cog(MusicCog(bot))
print('Voltou')

View File

@ -1,5 +1,5 @@
from random import randint, random from random import randint, random
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
from discord.ext.commands import Context, command, Cog from discord.ext.commands import Context, command, Cog
from Config.Helper import Helper from Config.Helper import Helper
from Views.Embeds import Embeds from Views.Embeds import Embeds
@ -11,9 +11,6 @@ class RandomCog(Cog):
"""Class to listen to commands of type Random""" """Class to listen to commands of type Random"""
def __init__(self, bot: VulkanBot): def __init__(self, bot: VulkanBot):
print('Eae2')
print(bot)
print(bot.extensions)
self.__embeds = Embeds() self.__embeds = Embeds()
@command(name='random', help=helper.HELP_RANDOM, description=helper.HELP_RANDOM_LONG, aliases=['rand']) @command(name='random', help=helper.HELP_RANDOM, description=helper.HELP_RANDOM_LONG, aliases=['rand'])

View File

@ -3,7 +3,7 @@ from typing import List
from discord.ext.commands import Context from discord.ext.commands import Context
from discord import Client, Guild, ClientUser, Member from discord import Client, Guild, ClientUser, Member
from Config.Messages import Messages from Config.Messages import Messages
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
from Handlers.HandlerResponse import HandlerResponse from Handlers.HandlerResponse import HandlerResponse
from Config.Configs import Configs from Config.Configs import Configs
from Config.Helper import Helper from Config.Helper import Helper

View File

@ -1,5 +1,5 @@
from discord.ext.commands import Context from discord.ext.commands import Context
from discord import VulkanBot from Music.VulkanBot import VulkanBot
from Handlers.AbstractHandler import AbstractHandler from Handlers.AbstractHandler import AbstractHandler
from Handlers.HandlerResponse import HandlerResponse from Handlers.HandlerResponse import HandlerResponse
from Parallelism.ProcessManager import ProcessManager from Parallelism.ProcessManager import ProcessManager

View File

@ -1,5 +1,5 @@
from discord.ext.commands import Context from discord.ext.commands import Context
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
from Handlers.AbstractHandler import AbstractHandler from Handlers.AbstractHandler import AbstractHandler
from Handlers.HandlerResponse import HandlerResponse from Handlers.HandlerResponse import HandlerResponse
from Utils.Utils import Utils from Utils.Utils import Utils

View File

@ -1,5 +1,5 @@
from discord.ext.commands import Context from discord.ext.commands import Context
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
from Handlers.AbstractHandler import AbstractHandler from Handlers.AbstractHandler import AbstractHandler
from Handlers.HandlerResponse import HandlerResponse from Handlers.HandlerResponse import HandlerResponse
from Config.Exceptions import BadCommandUsage from Config.Exceptions import BadCommandUsage

View File

@ -1,6 +1,6 @@
from typing import Union from typing import Union
from discord.ext.commands import Context from discord.ext.commands import Context
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
from Handlers.AbstractHandler import AbstractHandler from Handlers.AbstractHandler import AbstractHandler
from Handlers.HandlerResponse import HandlerResponse from Handlers.HandlerResponse import HandlerResponse
from Config.Exceptions import BadCommandUsage, VulkanError, InvalidInput, NumberRequired, UnknownError from Config.Exceptions import BadCommandUsage, VulkanError, InvalidInput, NumberRequired, UnknownError

View File

@ -1,7 +1,7 @@
from discord.ext.commands import Context from discord.ext.commands import Context
from Handlers.AbstractHandler import AbstractHandler from Handlers.AbstractHandler import AbstractHandler
from Handlers.HandlerResponse import HandlerResponse from Handlers.HandlerResponse import HandlerResponse
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
from Utils.Cleaner import Cleaner from Utils.Cleaner import Cleaner
from Parallelism.ProcessManager import ProcessManager from Parallelism.ProcessManager import ProcessManager

View File

@ -3,7 +3,7 @@ from Handlers.AbstractHandler import AbstractHandler
from Handlers.HandlerResponse import HandlerResponse from Handlers.HandlerResponse import HandlerResponse
from Parallelism.ProcessManager import ProcessManager from Parallelism.ProcessManager import ProcessManager
from Parallelism.Commands import VCommands, VCommandsType from Parallelism.Commands import VCommands, VCommandsType
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
class PauseHandler(AbstractHandler): class PauseHandler(AbstractHandler):

View File

@ -11,7 +11,7 @@ from Music.Song import Song
from Parallelism.ProcessManager import ProcessManager from Parallelism.ProcessManager import ProcessManager
from Parallelism.ProcessInfo import ProcessInfo from Parallelism.ProcessInfo import ProcessInfo
from Parallelism.Commands import VCommands, VCommandsType from Parallelism.Commands import VCommands, VCommandsType
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
class PlayHandler(AbstractHandler): class PlayHandler(AbstractHandler):

View File

@ -4,7 +4,7 @@ from Config.Exceptions import BadCommandUsage, ImpossibleMove
from Handlers.HandlerResponse import HandlerResponse from Handlers.HandlerResponse import HandlerResponse
from Parallelism.ProcessManager import ProcessManager from Parallelism.ProcessManager import ProcessManager
from Parallelism.Commands import VCommands, VCommandsType from Parallelism.Commands import VCommands, VCommandsType
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
class PrevHandler(AbstractHandler): class PrevHandler(AbstractHandler):

View File

@ -4,7 +4,7 @@ from Handlers.HandlerResponse import HandlerResponse
from Music.Downloader import Downloader from Music.Downloader import Downloader
from Utils.Utils import Utils from Utils.Utils import Utils
from Parallelism.ProcessManager import ProcessManager from Parallelism.ProcessManager import ProcessManager
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
class QueueHandler(AbstractHandler): class QueueHandler(AbstractHandler):

View File

@ -5,7 +5,7 @@ from Handlers.HandlerResponse import HandlerResponse
from Config.Exceptions import BadCommandUsage, VulkanError, ErrorRemoving, InvalidInput, NumberRequired from Config.Exceptions import BadCommandUsage, VulkanError, ErrorRemoving, InvalidInput, NumberRequired
from Music.Playlist import Playlist from Music.Playlist import Playlist
from Parallelism.ProcessManager import ProcessManager from Parallelism.ProcessManager import ProcessManager
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
class RemoveHandler(AbstractHandler): class RemoveHandler(AbstractHandler):

View File

@ -3,7 +3,7 @@ from Handlers.AbstractHandler import AbstractHandler
from Handlers.HandlerResponse import HandlerResponse from Handlers.HandlerResponse import HandlerResponse
from Parallelism.ProcessManager import ProcessManager from Parallelism.ProcessManager import ProcessManager
from Parallelism.Commands import VCommands, VCommandsType from Parallelism.Commands import VCommands, VCommandsType
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
class ResetHandler(AbstractHandler): class ResetHandler(AbstractHandler):

View File

@ -3,7 +3,7 @@ from Handlers.AbstractHandler import AbstractHandler
from Handlers.HandlerResponse import HandlerResponse from Handlers.HandlerResponse import HandlerResponse
from Parallelism.ProcessManager import ProcessManager from Parallelism.ProcessManager import ProcessManager
from Parallelism.Commands import VCommands, VCommandsType from Parallelism.Commands import VCommands, VCommandsType
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
class ResumeHandler(AbstractHandler): class ResumeHandler(AbstractHandler):

View File

@ -3,7 +3,7 @@ from Handlers.AbstractHandler import AbstractHandler
from Handlers.HandlerResponse import HandlerResponse from Handlers.HandlerResponse import HandlerResponse
from Config.Exceptions import UnknownError from Config.Exceptions import UnknownError
from Parallelism.ProcessManager import ProcessManager from Parallelism.ProcessManager import ProcessManager
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
class ShuffleHandler(AbstractHandler): class ShuffleHandler(AbstractHandler):

View File

@ -2,7 +2,7 @@ from discord.ext.commands import Context
from Handlers.AbstractHandler import AbstractHandler from Handlers.AbstractHandler import AbstractHandler
from Config.Exceptions import BadCommandUsage from Config.Exceptions import BadCommandUsage
from Handlers.HandlerResponse import HandlerResponse from Handlers.HandlerResponse import HandlerResponse
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
from Parallelism.ProcessManager import ProcessManager from Parallelism.ProcessManager import ProcessManager
from Parallelism.Commands import VCommands, VCommandsType from Parallelism.Commands import VCommands, VCommandsType

View File

@ -1,7 +1,7 @@
from discord.ext.commands import Context from discord.ext.commands import Context
from Handlers.AbstractHandler import AbstractHandler from Handlers.AbstractHandler import AbstractHandler
from Handlers.HandlerResponse import HandlerResponse from Handlers.HandlerResponse import HandlerResponse
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
from Parallelism.ProcessManager import ProcessManager from Parallelism.ProcessManager import ProcessManager
from Parallelism.Commands import VCommands, VCommandsType from Parallelism.Commands import VCommands, VCommandsType

View File

@ -2,12 +2,12 @@ from asyncio import AbstractEventLoop
from discord import Guild, Status, Game, Message from discord import Guild, Status, Game, Message
from discord.ext.commands.errors import CommandNotFound, MissingRequiredArgument from discord.ext.commands.errors import CommandNotFound, MissingRequiredArgument
from Config.Configs import Configs from Config.Configs import Configs
from discord.ext import commands from discord.ext.commands import Bot, Context
from Config.Messages import Messages from Config.Messages import Messages
from Views.Embeds import Embeds from Views.Embeds import Embeds
class VulkanBot(commands.Bot): class VulkanBot(Bot):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.__configs = Configs() self.__configs = Configs()
@ -68,6 +68,6 @@ class VulkanBot(commands.Bot):
await self.invoke(ctx) await self.invoke(ctx)
class Context(commands.Context): class Context(Context):
bot: VulkanBot bot: VulkanBot
guild: Guild guild: Guild

View File

@ -2,9 +2,10 @@ from random import choices
import string import string
from discord.bot import Bot from discord.bot import Bot
from discord import Intents from discord import Intents
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
from os import listdir from os import listdir
from Config.Configs import Configs from Config.Configs import Configs
from Config.Exceptions import VulkanError
class VulkanInitializer: class VulkanInitializer:
@ -35,9 +36,18 @@ class VulkanInitializer:
try: try:
for filename in listdir(f'./{self.__config.COMMANDS_PATH}'): for filename in listdir(f'./{self.__config.COMMANDS_PATH}'):
if filename.endswith('.py'): if filename.endswith('.py'):
print(f'Loading {filename}') cogPath = f'{self.__config.COMMANDS_PATH}.{filename[:-3]}'
bot.load_extension(f'{self.__config.COMMANDS_PATH}.{filename[:-3]}') bot.load_extension(cogPath, store=True)
bot.load_extension(f'DiscordCogs.MusicCog') if len(bot.cogs.keys()) != self.__getTotalCogs():
except Exception as e: raise VulkanError(message='Failed to load some Cog')
print(e)
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

View File

@ -10,7 +10,7 @@ from Music.Playlist import Playlist
from Music.Song import Song from Music.Song import Song
from Config.Configs import Configs from Config.Configs import Configs
from Config.Messages import Messages from Config.Messages import Messages
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
from Views.Embeds import Embeds from Views.Embeds import Embeds
from Parallelism.Commands import VCommands, VCommandsType from Parallelism.Commands import VCommands, VCommandsType

View File

@ -2,7 +2,7 @@ from typing import List
from discord.ext.commands import Context from discord.ext.commands import Context
from discord import Message, Embed from discord import Message, Embed
from Config.Singleton import Singleton from Config.Singleton import Singleton
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
class Cleaner(Singleton): class Cleaner(Singleton):

View File

@ -2,7 +2,7 @@ from abc import ABC, abstractmethod
from Handlers.HandlerResponse import HandlerResponse from Handlers.HandlerResponse import HandlerResponse
from discord.ext.commands import Context from discord.ext.commands import Context
from discord import Message from discord import Message
from Music.MusicBot import VulkanBot from Music.VulkanBot import VulkanBot
class AbstractView(ABC): class AbstractView(ABC):

44
main.py
View File

@ -1,46 +1,4 @@
from random import choices from Music.VulkanInitializer import VulkanInitializer
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)
if __name__ == '__main__': if __name__ == '__main__':