mirror of
				https://github.com/TitanEmbeds/Titan.git
				synced 2025-11-03 23:37:09 +01:00 
			
		
		
		
	Add informative messages for authenticated user ban or reached max server limit
This commit is contained in:
		@@ -545,25 +545,25 @@ def create_authenticated_user():
 | 
				
			|||||||
    else:
 | 
					    else:
 | 
				
			||||||
        if not check_guild_existance(guild_id):
 | 
					        if not check_guild_existance(guild_id):
 | 
				
			||||||
            abort(404)
 | 
					            abort(404)
 | 
				
			||||||
        if not checkUserBanned(guild_id):
 | 
					        if not check_user_in_guild(guild_id):
 | 
				
			||||||
            if not check_user_in_guild(guild_id):
 | 
					            add_member = discord_api.add_guild_member(guild_id, session['user_id'], session['user_keys']['access_token'])
 | 
				
			||||||
                add_member = discord_api.add_guild_member(guild_id, session['user_id'], session['user_keys']['access_token'])
 | 
					            if not add_member["success"]:
 | 
				
			||||||
                if not add_member["success"]:
 | 
					                discord_status_code = add_member["content"].get("code", 0)
 | 
				
			||||||
 | 
					                if discord_status_code == 40007: # user banned from server
 | 
				
			||||||
 | 
					                    status = {'banned': True}
 | 
				
			||||||
 | 
					                    response = jsonify(status=status)
 | 
				
			||||||
 | 
					                    response.status_code = 403
 | 
				
			||||||
 | 
					                else:
 | 
				
			||||||
                    response = jsonify(add_member)
 | 
					                    response = jsonify(add_member)
 | 
				
			||||||
                    response.status_code = 422
 | 
					                    response.status_code = 422
 | 
				
			||||||
                    return response
 | 
					                return response
 | 
				
			||||||
            db_user = db.session.query(AuthenticatedUsers).filter(and_(AuthenticatedUsers.guild_id == guild_id, AuthenticatedUsers.client_id == session['user_id'])).first()
 | 
					        db_user = db.session.query(AuthenticatedUsers).filter(and_(AuthenticatedUsers.guild_id == guild_id, AuthenticatedUsers.client_id == session['user_id'])).first()
 | 
				
			||||||
            if not db_user:
 | 
					        if not db_user:
 | 
				
			||||||
                db_user = AuthenticatedUsers(guild_id, session['user_id'])
 | 
					            db_user = AuthenticatedUsers(guild_id, session['user_id'])
 | 
				
			||||||
                db.session.add(db_user)
 | 
					            db.session.add(db_user)
 | 
				
			||||||
                db.session.commit()
 | 
					            db.session.commit()
 | 
				
			||||||
            status = update_user_status(guild_id, session['username'])
 | 
					        status = update_user_status(guild_id, session['username'])
 | 
				
			||||||
            return jsonify(status=status)
 | 
					        return jsonify(status=status)
 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            status = {'banned': True}
 | 
					 | 
				
			||||||
            response = jsonify(status=status)
 | 
					 | 
				
			||||||
            response.status_code = 403
 | 
					 | 
				
			||||||
            return response
 | 
					 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
@api.route("/user/<guild_id>/<user_id>")
 | 
					@api.route("/user/<guild_id>/<user_id>")
 | 
				
			||||||
@abort_if_guild_disabled()
 | 
					@abort_if_guild_disabled()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -97,6 +97,7 @@ class DiscordREST:
 | 
				
			|||||||
            if req.status_code == 403 or req.status_code == 404:
 | 
					            if req.status_code == 403 or req.status_code == 404:
 | 
				
			||||||
                return {
 | 
					                return {
 | 
				
			||||||
                    'success': False,
 | 
					                    'success': False,
 | 
				
			||||||
 | 
					                    'content': json_or_text(req),
 | 
				
			||||||
                    'code': req.status_code,
 | 
					                    'code': req.status_code,
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1101,13 +1101,15 @@
 | 
				
			|||||||
            });
 | 
					            });
 | 
				
			||||||
            usr.fail(function(data) {
 | 
					            usr.fail(function(data) {
 | 
				
			||||||
                if (data.status == 403) {
 | 
					                if (data.status == 403) {
 | 
				
			||||||
                    Materialize.toast('Authentication error! You have been banned.', 10000);
 | 
					                    Materialize.toast('Authentication error! You are banned.', 10000);
 | 
				
			||||||
                    setVisitorMode(true);
 | 
					                    setVisitorMode(true);
 | 
				
			||||||
                } else if (data.status == 422) {
 | 
					                } else if (data.status == 422) {
 | 
				
			||||||
                    if (data.responseJSON.code == 403) {
 | 
					                    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);
 | 
					                        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 if (data.responseJSON.content.code == 30001) { // Maximum number of guilds reached (100)
 | 
				
			||||||
 | 
					                        Materialize.toast("You have reached the 100 servers limit. You may not join more servers.", 10000);
 | 
				
			||||||
                    } else {
 | 
					                    } 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);
 | 
					                        Materialize.toast("An unexpected error has occured while attempting to add you into the server.", 10000);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                } else if (index < 10) {
 | 
					                } else if (index < 10) {
 | 
				
			||||||
                    _wait_for_discord_login(index + 1);
 | 
					                    _wait_for_discord_login(index + 1);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user