discord-bot/database.py
Roberto Anić Banić b3d36999b3 Fix
2018-05-07 22:31:15 +02:00

35 lines
702 B
Python

from peewee import *
from bot_config import bot_admin_id
db = SqliteDatabase('bot.db')
class BaseModel(Model):
class Meta:
database = db
class Moderator(BaseModel):
discord_id = IntegerField(unique=True)
sudoer = BooleanField(default=False)
class PiracyString(BaseModel):
string = CharField(unique=True)
class FaqItem(BaseModel):
key = CharField(unique=True)
text = TextField(null=False)
def init():
with db:
db.get_tables()
db.create_tables([Moderator, PiracyString, FaqItem])
try:
Moderator.get(discord_id=bot_admin_id)
except DoesNotExist:
Moderator(discord_id=bot_admin_id, sudoer=True).save()