class Tag(Model): id = BigIntField(pk=True, generated=True) guild_id = BigIntField(null=False) author_id = BigIntField(null=False) tag_name = CharField(max_length=2000, null=False) tag_content = CharField(max_length=2000, null=False) tag_added = DateField(null=False)
class TwitterChannel(Model): channel_id = BigIntField() twitter_id = BigIntField() guild_id = BigIntField() class Meta: indexes = ("channel_id", "twitter_id", "guild_id")
class Guild(Model): guild_id = BigIntField(unique=True) prefix = CharField(max_length=5, null=True, default="?") clear_spam = BooleanField(default=False) aggregate_clans = BooleanField(default=True) track_sherpas = BooleanField(default=False) admin_channel = BigIntField(unique=True, null=True) announcement_channel = BigIntField(unique=True, null=True)
class Game(Model): mode_id = IntField() instance_id = BigIntField(unique=True) date = DatetimeField() reference_id = BigIntField(null=True) class Meta: indexes = ("mode_id", "reference_id")
class Infraction(Model): id = BigIntField(pk=True, generated=True) guild_id = BigIntField(null=False) moderator_id = BigIntField(null=False) user_id = BigIntField(null=False) type = CharField(max_length=50, null=False) reason = CharField(max_length=2000, null=False, default="No reason was provided.") given_at = DateField(null=False)
class Guild(Model): id = BigIntField(pk=True) prefix = TextField(null=True) mute_role = BigIntField(null=True) level_up_messages = BooleanField(default=True) moderators: ReverseRelation["Moderator"] mutes: ReverseRelation["Mute"] warns: ReverseRelation["Warn"] class Meta: table = "guilds" def __str__(self): return f"<Guild id:{self.id} prefix:{self.prefix} muterole:{self.mute_role}>"
class Message(Model): id = BigIntField(pk=True) channel_id = BigIntField(null=False) user: ForeignKeyRelation[User] = ForeignKeyField('models.User', related_name='messages', null=False) user_event: ReverseRelation['Event'] bot_event: ReverseRelation['Event'] reminder: ReverseRelation['Reminder'] def __str__(self): return f'{self.__class__}: {self.id}'
class User(Model): id = BigIntField(pk=True, generated=False) time_zone = CharField(max_length=255, null=True) time_format = CharField(max_length=255, null=True) messages: ReverseRelation['Message'] def __str__(self): return f'{self.__class__}: {self.id}'
class Guild(Model): id = BigIntField(pk=True, generated=False) mute_role = BigIntField(null=True) mod_logs = BigIntField(null=True) mod_users = ArrayField(int, default=list) mod_roles = ArrayField(int, default=list) disabled_commands = ArrayField(str, default=list) disabled_channels = ArrayField(int, default=list) disabled_users = ArrayField(int, default=list) ignored_users = disabled_users = ArrayField(int) ignored_channels = disabled_users = ArrayField(int) tags_locked = BooleanField(defualt=False) tags_mod_only = BooleanField(defualt=False) language = CharField(max_length=20, null=False, default="en") # I am related stuff: iam_roles = ArrayField(int, null=True) iam_disabled_users = ArrayField(int, null=True)
class Clan(Model): clan_id = BigIntField(unique=True) name = CharField(max_length=255) callsign = CharField(max_length=4) platform = IntField(null=True, validators=[PlatformValidator()]) the100_group_id = IntField(unique=True, null=True) activity_tracking = BooleanField(default=True) guild: ForeignKeyRelation[Guild] = ForeignKeyField( "seraphsix.Guild", related_name="clans", to_field="id" ) members: ReverseRelation["ClanMember"]
class Role(Model): role_id = BigIntField() platform_id = IntField(null=True) is_sherpa = BooleanField(null=True) is_clanmember = BooleanField(null=True) is_new_clanmember = BooleanField(null=True) is_non_clanmember = BooleanField(null=True) is_protected_clanmember = BooleanField(null=True) guild: ForeignKeyRelation[Guild] = ForeignKeyField( "seraphsix.Guild", related_name="roles", to_field="id" ) class Meta: indexes = ("guild", "role_id")
class Member(Model): discord_id = BigIntField(null=True) bungie_id = BigIntField(null=True) bungie_username = CharField(max_length=255, null=True) xbox_id = BigIntField(null=True) xbox_username = CharField(max_length=255, unique=True, null=True) psn_id = BigIntField(null=True) psn_username = CharField(max_length=255, unique=True, null=True) blizzard_id = BigIntField(null=True) blizzard_username = CharField(max_length=255, unique=True, null=True) steam_id = BigIntField(null=True) steam_username = CharField(max_length=255, unique=True, null=True) stadia_id = BigIntField(null=True) stadia_username = CharField(max_length=255, unique=True, null=True) the100_id = BigIntField(unique=True, null=True) the100_username = CharField(max_length=255, unique=True, null=True) timezone = CharField(max_length=255, null=True) bungie_access_token = CharField(max_length=360, unique=True, null=True) bungie_refresh_token = CharField(max_length=360, unique=True, null=True) is_cross_save = BooleanField(default=False) primary_membership_id = BigIntField(unique=True, null=True) clan: ReverseRelation["ClanMember"] games: ReverseRelation["GameMember"] class Meta: indexes = [ PostgreSQLIndex( fields={ "discord_id", "bungie_id", "xbox_id", "psn_id", "blizzard_id", "steam_id", "stadia_id", "the100_id", } ) ]
class ClanMemberApplication(Model): approved = BooleanField(default=False) message_id = BigIntField(unique=True) guild: ForeignKeyRelation[Guild] = ForeignKeyField( "seraphsix.Guild", related_name="clanmemberapplications", to_field="id" ) member: ForeignKeyRelation[Member] = ForeignKeyField( "seraphsix.Member", related_name="clanmemberapplications_created", to_field="id" ) approved_by: ForeignKeyRelation[Member] = ForeignKeyField( "seraphsix.Member", related_name="clanmemberapplications_approved", to_field="id", )
class Warn(Model): id = IntField(pk=True) moderator = BigIntField() reason = TextField(null=True) when = DatetimeField(auto_now_add=True) user: ForeignKeyRelation[User] = ForeignKeyField("models.User", related_name="warns") guild: ForeignKeyRelation[Guild] = ForeignKeyField("models.Guild", related_name="warns") class Meta: table = "warns" def __str__(self): return (f"<Warn id:{self.id} moderator:{self.moderator} " f"reason:'{self.reason}' datetime:{self.when} " f"user:{self.user.id} guild:{self.guild.id}>")
class User(Model): id = BigIntField(pk=True) exp = IntField(default=0) level = IntField(default=0) balance = IntField(default=0) daily_streak = IntField(default=0) last_daily = DatetimeField(null=True) mutes: ReverseRelation["Mute"] warns: ReverseRelation["Warn"] @property def next_daily(self): if not self.last_daily: return None return datetime.fromtimestamp( (self.last_daily + timedelta(hours=23)).timestamp() ) @property def daily_available(self): if not self.last_daily: return True return datetime.utcnow().timestamp() > self.next_daily.timestamp() @property def daily_streak_expired(self): if not self.last_daily: return None return ( datetime.utcnow().timestamp() > (self.last_daily + timedelta(days=2)).timestamp() ) class Meta: table = "users" def __str__(self): return ( f"<User id:{self.id} exp:{self.exp} " f"level:{self.level} bal:{self.balance}>" )
class Mute(Model): id = IntField(pk=True) moderator = BigIntField() reason = TextField(null=True) start = DatetimeField(auto_now_add=True) end = DatetimeField() active = BooleanField(default=True) user: ForeignKeyRelation[User] = ForeignKeyField("models.User", related_name="mutes") guild: ForeignKeyRelation[Guild] = ForeignKeyField("models.Guild", related_name="mutes") class Meta: table = "mutes" def __str__(self): return ( f"<Mute id:{self.id} moderator:{self.moderator} " f"reason:'{self.reason}' start:{self.start} end:{self.end} " f"active:{self.active} user:{self.user.id} guild:{self.guild.id}>")
class Muted_Member(Model): guild = BigIntField(null=False) user_id = BigIntField(null=False)
class BrawlhallaUser(Model): discord_id = BigIntField(pk=True, generated=False) brawlhalla_id = IntField()