From 956e466db19c0f51c779f574480798d5201902b0 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Thu, 21 Sep 2017 21:47:00 +0000 Subject: [PATCH] Bot needs create instant invite perms and more descriptive error for 422 if it happens --- webapp/titanembeds/oauth.py | 2 +- webapp/titanembeds/static/js/embed.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/webapp/titanembeds/oauth.py b/webapp/titanembeds/oauth.py index e0bfab9..de5d58f 100644 --- a/webapp/titanembeds/oauth.py +++ b/webapp/titanembeds/oauth.py @@ -96,5 +96,5 @@ def generate_guild_icon_url(id, hash): return guild_icon_url + str(id) + "/" + str(hash) + ".jpg" def generate_bot_invite_url(guild_id): - url = "https://discordapp.com/oauth2/authorize?&client_id={}&scope=bot&permissions={}&guild_id={}".format(config['client-id'], '537349164', guild_id) + url = "https://discordapp.com/oauth2/authorize?&client_id={}&scope=bot&permissions={}&guild_id={}".format(config['client-id'], '641195117', guild_id) return url diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index d0aea34..bc7016d 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -616,6 +616,12 @@ if (data.status == 403) { Materialize.toast('Authentication error! You have been banned.', 10000); setVisitorMode(true); + } else if (data.status == 422) { + if (data.responseJSON.code == 403) { + Materialize.toast("Attempting to add you into the server store has failed. The bot does not have permissions to create instant invite. Therefore, Discord Login has been disabled.", 10000); + } else { + Materialize.toast("Attempting to add you into the server has failed. Either you are banned, reached 100 servers in Discord, or something else bad has happened.", 10000); + } } else if (index < 10) { _wait_for_discord_login(index + 1); } @@ -986,8 +992,6 @@ Materialize.toast('Authentication error! You have been banned.', 10000); } else if (data.status == 406) { Materialize.toast('Illegal username provided! Only alphanumeric, spaces, dashes, and underscores allowed in usernames.', 10000); - } else if (data.status == 422) { - Materialize.toast("Attempting to add you into the server has failed. Either you are banned, reached 100 servers in Discord, or something else bad has happened.", 10000); } else if (data.status == 412) { Materialize.toast("reCAPTCHA reponse has failed. Try again?", 10000); }