This repository has been archived on 2024-07-28. You can view files and clone it, but cannot push or open issues or pull requests.
moderator-bot/database.py

45 lines
1.0 KiB
Python
Raw Normal View History

2022-11-06 03:48:10 -05:00
from peewee import Field, Model, BigIntegerField, CharField, DateField, DateTimeField, ForeignKeyField
import config
from playhouse.db_url import connect
from datetime import datetime, date
2022-12-01 05:54:32 -05:00
db = connect(config.db_url)
2022-11-06 03:48:10 -05:00
from enum import Enum
class MemberRoles(Enum):
OWNER = "owner"
ADMIN = "admin"
HELPER = "helper"
MEMBER = "member"
class Member(Model):
user_id = BigIntegerField()
first_name = CharField()
username = CharField(null=True)
role = CharField(default="member")
2022-12-01 05:54:32 -05:00
warns = BigIntegerField(default=0)
2022-11-06 03:48:10 -05:00
joined = DateField(default=date.today())
class Meta:
db_table = "members"
database = db
class Restriction(Model):
2022-12-01 05:54:32 -05:00
from_user = ForeignKeyField(Member, lazy_load=True)
to_user = ForeignKeyField(Member, lazy_load=True)
2022-11-06 03:48:10 -05:00
2022-12-01 05:54:32 -05:00
text = CharField()
message_id = BigIntegerField()
2022-11-06 03:48:10 -05:00
timestamp = DateTimeField(default=datetime.now().replace(microsecond=0))
class Meta:
db_table = "auditlog"
database = db