Пример #1
0
def user_info(guild_id, user_id):
    usr = {
        "id": None,
        "username": None,
        "nickname": None,
        "discriminator": None,
        "avatar": None,
        "avatar_url": None,
        "roles": [],
        "badges": [],
    }
    member = db.session.query(GuildMembers).filter(
        GuildMembers.guild_id == guild_id,
        GuildMembers.user_id == user_id).first()
    if member:
        usr["id"] = str(member.user_id)
        usr["username"] = member.username
        usr["nickname"] = member.nickname
        usr["discriminator"] = member.discriminator
        usr["avatar"] = member.avatar
        usr["avatar_url"] = generate_avatar_url(usr["id"], usr["avatar"],
                                                usr["discriminator"], True)
        roles = get_member_roles(guild_id, user_id)
        dbguild = db.session.query(Guilds).filter(
            Guilds.guild_id == guild_id).first()
        guild_roles = json.loads(dbguild.roles)
        for r in roles:
            for gr in guild_roles:
                if gr["id"] == r:
                    usr["roles"].append(gr)
        usr["badges"] = get_badges(user_id)
        if redis_store.get("DiscordBotsOrgVoted/" + str(member.user_id)):
            usr["badges"].append("discordbotsorgvoted")
    return jsonify(usr)
Пример #2
0
def user_info(guild_id, user_id):
    usr = {
        "id": None,
        "username": None,
        "nickname": None,
        "discriminator": None,
        "avatar": None,
        "avatar_url": None,
        "roles": [],
        "badges": [],
    }
    member = redisqueue.get_guild_member(guild_id, user_id)
    if member:
        usr["id"] = str(member["id"])
        usr["username"] = member["username"]
        usr["nickname"] = member["nick"]
        usr["discriminator"] = member["discriminator"]
        usr["avatar"] = member["avatar"]
        usr["avatar_url"] = generate_avatar_url(usr["id"], usr["avatar"],
                                                usr["discriminator"], True)
        roles = get_member_roles(guild_id, user_id)
        guild_roles = redisqueue.get_guild(guild_id)["roles"]
        for r in roles:
            for gr in guild_roles:
                if gr["id"] == r:
                    usr["roles"].append(gr)
        usr["badges"] = get_badges(user_id)
        if redis_store.get("DiscordBotsOrgVoted/" + str(member["id"])):
            usr["badges"].append("discordbotsorgvoted")
    return jsonify(usr)