discord-akwah/main.py

29 lines
752 B
Python
Raw Normal View History

2020-11-13 15:51:12 +01:00
from os import listdir
from discord.ext.commands import Bot
2021-05-23 17:50:31 +02:00
from configparser import ConfigParser
from peewee import SqliteDatabase
2020-11-13 01:49:39 +01:00
2020-11-13 15:51:12 +01:00
# read config at configured location \\ default to 'config.ini'
2021-05-23 17:50:31 +02:00
config = ConfigParser()
with open('config.ini', 'r') as configfile:
config.read_file(configfile)
# init db
db = SqliteDatabase(config['DATABASE']['path'])
db.connect()
2020-11-13 15:51:12 +01:00
# spawn discord bot instance
2020-11-13 01:49:39 +01:00
# init token from config
2020-11-13 15:51:12 +01:00
bot = Bot(command_prefix="~ak ")
2020-11-15 01:37:27 +01:00
TOKEN = config['AUTH']['token']
2020-11-13 01:49:39 +01:00
2020-11-13 15:51:12 +01:00
# load extensions
for file in listdir("src/ext"):
2020-11-13 15:51:12 +01:00
if file.endswith(".py"):
name = file[:-3]
bot.load_extension(f"src.ext.{name}")
2020-11-13 15:51:12 +01:00
2020-11-13 01:49:39 +01:00
if __name__ == "__main__":
print("[INFO]: Starting bot...")
2020-11-15 01:37:27 +01:00
# use token from config
bot.run(TOKEN)