-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
44 lines (30 loc) · 926 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
import os
from glob import glob
import discord
import dotenv
from apscheduler.schedulers import asyncio
from db import database
import logging
logger = logging.getLogger(__name__)
dotenv.load_dotenv(dotenv.find_dotenv())
bot = discord.Bot()
@bot.event
async def on_ready():
# start scheduler to auto save db
scheduler = asyncio.AsyncIOScheduler()
database.auto_save(scheduler)
scheduler.start()
logger.info("Bot successfully started!")
def main():
# load cogs into list
COGS = [path.split(os.sep)[-1][:-3] for path in glob("./cogs/*.py")]
for cog in COGS:
if cog == "__init__":
continue
bot.load_extension(f"cogs.{cog}")
logger.info(f"Loaded {cog}")
bot.run(os.environ.get("BOT_TOKEN"))
if __name__ == "__main__":
logging.basicConfig(format='%(asctime)s - %(name)s - %(message)s', level=logging.INFO)
main()