示例#1
0
def loadCogs():
    for cog in config["cogs"]:
        try:
            bot.load_extension(cog)
            colours.success(f"{cog} loaded successfully")
        except Exception as e:
            colours.warn(f"{cog} failed to load: {e}")
 def cogLoad(self, res, cog, error=None):
     if res == "success":
         Colours.success(f"Loaded {cog} cog successfully")
         self.writeToFile(logMsg["cogSuccess"].format(self.date(), cog))
     else:
         Colours.fail(f"Failed to load cog: {cog}.\n{error}")
         self.writeToFile(logMsg["cogFail"].format(self.date(), cog))
示例#3
0
    def writeToFile(self, msg):
        if not os.path.isdir("logs"):
            try:
                os.mkdir("logs")
            except:
                colours.fail(
                    "Couldn't create the log directory -- check your file permissions"
                )

        #Handle for the log file -- opening in append mode
        with open(getLog(), "a") as handle:
            handle.write(f"{msg}\n")
示例#4
0
    def connect(self):
        try:
            self.conn = sqlite3.connect(self.dbname)
        except:
            colours.fail(strings["errors"]["dbConnectFail"])
        self.curs = self.conn.cursor()

        #Check to see if the database contains a "users" table
        tableList = self.conn.execute(
            "SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name"
        ).fetchall()
        for i in tableList:
            if i[0] == "users":
                return
        #If not, create it!
        self.setup()
示例#5
0
 def dbCreate(self, dbname):
     colours.info(f"New Database {dbname}. Creating tables...")
     self.writeToFile(logMsg["dbCreate"].format(self.date(), dbname))
示例#6
0
 def end(self):
     colours.info(f"Ending Log {getLog()}...")
     self.writeToFile(logMsg["end"].format(self.date()))
示例#7
0
 def start(self):
     colours.info(f"Starting Log {getLog()}...")
     self.writeToFile(logMsg["initialise"].format(self.date()))
示例#8
0
    Log.end()
    sys.exit()


def sigHandle(sig, frame):
    exit()


signal.signal(signal.SIGINT, sigHandle)

#Sort out log directory
if not os.path.isdir("logs"):
    try:
        os.mkdir("logs")
    except:
        Colours.fail("Couldn't create log directory")

#Record the start time for the bot
os.environ["START-TIME"] = str(datetime.date.today())

#Create the bot
bot = commands.Bot(command_prefix=config["prefix"])
bot.remove_command("help")

#Load Cogs
for cog in config["cogs"]:
    if cog not in config["disabledCogs"]:
        try:
            bot.load_extension(f"cogs.{cog}")
            Colours.success(f"{cog} loaded successfully")
        except Exception as e:
示例#9
0
async def on_ready():
    if config["status"] != "":
        await bot.change_presence(activity=discord.Game(config["status"]))
    colours.success("Connected")
示例#10
0
def exiting():
    log.end()
    colours.success("Exiting...")
    sys.exit(0)
示例#11
0
 def start(self):
     Colours.success("Logging Enabled")
     self.writeToFile(logMsg["start"].format(self.date()))