#This is the most basic interface CLI wich is basically a comand line that appears when you launch the app it will have commands like stop, help, commands, cogs, load, unload and so on..
@ -214,7 +215,7 @@ async def stop(ctx):
if__name__=="__main__":
api=API(config,bot,log)
api=API(config,bot,log, token)
cli=CLI(api)
bot.api=api
@ -271,9 +272,64 @@ if __name__ == "__main__":
cli.register_command("clear",cli_clear,"Clears the terminal output")
#load
defcli_load(self,cog):
try:
cog=str(cog)
except:
print("Unable to convert the cog name to string.")
return1
print(f"Trying to load {cog}...")
try:
cog_module=importlib.import_module(cog)
class_name=cog.split(".")[1]
print(class_name)
cog_class=getattr(cog_module,class_name)
cog_instance=cog_class(self.api.bot)
self.api.bot.add_cog(cog_instance)
exceptExceptionase:
print(f"ERR: Failed to load {cog} becouse: {e}")
else:
print(f"Loaded {cog} successfully")
cli.register_command("load",cli_load,"Loads a cog takes a cog name as a arg example: load cogs.example")
#unload
defcli_unload(self,cog):
try:
cog=str(cog)
except:
print("Unable to convert the cog name to string.")
return1
print(f"Trying to loadd {cog}...")
try:
cog=cog.split(".")[1]
self.api.bot.unload_extension(cog)
exceptExceptionase:
print(f"ERR Unable to unload {cog} due to: {e}")
else:
print(f"Loaded {cog} successfully")
cli.register_command("unload",cli_unload,"Unloads a cog takes a cog name as a arg example: unload cogs.example")
#start Starts the bot itself.
defcli_start(self):
print("Starting the bot...")
try:
self.api.bot.run(self.api.token)
exceptExceptionase:
print(e)
return1
else:
print("Bot started.")
return0
#cli.register_command("start", cli_start, "Starts the bot.")