mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-14 18:11:23 +01:00
Inital postgresql implementation (#46)
This commit is contained in:
parent
3a503c9bcb
commit
aa9075f484
@ -84,7 +84,7 @@ class Titan(discord.Client):
|
||||
)
|
||||
|
||||
try:
|
||||
await self.database.connect(config["database-uri"] + "?charset=utf8mb4")
|
||||
await self.database.connect(config["database-uri"])
|
||||
self.database_connected = True
|
||||
except Exception:
|
||||
self.logger.error("Unable to connect to specified database!")
|
||||
|
@ -11,10 +11,10 @@ class Guilds(Base):
|
||||
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(length=4294967295)) # Guild Roles
|
||||
channels = db.Column(db.Text(length=4294967295))# Guild channels
|
||||
webhooks = db.Column(db.Text(length=4294967295))# Guild webhooks
|
||||
emojis = db.Column(db.Text(length=4294967295)) # Guild Emojis
|
||||
roles = db.Column(db.Text().with_variant(db.Text(length=4294967295), 'mysql')) # Guild Roles
|
||||
channels = db.Column(db.Text().with_variant(db.Text(length=4294967295), 'mysql'))# Guild channels
|
||||
webhooks = db.Column(db.Text().with_variant(db.Text(length=4294967295), 'mysql'))# Guild webhooks
|
||||
emojis = db.Column(db.Text().with_variant(db.Text(length=4294967295), 'mysql')) # 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
|
||||
discordio = db.Column(db.String(255)) # Custom Discord.io Invite Link
|
||||
|
@ -55,7 +55,7 @@ def upgrade():
|
||||
existing_server_default=sa.text(u"'1'"))
|
||||
op.alter_column(u'guilds', 'channels',
|
||||
existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'chat_links',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
@ -64,11 +64,11 @@ def upgrade():
|
||||
existing_server_default=sa.text(u"'1'"))
|
||||
op.alter_column(u'guilds', 'emojis',
|
||||
existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'roles',
|
||||
existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'unauth_users',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
@ -81,7 +81,7 @@ def upgrade():
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'webhooks',
|
||||
existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'unauthenticated_users', 'revoked',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
@ -90,7 +90,7 @@ def upgrade():
|
||||
existing_server_default=sa.text(u"'0'"))
|
||||
op.alter_column(u'user_css', 'css',
|
||||
existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=True)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@ -98,7 +98,7 @@ def upgrade():
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column(u'user_css', 'css',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=True)
|
||||
op.alter_column(u'unauthenticated_users', 'revoked',
|
||||
@ -107,7 +107,7 @@ def downgrade():
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text(u"'0'"))
|
||||
op.alter_column(u'guilds', 'webhooks',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'visitor_view',
|
||||
@ -120,11 +120,11 @@ def downgrade():
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text(u"'1'"))
|
||||
op.alter_column(u'guilds', 'roles',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'emojis',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'chat_links',
|
||||
@ -133,7 +133,7 @@ def downgrade():
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text(u"'1'"))
|
||||
op.alter_column(u'guilds', 'channels',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_typesa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'bracket_links',
|
||||
|
@ -39,7 +39,7 @@ def upgrade():
|
||||
existing_server_default=sa.text(u"'1'"))
|
||||
op.alter_column('guilds', 'channels',
|
||||
existing_type=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'chat_links',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
@ -48,11 +48,11 @@ def upgrade():
|
||||
existing_server_default=sa.text(u"'1'"))
|
||||
op.alter_column('guilds', 'emojis',
|
||||
existing_type=mysql.TEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'roles',
|
||||
existing_type=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'unauth_users',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
@ -65,7 +65,7 @@ def upgrade():
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'webhooks',
|
||||
existing_type=mysql.TEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('unauthenticated_users', 'revoked',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
@ -74,7 +74,7 @@ def upgrade():
|
||||
existing_server_default=sa.text(u"'0'"))
|
||||
op.alter_column('user_css', 'css',
|
||||
existing_type=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=True)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@ -82,7 +82,7 @@ def upgrade():
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('user_css', 'css',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=True)
|
||||
op.alter_column('unauthenticated_users', 'revoked',
|
||||
@ -91,7 +91,7 @@ def downgrade():
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text(u"'0'"))
|
||||
op.alter_column('guilds', 'webhooks',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.TEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'visitor_view',
|
||||
@ -104,11 +104,11 @@ def downgrade():
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text(u"'1'"))
|
||||
op.alter_column('guilds', 'roles',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'emojis',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.TEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'chat_links',
|
||||
@ -117,7 +117,7 @@ def downgrade():
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text(u"'1'"))
|
||||
op.alter_column('guilds', 'channels',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'bracket_links',
|
||||
|
@ -44,7 +44,7 @@ def upgrade():
|
||||
existing_server_default=sa.text(u"'1'"))
|
||||
op.alter_column(u'guilds', 'channels',
|
||||
existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'chat_links',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
@ -53,11 +53,11 @@ def upgrade():
|
||||
existing_server_default=sa.text(u"'1'"))
|
||||
op.alter_column(u'guilds', 'emojis',
|
||||
existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'roles',
|
||||
existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'unauth_users',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
@ -70,7 +70,7 @@ def upgrade():
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'webhooks',
|
||||
existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'unauthenticated_users', 'revoked',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
@ -79,7 +79,7 @@ def upgrade():
|
||||
existing_server_default=sa.text(u"'0'"))
|
||||
op.alter_column(u'user_css', 'css',
|
||||
existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=True)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@ -87,7 +87,7 @@ def upgrade():
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column(u'user_css', 'css',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=True)
|
||||
op.alter_column(u'unauthenticated_users', 'revoked',
|
||||
@ -96,7 +96,7 @@ def downgrade():
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text(u"'0'"))
|
||||
op.alter_column(u'guilds', 'webhooks',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'visitor_view',
|
||||
@ -109,11 +109,11 @@ def downgrade():
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text(u"'1'"))
|
||||
op.alter_column(u'guilds', 'roles',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'emojis',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'chat_links',
|
||||
@ -122,7 +122,7 @@ def downgrade():
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text(u"'1'"))
|
||||
op.alter_column(u'guilds', 'channels',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column(u'guilds', 'bracket_links',
|
||||
|
@ -40,7 +40,7 @@ def upgrade():
|
||||
existing_server_default=sa.text("'1'"))
|
||||
op.alter_column('guilds', 'channels',
|
||||
existing_type=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'chat_links',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
@ -49,11 +49,11 @@ def upgrade():
|
||||
existing_server_default=sa.text("'1'"))
|
||||
op.alter_column('guilds', 'emojis',
|
||||
existing_type=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'roles',
|
||||
existing_type=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'unauth_users',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
@ -66,7 +66,7 @@ def upgrade():
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'webhooks',
|
||||
existing_type=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('unauthenticated_users', 'revoked',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
@ -75,7 +75,7 @@ def upgrade():
|
||||
existing_server_default=sa.text("'0'"))
|
||||
op.alter_column('user_css', 'css',
|
||||
existing_type=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'),
|
||||
type_=sa.Text(length=4294967295),
|
||||
type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
existing_nullable=True)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@ -83,7 +83,7 @@ def upgrade():
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('user_css', 'css',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'),
|
||||
existing_nullable=True)
|
||||
op.alter_column('unauthenticated_users', 'revoked',
|
||||
@ -92,7 +92,7 @@ def downgrade():
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text("'0'"))
|
||||
op.alter_column('guilds', 'webhooks',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'visitor_view',
|
||||
@ -105,11 +105,11 @@ def downgrade():
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text("'1'"))
|
||||
op.alter_column('guilds', 'roles',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'emojis',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'chat_links',
|
||||
@ -118,7 +118,7 @@ def downgrade():
|
||||
existing_nullable=False,
|
||||
existing_server_default=sa.text("'1'"))
|
||||
op.alter_column('guilds', 'channels',
|
||||
existing_type=sa.Text(length=4294967295),
|
||||
existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'),
|
||||
type_=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('guilds', 'bracket_links',
|
||||
|
@ -21,7 +21,7 @@ except:
|
||||
|
||||
os.chdir(config['app-location'])
|
||||
app = Flask(__name__, static_folder="static")
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = config['database-uri'] + "?charset=utf8mb4"
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = config['database-uri']
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False # Suppress the warning/no need this on for now.
|
||||
app.config['RATELIMIT_HEADERS_ENABLED'] = True
|
||||
app.config['SQLALCHEMY_POOL_RECYCLE'] = 250
|
||||
|
@ -231,7 +231,7 @@ def add_bot(guild_id):
|
||||
def prepare_guild_members_list(members, bans):
|
||||
all_users = []
|
||||
ip_pool = []
|
||||
members = sorted(members, key=lambda k: datetime.datetime.strptime(str(k.last_timestamp), "%Y-%m-%d %H:%M:%S"), reverse=True)
|
||||
members = sorted(members, key=lambda k: datetime.datetime.strptime(str(k.last_timestamp.replace(tzinfo=None)), "%Y-%m-%d %H:%M:%S"), reverse=True)
|
||||
for member in members:
|
||||
user = {
|
||||
"id": member.id,
|
||||
|
@ -11,10 +11,10 @@ class Guilds(db.Model):
|
||||
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(4294967295), nullable=False) # Guild Roles
|
||||
channels = db.Column(db.Text(4294967295), nullable=False) # Guild channels
|
||||
webhooks = db.Column(db.Text(4294967295), nullable=False) # Guild webhooks
|
||||
emojis = db.Column(db.Text(4294967295), nullable=False) # Guild Emojis
|
||||
roles = db.Column(db.Text().with_variant(db.Text(4294967295), 'mysql'), nullable=False) # Guild Roles
|
||||
channels = db.Column(db.Text().with_variant(db.Text(4294967295), 'mysql'), nullable=False) # Guild channels
|
||||
webhooks = db.Column(db.Text().with_variant(db.Text(4294967295), 'mysql'), nullable=False) # Guild webhooks
|
||||
emojis = db.Column(db.Text().with_variant(db.Text(4294967295), 'mysql'), 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
|
||||
discordio = db.Column(db.String(255)) # Custom Discord.io Invite Link
|
||||
|
@ -20,14 +20,14 @@ def set_keyvalproperty(key, value, expiration=None):
|
||||
def get_keyvalproperty(key):
|
||||
q = db.session.query(KeyValueProperties).filter(KeyValueProperties.key == key)
|
||||
now = datetime.now()
|
||||
if q.count() > 0 and (q.first().expiration is None or q.first().expiration > now):
|
||||
if q.count() > 0 and (q.first().expiration is None or q.first().expiration.replace(tzinfo=None) > now):
|
||||
return q.first().value
|
||||
return None
|
||||
|
||||
def getexpir_keyvalproperty(key):
|
||||
q = db.session.query(KeyValueProperties).filter(KeyValueProperties.key == key)
|
||||
now = datetime.now()
|
||||
if q.count() > 0 and (q.first().expiration is not None and q.first().expiration > now):
|
||||
if q.count() > 0 and (q.first().expiration is not None and q.first().expiration.replace(tzinfo=None) > now):
|
||||
return int(q.first().expiration.strftime('%s'))
|
||||
return 0
|
||||
|
||||
|
@ -5,7 +5,7 @@ class UserCSS(db.Model):
|
||||
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(4294967295)) # CSS contents
|
||||
css = db.Column(db.Text().with_variant(db.Text(4294967295), 'mysql')) # CSS contents
|
||||
|
||||
def __init__(self, name, user_id, css=None):
|
||||
self.name = name
|
||||
|
Loading…
Reference in New Issue
Block a user