diff --git a/Aoipy/Classes/AoiPyClient.py b/Aoipy/Classes/AoiPyClient.py index 520d626..cb444fb 100644 --- a/Aoipy/Classes/AoiPyClient.py +++ b/Aoipy/Classes/AoiPyClient.py @@ -3,17 +3,21 @@ from Aoipy.tools import FunctionHandler from .CommandHandler import load_commands import asyncio + global TotalFuncs global bots +global all_commands class Aoipy(discord.Client): # Global variables global bots + global all_commands def __init__(self, prefix, case_insensitive, intents: tuple, activity, help_command, load_command_dir): # Global variables global bots + global all_commands # Initialize Start class self.prefix = prefix @@ -66,6 +70,7 @@ def AoipyClient(prefix: str, case_insensitive: bool = False, intents: tuple = (" # Global variables global bots global TotalFuncs + global all_commands # Initialize FunctionHandler and register functions Functions = FunctionHandler() diff --git a/Aoipy/Classes/Cogs.py b/Aoipy/Classes/Cogs.py index 0950bca..489cdc8 100644 --- a/Aoipy/Classes/Cogs.py +++ b/Aoipy/Classes/Cogs.py @@ -5,7 +5,7 @@ class Aoicogs: def Cogs(self, Cog_Group, Name, Code): - from Aoipy.Classes.AoiPyClient import bots + from Aoipy.Classes.AoiPyClient import bots, all_commands class main_bod: def __init__(self, bot): @@ -20,5 +20,10 @@ async def go(self, ctx, *args, Code=Code): await findBracketPairs(finalCode, TotalFuncs, Context) - COGS = type(Cog_Group, (commands.Cog,), {'__init__': main_bod.__init__, 'go': main_bod.go}) - asyncio.run(bots.add_cog(COGS(bots))) + if Cog_Group in all_commands: + bots.remove_cog(Cog_Group) + all_commands[Cog_Group][f"go{len(all_commands[Cog_Group])}"]=main_bod.go + else: + all_commands[Cog_Group] = {'__init__': main_bod.__init__, 'go': main_bod.go} + COGS = type(Cog_Group, (commands.Cog,), all_commands[Cog_Group]) + bots.add_cog(COGS(bots))