예제 #1
0
 async def disableCog(self, ctx, extension):
     flag = False
     try:
         self.bot.load_extension(f'cogs.main.{extension}')
         self.bot.unload_extension(f'cogs.main.{extension}')
         flag = True
     except:
         try:
             self.bot.unload_extension(f'cogs.main.{extension}')
             self.bot.load_extension(f'cogs.main.{extension}')
             flag = True
         except:
             pass
         
     if flag:
         try:
             state = dbQuery.cogLoaded(extension)
             dbInsert.cogs(extension, False, state)
             logger.normRun(f'Successfully disabled cog: {extension}')
             await ctx.message.add_reaction("✅")
         except Exception as e:
             logger.errorRun(f'Failed to disable cog: {extension}')
             logger.errorRun(f'{e}')
             await ctx.message.add_reaction("❌")
     else:
         logger.errorRun(f'Failed to disable cog: {extension}')
         await ctx.message.add_reaction("❌")
예제 #2
0
 async def prefix(self, ctx, prefix: str):
     try:
         dbInsert.prefix(ctx.guild.id, prefix)
         await ctx.message.add_reaction("✅")
     except Exception as e:
         logger.errorRun("prefix.py prefix - error changing prefix")
         logger.normRun(e)
         await ctx.message.add_reaction("❌")
예제 #3
0
 async def loadCog(self, ctx, extension):
     try:
         self.bot.load_extension(f'cogs.main.{extension}')
         logger.normRun(f'Successfully loaded cog: {extension}')
         state = dbQuery.cogEnabled(extension)
         dbInsert.cogs(extension, state, True)
         await ctx.message.add_reaction("✅")
     except Exception as e:
         logger.errorRun(f'Failed to load cog: {extension}')
         logger.errorRun(f'{e}')
         await ctx.message.add_reaction("❌")
예제 #4
0
 async def enableCmd(self, ctx, *, cmd):
     allCmd = []
     for command in set(ctx.bot.walk_commands()):
         allCmd.append(str(command))
     try:
         if str(cmd) in allCmd:
             dbInsert.commands(ctx.guild.id, cmd, True)
             logger.normRun(f"Successfully enabled command: {cmd}")
             await ctx.message.add_reaction("✅")
         else:
             logger.warnRun(f"Command doesn't exist: {cmd}")
             await ctx.message.add_reaction("❌")
     except Exception as e:
         logger.errorRun(f"Failed to enable command: {cmd}")
         logger.normRun(e)
         await ctx.message.add_reaction("❌")
예제 #5
0
def connect():
    try:
        conf = config.readINI('mainConfig.ini')
        cnx = mysql.connect(host=conf['mySQL']['host'],
                            database=conf['mySQL']['dbname'],
                            user=conf['mySQL']['user'],
                            password=conf['mySQL']['password'])
        return cnx
    except mysql.Error as e:
        if e.errno == errorcode.ER_ACCESS_DENIED_ERROR:
            logger.errorRun(
                "dbConnect.py SQLconnect - Something is wrong with the username or password"
            )
            logger.normRun(e)
        elif e.errno == errorcode.ER_BAD_DB_ERROR:
            logger.errorRun(
                "dbConnect.py SQLconnect - Database does not exist")
            logger.normRun(e)
        else:
            logger.errorRun("dbConnect.py SQLconnect - error")
            logger.normRun(e)
        return False