mirror of
				https://github.com/TitanEmbeds/Titan.git
				synced 2025-11-03 23:37:09 +01:00 
			
		
		
		
	Fixed up database modules in webapp
This commit is contained in:
		@@ -4,10 +4,10 @@ import time
 | 
			
		||||
 | 
			
		||||
class AuthenticatedUsers(db.Model):
 | 
			
		||||
    __tablename__ = "authenticated_users"
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)    # Auto increment id
 | 
			
		||||
    guild_id = db.Column(db.String(255))            # Guild pretaining to the authenticated user
 | 
			
		||||
    client_id = db.Column(db.String(255))           # Client ID of the authenticated user
 | 
			
		||||
    last_timestamp = db.Column(db.TIMESTAMP)        # The timestamp of when the user has last sent the heartbeat
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)                    # Auto increment id
 | 
			
		||||
    guild_id = db.Column(db.String(255), nullable=False)            # Guild pretaining to the authenticated user
 | 
			
		||||
    client_id = db.Column(db.String(255), nullable=False)           # Client ID of the authenticated user
 | 
			
		||||
    last_timestamp = db.Column(db.TIMESTAMP, nullable=False)        # The timestamp of when the user has last sent the heartbeat
 | 
			
		||||
 | 
			
		||||
    def __init__(self, guild_id, client_id):
 | 
			
		||||
        self.guild_id = guild_id
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,6 @@ from titanembeds.database import db
 | 
			
		||||
 | 
			
		||||
class Cosmetics(db.Model):
 | 
			
		||||
    __tablename__ = "cosmetics"
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)    # Auto increment id
 | 
			
		||||
    user_id = db.Column(db.String(255))             # Discord user id of user of cosmetics
 | 
			
		||||
    css = db.Column(db.Boolean())                   # If they can create/edit custom CSS
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)                    # Auto increment id
 | 
			
		||||
    user_id = db.Column(db.String(255), nullable=False)             # Discord user id of user of cosmetics
 | 
			
		||||
    css = db.Column(db.Boolean(), nullable=False)                   # If they can create/edit custom CSS
 | 
			
		||||
@@ -3,16 +3,16 @@ import json
 | 
			
		||||
 | 
			
		||||
class GuildMembers(db.Model):
 | 
			
		||||
    __tablename__ = "guild_members"
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)    # Auto incremented id
 | 
			
		||||
    guild_id = db.Column(db.String(255))            # Discord guild id
 | 
			
		||||
    user_id = db.Column(db.String(255))             # Discord user id
 | 
			
		||||
    username = db.Column(db.String(255))            # Name
 | 
			
		||||
    discriminator = db.Column(db.Integer)           # User discriminator
 | 
			
		||||
    nickname = db.Column(db.String(255))            # User nickname
 | 
			
		||||
    avatar = db.Column(db.String(255))              # The avatar str of the user
 | 
			
		||||
    active = db.Column(db.Boolean())                # If the user is a member of the guild
 | 
			
		||||
    banned = db.Column(db.Boolean())                # If the user is banned in the guild
 | 
			
		||||
    roles = db.Column(db.Text())                    # Member roles
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)                    # Auto incremented id
 | 
			
		||||
    guild_id = db.Column(db.String(255), nullable=False)            # Discord guild id
 | 
			
		||||
    user_id = db.Column(db.String(255), nullable=False)             # Discord user id
 | 
			
		||||
    username = db.Column(db.String(255), nullable=False)            # Name
 | 
			
		||||
    discriminator = db.Column(db.Integer, nullable=False)           # User discriminator
 | 
			
		||||
    nickname = db.Column(db.String(255))                            # User nickname
 | 
			
		||||
    avatar = db.Column(db.String(255))                              # The avatar str of the user
 | 
			
		||||
    active = db.Column(db.Boolean(), nullable=False)                # If the user is a member of the guild
 | 
			
		||||
    banned = db.Column(db.Boolean(), nullable=False)                # If the user is banned in the guild
 | 
			
		||||
    roles = db.Column(db.Text(), nullable=False)                    # Member roles
 | 
			
		||||
 | 
			
		||||
    def __init__(self, guild_id, user_id, username, discriminator, nickname, avatar, active, banned, roles):
 | 
			
		||||
        self.guild_id = guild_id
 | 
			
		||||
 
 | 
			
		||||
@@ -2,18 +2,18 @@ from titanembeds.database import db
 | 
			
		||||
 | 
			
		||||
class Guilds(db.Model):
 | 
			
		||||
    __tablename__ = "guilds"
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)    # Auto incremented id
 | 
			
		||||
    guild_id = db.Column(db.String(255))            # Discord guild id
 | 
			
		||||
    name = db.Column(db.String(255))                # Name
 | 
			
		||||
    unauth_users = db.Column(db.Boolean())          # If allowed unauth users
 | 
			
		||||
    chat_links = db.Column(db.Boolean())            # If users can post links
 | 
			
		||||
    bracket_links = db.Column(db.Boolean())         # If appending brackets to links to prevent embed
 | 
			
		||||
    mentions_limit = db.Column(db.Integer)          # If there is a limit on the number of mentions in a msg
 | 
			
		||||
    roles = db.Column(db.Text())                    # Guild Roles
 | 
			
		||||
    channels = db.Column(db.Text())                 # Guild channels
 | 
			
		||||
    emojis = db.Column(db.Text())                   # Guild Emojis
 | 
			
		||||
    owner_id = db.Column(db.String(255))            # Snowflake of the owner
 | 
			
		||||
    icon = db.Column(db.String(255))                # The icon string, null if none
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)                                # Auto incremented id
 | 
			
		||||
    guild_id = db.Column(db.String(255), nullable=False)                        # Discord guild id
 | 
			
		||||
    name = db.Column(db.String(255), nullable=False)                            # Name
 | 
			
		||||
    unauth_users = db.Column(db.Boolean(), nullable=False, default=1)           # If allowed unauth users
 | 
			
		||||
    chat_links = db.Column(db.Boolean(), nullable=False, default=1)             # If users can post links
 | 
			
		||||
    bracket_links = db.Column(db.Boolean(), nullable=False, default=1)          # If appending brackets to links to prevent embed
 | 
			
		||||
    mentions_limit = db.Column(db.Integer, nullable=False, default=11)          # If there is a limit on the number of mentions in a msg
 | 
			
		||||
    roles = db.Column(db.Text(), nullable=False)                                # Guild Roles
 | 
			
		||||
    channels = db.Column(db.Text(), nullable=False)                             # Guild channels
 | 
			
		||||
    emojis = db.Column(db.Text(), nullable=False)                               # Guild Emojis
 | 
			
		||||
    owner_id = db.Column(db.String(255), nullable=False)                        # Snowflake of the owner
 | 
			
		||||
    icon = db.Column(db.String(255))                                            # The icon string, null if none
 | 
			
		||||
 | 
			
		||||
    def __init__(self, guild_id, name, roles, channels, emojis, owner_id, icon):
 | 
			
		||||
        self.guild_id = guild_id
 | 
			
		||||
 
 | 
			
		||||
@@ -52,10 +52,10 @@ def delete_keyvalproperty(key):
 | 
			
		||||
 | 
			
		||||
class KeyValueProperties(db.Model):
 | 
			
		||||
    __tablename__ = "keyvalue_properties"
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)    # Auto incremented id
 | 
			
		||||
    key = db.Column(db.String(255))                 # Property Key
 | 
			
		||||
    value = db.Column(db.Text())                    # Property value
 | 
			
		||||
    expiration = db.Column(db.TIMESTAMP)            # Suggested Expiration for value (None = no expire) in secs
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)                    # Auto incremented id
 | 
			
		||||
    key = db.Column(db.String(255), nullable=False)                 # Property Key
 | 
			
		||||
    value = db.Column(db.Text())                                    # Property value
 | 
			
		||||
    expiration = db.Column(db.TIMESTAMP)                            # Suggested Expiration for value (None = no expire) in secs
 | 
			
		||||
 | 
			
		||||
    def __init__(self, key, value, expiration=None):
 | 
			
		||||
        self.key = key
 | 
			
		||||
 
 | 
			
		||||
@@ -4,16 +4,16 @@ import json
 | 
			
		||||
 | 
			
		||||
class Messages(db.Model):
 | 
			
		||||
    __tablename__ = "messages"
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)    # Auto incremented id
 | 
			
		||||
    guild_id = db.Column(db.String(255))            # Discord guild id
 | 
			
		||||
    channel_id = db.Column(db.String(255))          # Channel id
 | 
			
		||||
    message_id = db.Column(db.String(255))          # Message snowflake
 | 
			
		||||
    content = db.Column(db.Text())                  # Message contents
 | 
			
		||||
    author = db.Column(db.Text())                   # Author
 | 
			
		||||
    timestamp = db.Column(db.TIMESTAMP)             # Timestamp of when content is created
 | 
			
		||||
    edited_timestamp = db.Column(db.TIMESTAMP)      # Timestamp of when content is edited
 | 
			
		||||
    mentions = db.Column(db.Text())                 # Mentions serialized
 | 
			
		||||
    attachments = db.Column(db.Text())              # serialized attachments
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)                    # Auto incremented id
 | 
			
		||||
    guild_id = db.Column(db.String(255), nullable=False)            # Discord guild id
 | 
			
		||||
    channel_id = db.Column(db.String(255), nullable=False)          # Channel id
 | 
			
		||||
    message_id = db.Column(db.String(255), nullable=False)          # Message snowflake
 | 
			
		||||
    content = db.Column(db.Text(), nullable=False)                  # Message contents
 | 
			
		||||
    author = db.Column(db.Text(), nullable=False)                   # Author
 | 
			
		||||
    timestamp = db.Column(db.TIMESTAMP, nullable=False)             # Timestamp of when content is created
 | 
			
		||||
    edited_timestamp = db.Column(db.TIMESTAMP)                      # Timestamp of when content is edited
 | 
			
		||||
    mentions = db.Column(db.Text())                                 # Mentions serialized
 | 
			
		||||
    attachments = db.Column(db.Text())                              # serialized attachments
 | 
			
		||||
 | 
			
		||||
    def __init__(self, guild_id, channel_id, message_id, content, author, timestamp, edited_timestamp, mentions, attachments):
 | 
			
		||||
        self.guild_id = guild_id
 | 
			
		||||
 
 | 
			
		||||
@@ -4,15 +4,15 @@ import time
 | 
			
		||||
 | 
			
		||||
class UnauthenticatedBans(db.Model):
 | 
			
		||||
    __tablename__ = "unauthenticated_bans"
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)    # Auto increment id
 | 
			
		||||
    guild_id = db.Column(db.String(255))            # Guild pretaining to the unauthenticated user
 | 
			
		||||
    ip_address = db.Column(db.String(255))          # The IP Address of the user
 | 
			
		||||
    last_username = db.Column(db.String(255))       # The username when they got banned
 | 
			
		||||
    last_discriminator = db.Column(db.Integer)      # The discrim when they got banned
 | 
			
		||||
    timestamp = db.Column(db.TIMESTAMP)             # The timestamp of when the user got banned
 | 
			
		||||
    reason = db.Column(db.Text())                   # The reason of the ban set by the guild moderators
 | 
			
		||||
    lifter_id = db.Column(db.String(255))           # Discord Client ID of the user who lifted the ban
 | 
			
		||||
    placer_id = db.Column(db.String(255))           # The id of who placed the ban
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)                    # Auto increment id
 | 
			
		||||
    guild_id = db.Column(db.String(255), nullable=False)            # Guild pretaining to the unauthenticated user
 | 
			
		||||
    ip_address = db.Column(db.String(255), nullable=False)          # The IP Address of the user
 | 
			
		||||
    last_username = db.Column(db.String(255), nullable=False)       # The username when they got banned
 | 
			
		||||
    last_discriminator = db.Column(db.Integer, nullable=False)      # The discrim when they got banned
 | 
			
		||||
    timestamp = db.Column(db.TIMESTAMP, nullable=False)             # The timestamp of when the user got banned
 | 
			
		||||
    reason = db.Column(db.Text())                                   # The reason of the ban set by the guild moderators
 | 
			
		||||
    lifter_id = db.Column(db.String(255))                           # Discord Client ID of the user who lifted the ban
 | 
			
		||||
    placer_id = db.Column(db.String(255), nullable=False)           # The id of who placed the ban
 | 
			
		||||
 | 
			
		||||
    def __init__(self, guild_id, ip_address, last_username, last_discriminator, reason, placer_id):
 | 
			
		||||
        self.guild_id = guild_id
 | 
			
		||||
 
 | 
			
		||||
@@ -6,14 +6,14 @@ import string
 | 
			
		||||
 | 
			
		||||
class UnauthenticatedUsers(db.Model):
 | 
			
		||||
    __tablename__ = "unauthenticated_users"
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)    # Auto increment id
 | 
			
		||||
    guild_id = db.Column(db.String(255))            # Guild pretaining to the unauthenticated user
 | 
			
		||||
    username = db.Column(db.String(255))            # The username of the user
 | 
			
		||||
    discriminator = db.Column(db.Integer)           # The discriminator to distinguish unauth users with each other
 | 
			
		||||
    user_key = db.Column(db.Text())                 # The secret key used to identify the user holder
 | 
			
		||||
    ip_address = db.Column(db.String(255))          # The IP Address of the user
 | 
			
		||||
    last_timestamp = db.Column(db.TIMESTAMP)        # The timestamp of when the user has last sent the heartbeat
 | 
			
		||||
    revoked = db.Column(db.Boolean())               # If the user's key has been revoked and a new one is required to be generated
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True, nullable=False)    # Auto increment id
 | 
			
		||||
    guild_id = db.Column(db.String(255), nullable=False)            # Guild pretaining to the unauthenticated user
 | 
			
		||||
    username = db.Column(db.String(255), nullable=False)            # The username of the user
 | 
			
		||||
    discriminator = db.Column(db.Integer, nullable=False)           # The discriminator to distinguish unauth users with each other
 | 
			
		||||
    user_key = db.Column(db.Text(), nullable=False)                 # The secret key used to identify the user holder
 | 
			
		||||
    ip_address = db.Column(db.String(255), nullable=False)          # The IP Address of the user
 | 
			
		||||
    last_timestamp = db.Column(db.TIMESTAMP, nullable=False)        # The timestamp of when the user has last sent the heartbeat
 | 
			
		||||
    revoked = db.Column(db.Boolean(), nullable=False)               # If the user's key has been revoked and a new one is required to be generated
 | 
			
		||||
 | 
			
		||||
    def __init__(self, guild_id, username, discriminator, ip_address):
 | 
			
		||||
        self.guild_id = guild_id
 | 
			
		||||
 
 | 
			
		||||
@@ -2,10 +2,10 @@ from titanembeds.database import db
 | 
			
		||||
 | 
			
		||||
class UserCSS(db.Model):
 | 
			
		||||
    __tablename__ = "user_css"
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)    # Auto increment id
 | 
			
		||||
    name = db.Column(db.String(255))                # CSS Name
 | 
			
		||||
    user_id = db.Column(db.String(255))             # Discord client ID of the owner of the css (can edit)
 | 
			
		||||
    css = db.Column(db.Text())                      # CSS contents
 | 
			
		||||
    id = db.Column(db.Integer, primary_key=True)                    # Auto increment id
 | 
			
		||||
    name = db.Column(db.String(255), nullable=False)                # CSS Name
 | 
			
		||||
    user_id = db.Column(db.String(255), nullable=False)             # Discord client ID of the owner of the css (can edit)
 | 
			
		||||
    css = db.Column(db.Text())                                      # CSS contents
 | 
			
		||||
 | 
			
		||||
    def __init__(self, name, user_id, css=None):
 | 
			
		||||
        self.name = name
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user