diff --git a/webapp/titanembeds/blueprints/user/user.py b/webapp/titanembeds/blueprints/user/user.py index 7c50b53..11c2f85 100644 --- a/webapp/titanembeds/blueprints/user/user.py +++ b/webapp/titanembeds/blueprints/user/user.py @@ -515,6 +515,10 @@ def donate_patch(): subtract_amt = 300 if entry is not None and entry.guest_icon: abort(400) + if item == "send_rich_embed": + subtract_amt = 300 + if entry is not None and entry.send_rich_embed: + abort(400) amt_change = -1 * subtract_amt * amount subtract = set_titan_token(session["user_id"], amt_change, "BUY " + item + " x" + str(amount)) if not subtract: @@ -530,6 +534,10 @@ def donate_patch(): if not entry: entry = Cosmetics(session["user_id"]) entry.guest_icon = True + if item == "send_rich_embed": + if not entry: + entry = Cosmetics(session["user_id"]) + entry.send_rich_embed = True db.session.add(entry) db.session.commit() return ('', 204) diff --git a/webapp/titanembeds/static/js/donate.js b/webapp/titanembeds/static/js/donate.js index 54b7a8e..d4c2a09 100644 --- a/webapp/titanembeds/static/js/donate.js +++ b/webapp/titanembeds/static/js/donate.js @@ -63,4 +63,21 @@ } }); }); + + $("#buy-send-rich-embed-btn").click(function () { + var formPatch = patchForm("send_rich_embed", 1); + formPatch.done(function (data) { + alert("Successfully bought send rich embed perk!"); + location.reload(); + }); + formPatch.fail(function (data) { + if (data.status == 400) { + Materialize.toast('Item already purchased!', 10000); + } else if (data.status == 402) { + Materialize.toast('Insufficient token funds!', 10000); + } else { + Materialize.toast('Purchasing send rich embed perk failed!', 10000); + } + }); + }); })(); \ No newline at end of file diff --git a/webapp/titanembeds/templates/donate.html.j2 b/webapp/titanembeds/templates/donate.html.j2 index 12f436c..19f13a1 100644 --- a/webapp/titanembeds/templates/donate.html.j2 +++ b/webapp/titanembeds/templates/donate.html.j2 @@ -58,6 +58,14 @@ {% if cosmetics.guest_icon %}Already Purchased{% else %}Buy{% endif %} +
+
+

Send Rich Embed [300 tokens]

+

Lets you and your users access to send rich embed messages directly within your embed!

+

(Note: Embed Links has to be enabled to be displayed in Discord; Titan needs server permissions to Embed Links)

+ {% if cosmetics.send_rich_embed %}Already Purchased{% else %}Buy{% endif %} +
+
{% endblock %} {% block script %}