mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-24 14:07:03 +01:00
Dashboard setting to change chat links, embed render, and mentions limit
This commit is contained in:
parent
b475cc4e64
commit
74e62c7f4c
@ -6,6 +6,9 @@ class Guilds(Base):
|
|||||||
guild_id = db.Column(db.String(255)) # Discord guild id
|
guild_id = db.Column(db.String(255)) # Discord guild id
|
||||||
name = db.Column(db.String(255)) # Name
|
name = db.Column(db.String(255)) # Name
|
||||||
unauth_users = db.Column(db.Boolean()) # If allowed unauth users
|
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
|
roles = db.Column(db.Text()) # Guild Roles
|
||||||
channels = db.Column(db.Text()) # Guild channels
|
channels = db.Column(db.Text()) # Guild channels
|
||||||
owner_id = db.Column(db.String(255)) # Snowflake of the owner
|
owner_id = db.Column(db.String(255)) # Snowflake of the owner
|
||||||
@ -15,6 +18,9 @@ class Guilds(Base):
|
|||||||
self.guild_id = guild_id
|
self.guild_id = guild_id
|
||||||
self.name = name
|
self.name = name
|
||||||
self.unauth_users = True # defaults to true
|
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.roles = roles
|
||||||
self.channels = channels
|
self.channels = channels
|
||||||
self.owner_id = owner_id
|
self.owner_id = owner_id
|
||||||
|
@ -92,6 +92,9 @@ def administrate_guild(guild_id):
|
|||||||
"id": db_guild.guild_id,
|
"id": db_guild.guild_id,
|
||||||
"name": db_guild.name,
|
"name": db_guild.name,
|
||||||
"unauth_users": db_guild.unauth_users,
|
"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
|
"icon": db_guild.icon
|
||||||
}
|
}
|
||||||
return render_template("administrate_guild.html.j2", guild=dbguild_dict, members=users, permissions=permissions)
|
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:
|
if not db_guild:
|
||||||
abort(400)
|
abort(400)
|
||||||
db_guild.unauth_users = request.form.get("unauth_users", db_guild.unauth_users) in ["true", True]
|
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()
|
db.session.commit()
|
||||||
return jsonify(
|
return jsonify(
|
||||||
id=db_guild.id,
|
id=db_guild.id,
|
||||||
guild_id=db_guild.guild_id,
|
guild_id=db_guild.guild_id,
|
||||||
unauth_users=db_guild.unauth_users,
|
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')
|
@user.route('/me')
|
||||||
|
@ -6,6 +6,9 @@ class Guilds(db.Model):
|
|||||||
guild_id = db.Column(db.String(255)) # Discord guild id
|
guild_id = db.Column(db.String(255)) # Discord guild id
|
||||||
name = db.Column(db.String(255)) # Name
|
name = db.Column(db.String(255)) # Name
|
||||||
unauth_users = db.Column(db.Boolean()) # If allowed unauth users
|
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
|
roles = db.Column(db.Text()) # Guild Roles
|
||||||
channels = db.Column(db.Text()) # Guild channels
|
channels = db.Column(db.Text()) # Guild channels
|
||||||
owner_id = db.Column(db.String(255)) # Snowflake of the owner
|
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.guild_id = guild_id
|
||||||
self.name = name
|
self.name = name
|
||||||
self.unauth_users = True # defaults to true
|
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.roles = roles
|
||||||
self.channels = channels
|
self.channels = channels
|
||||||
self.owner_id = owner_id
|
self.owner_id = owner_id
|
||||||
|
@ -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) {
|
function initiate_ban(guild_id, user_id) {
|
||||||
var reason = prompt("Please enter your reason for ban");
|
var reason = prompt("Please enter your reason for ban");
|
||||||
var payload = {
|
var payload = {
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
<div class="card horizontal black-text indigo lighten-5 z-depth-3 hoverable">
|
<div class="card horizontal black-text indigo lighten-5 z-depth-3 hoverable">
|
||||||
<div class="card-stacked">
|
<div class="card-stacked">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
|
|
||||||
<p class="flow-text">Unauthenticated (Guest) Users</p>
|
<p class="flow-text">Unauthenticated (Guest) Users</p>
|
||||||
<div class="switch">
|
<div class="switch">
|
||||||
<label>
|
<label>
|
||||||
@ -47,6 +48,37 @@
|
|||||||
Enable
|
Enable
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<p class="flow-text">Chat Links</p>
|
||||||
|
<div class="switch">
|
||||||
|
<label>
|
||||||
|
Disable
|
||||||
|
<input type="checkbox" id="chat_links" name="chat_links" {% if guild['chat_links'] %}checked{% endif %} >
|
||||||
|
<span class="lever"></span>
|
||||||
|
Enable
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<p class="flow-text">Render Links as an Embed</p>
|
||||||
|
<p>(if possible)</p>
|
||||||
|
<div class="switch">
|
||||||
|
<label>
|
||||||
|
Disable
|
||||||
|
<input type="checkbox" id="bracket_links" name="bracket_links" {% if guild['bracket_links'] %}checked{% endif %} >
|
||||||
|
<span class="lever"></span>
|
||||||
|
Enable
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<p class="flow-text">Message mentions limit</p>
|
||||||
|
<p>(-1 to have no limit - enter to submit)</p>
|
||||||
|
<input id="mentions_limit" type="number" value="{{ guild['mentions_limit'] }}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user