diff --git a/discordbot/titanembeds/database/guilds.py b/discordbot/titanembeds/database/guilds.py index f540328..4bae06a 100644 --- a/discordbot/titanembeds/database/guilds.py +++ b/discordbot/titanembeds/database/guilds.py @@ -6,6 +6,9 @@ class Guilds(Base): 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 owner_id = db.Column(db.String(255)) # Snowflake of the owner @@ -15,6 +18,9 @@ class Guilds(Base): self.guild_id = guild_id self.name = name self.unauth_users = True # defaults to true + self.chat_links = True + self.bracket_links = True + self.mentions_limit = -1 # -1 = unlimited mentions self.roles = roles self.channels = channels self.owner_id = owner_id diff --git a/webapp/titanembeds/blueprints/user/user.py b/webapp/titanembeds/blueprints/user/user.py index 022e765..68194da 100644 --- a/webapp/titanembeds/blueprints/user/user.py +++ b/webapp/titanembeds/blueprints/user/user.py @@ -92,6 +92,9 @@ def administrate_guild(guild_id): "id": db_guild.guild_id, "name": db_guild.name, "unauth_users": db_guild.unauth_users, + "chat_links": db_guild.chat_links, + "bracket_links": db_guild.bracket_links, + "mentions_limit": db_guild.mentions_limit, "icon": db_guild.icon } return render_template("administrate_guild.html.j2", guild=dbguild_dict, members=users, permissions=permissions) @@ -105,11 +108,17 @@ def update_administrate_guild(guild_id): if not db_guild: abort(400) db_guild.unauth_users = request.form.get("unauth_users", db_guild.unauth_users) in ["true", True] + db_guild.chat_links = request.form.get("chat_links", db_guild.chat_links) in ["true", True] + db_guild.bracket_links = request.form.get("bracket_links", db_guild.bracket_links) in ["true", True] + db_guild.mentions_limit = request.form.get("mentions_limit", db_guild.mentions_limit) db.session.commit() return jsonify( id=db_guild.id, guild_id=db_guild.guild_id, unauth_users=db_guild.unauth_users, + chat_links=db_guild.chat_links, + bracket_links=db_guild.bracket_links, + mentions_limit=db_guild.mentions_limit, ) @user.route('/me') diff --git a/webapp/titanembeds/database/guilds.py b/webapp/titanembeds/database/guilds.py index e308dfc..6f3f588 100644 --- a/webapp/titanembeds/database/guilds.py +++ b/webapp/titanembeds/database/guilds.py @@ -6,6 +6,9 @@ class Guilds(db.Model): 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 owner_id = db.Column(db.String(255)) # Snowflake of the owner @@ -15,6 +18,9 @@ class Guilds(db.Model): self.guild_id = guild_id self.name = name self.unauth_users = True # defaults to true + self.chat_links = True + self.bracket_links = True + self.mentions_limit = -1 # -1 = unlimited mentions self.roles = roles self.channels = channels self.owner_id = owner_id diff --git a/webapp/titanembeds/static/js/administrate_guild.js b/webapp/titanembeds/static/js/administrate_guild.js index 6aca7f8..b4c6a75 100644 --- a/webapp/titanembeds/static/js/administrate_guild.js +++ b/webapp/titanembeds/static/js/administrate_guild.js @@ -7,6 +7,35 @@ $('#unauth_users').change(function() { }); }); +$('#chat_links').change(function() { + var pathname = window.location.pathname; + var checked = $(this).is(':checked') + var payload = {"chat_links": checked} + $.post(pathname, payload, function(data) { + Materialize.toast('Updated chat links setting!', 2000) + }); +}); + +$('#bracket_links').change(function() { + var pathname = window.location.pathname; + var checked = $(this).is(':checked') + var payload = {"bracket_links": checked} + $.post(pathname, payload, function(data) { + Materialize.toast('Updated embed links setting!', 2000) + }); +}); + +$("#mentions_limit").keyup(function(event){ + if(event.keyCode == 13){ + var pathname = window.location.pathname; + var value = $("#mentions_limit").val() + var payload = {"mentions_limit": value} + $.post(pathname, payload, function(data) { + Materialize.toast('Updated mentions limit setting!', 2000) + }); + } +}); + function initiate_ban(guild_id, user_id) { var reason = prompt("Please enter your reason for ban"); var payload = { diff --git a/webapp/titanembeds/templates/administrate_guild.html.j2 b/webapp/titanembeds/templates/administrate_guild.html.j2 index 2c8c265..88724d7 100644 --- a/webapp/titanembeds/templates/administrate_guild.html.j2 +++ b/webapp/titanembeds/templates/administrate_guild.html.j2 @@ -38,6 +38,7 @@
+

Unauthenticated (Guest) Users

+ +
+ +

Chat Links

+
+ +
+ +
+ +

Render Links as an Embed

+

(if possible)

+
+ +
+ +
+ +

Message mentions limit

+

(-1 to have no limit - enter to submit)

+