mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-25 06:27:03 +01:00
Fix permissions issue and role hoists
This commit is contained in:
parent
86c7232b35
commit
6cd27f2aff
@ -65,7 +65,8 @@ def get_formatted_user(user):
|
|||||||
}
|
}
|
||||||
roles = sorted(user.roles, key=lambda k: k.position, reverse=True)
|
roles = sorted(user.roles, key=lambda k: k.position, reverse=True)
|
||||||
for role in roles:
|
for role in roles:
|
||||||
userobj["roles"].append(role.id)
|
userobj["roles"].append(str(role.id))
|
||||||
|
print(role, role.hoist)
|
||||||
if role.hoist and userobj["hoist-role"] == None:
|
if role.hoist and userobj["hoist-role"] == None:
|
||||||
userobj["hoist-role"] = {
|
userobj["hoist-role"] = {
|
||||||
"id": str(role.id),
|
"id": str(role.id),
|
||||||
|
@ -103,7 +103,7 @@ def get_online_discord_users(guild_id, embed):
|
|||||||
apimembers = redisqueue.list_guild_members(guild_id)
|
apimembers = redisqueue.list_guild_members(guild_id)
|
||||||
apimembers_filtered = {}
|
apimembers_filtered = {}
|
||||||
for member in apimembers:
|
for member in apimembers:
|
||||||
apimembers_filtered[member["id"]] = member
|
apimembers_filtered[int(member["id"])] = member
|
||||||
guild_roles = json.loads(db.session.query(Guilds).filter(Guilds.guild_id == guild_id).first().roles)
|
guild_roles = json.loads(db.session.query(Guilds).filter(Guilds.guild_id == guild_id).first().roles)
|
||||||
guildroles_filtered = {}
|
guildroles_filtered = {}
|
||||||
for role in guild_roles:
|
for role in guild_roles:
|
||||||
@ -113,29 +113,10 @@ def get_online_discord_users(guild_id, embed):
|
|||||||
member["hoist-role"] = None
|
member["hoist-role"] = None
|
||||||
member["color"] = None
|
member["color"] = None
|
||||||
if apimem:
|
if apimem:
|
||||||
mem_roles = []
|
member["hoist-role"] = apimem["hoist-role"]
|
||||||
for roleid in apimem["roles"]:
|
member["color"] = apimem["color"]
|
||||||
role = guildroles_filtered.get(roleid)
|
member["avatar"] = apimem["avatar"]
|
||||||
if not role:
|
member["avatar_url"] = apimem["avatar_url"]
|
||||||
continue
|
|
||||||
mem_roles.append(role)
|
|
||||||
mem_roles = sorted(mem_roles, key=lambda k: k['position'])
|
|
||||||
for role in mem_roles:
|
|
||||||
if role["color"] != 0:
|
|
||||||
member["color"] = '{0:02x}'.format(role["color"]) #int to hex
|
|
||||||
while len(member["color"]) < 6:
|
|
||||||
member["color"] = "0" + member["color"]
|
|
||||||
if role["hoist"]:
|
|
||||||
member["hoist-role"] = {}
|
|
||||||
member["hoist-role"]["name"] = role["name"]
|
|
||||||
member["hoist-role"]["id"] = role["id"]
|
|
||||||
member["hoist-role"]["position"] = role["position"]
|
|
||||||
if member.get("avatar", None):
|
|
||||||
member["avatar_url"] = "https://cdn.discordapp.com/avatars/{}/{}".format(member["id"], member["avatar"])
|
|
||||||
if member["avatar"].startswith("a_"):
|
|
||||||
member["avatar_url"] = member["avatar_url"] + ".gif"
|
|
||||||
else:
|
|
||||||
member["avatar_url"] = member["avatar_url"] + ".png"
|
|
||||||
return embed['members']
|
return embed['members']
|
||||||
|
|
||||||
def get_online_embed_users(guild_id):
|
def get_online_embed_users(guild_id):
|
||||||
|
@ -148,7 +148,6 @@ class Gateway(Namespace):
|
|||||||
return color
|
return color
|
||||||
|
|
||||||
def on_lookup_user_info(self, data):
|
def on_lookup_user_info(self, data):
|
||||||
print("test")
|
|
||||||
guild_id = data["guild_id"]
|
guild_id = data["guild_id"]
|
||||||
name = data["name"]
|
name = data["name"]
|
||||||
discriminator = data["discriminator"]
|
discriminator = data["discriminator"]
|
||||||
@ -164,25 +163,18 @@ class Gateway(Namespace):
|
|||||||
"discordbotsorgvoted": False,
|
"discordbotsorgvoted": False,
|
||||||
}
|
}
|
||||||
member = redisqueue.get_guild_member_named(guild_id, "{}#{}".format(name, discriminator))
|
member = redisqueue.get_guild_member_named(guild_id, "{}#{}".format(name, discriminator))
|
||||||
print("test1")
|
|
||||||
if member:
|
if member:
|
||||||
print("test1.5")
|
|
||||||
usr["id"] = str(member["id"])
|
usr["id"] = str(member["id"])
|
||||||
usr["username"] = member["username"]
|
usr["username"] = member["username"]
|
||||||
usr["nickname"] = member["nick"]
|
usr["nickname"] = member["nick"]
|
||||||
usr["avatar"] = member["avatar"]
|
usr["avatar"] = member["avatar"]
|
||||||
print("test1.54")
|
|
||||||
usr["color"] = self.get_user_color(guild_id, usr["id"])
|
usr["color"] = self.get_user_color(guild_id, usr["id"])
|
||||||
print("test1.55")
|
|
||||||
if (usr["avatar"]):
|
if (usr["avatar"]):
|
||||||
usr["avatar_url"] = "https://cdn.discordapp.com/avatars/{}/{}.png".format(usr["id"], usr["avatar"])
|
usr["avatar_url"] = "https://cdn.discordapp.com/avatars/{}/{}.png".format(usr["id"], usr["avatar"])
|
||||||
usr["roles"] = member["roles"]
|
usr["roles"] = member["roles"]
|
||||||
usr["discordbotsorgvoted"] = bool(redis_store.get("DiscordBotsOrgVoted/" + str(member["id"])))
|
usr["discordbotsorgvoted"] = bool(redis_store.get("DiscordBotsOrgVoted/" + str(member["id"])))
|
||||||
print("test1.6")
|
|
||||||
else:
|
else:
|
||||||
print("test2")
|
|
||||||
member = redisqueue.get_guild_member_named(guild_id, name)
|
member = redisqueue.get_guild_member_named(guild_id, name)
|
||||||
print("test3")
|
|
||||||
if member:
|
if member:
|
||||||
usr["id"] = str(member["id"])
|
usr["id"] = str(member["id"])
|
||||||
usr["username"] = member["username"]
|
usr["username"] = member["username"]
|
||||||
@ -193,6 +185,5 @@ class Gateway(Namespace):
|
|||||||
usr["avatar_url"] = "https://cdn.discordapp.com/avatars/{}/{}.png".format(usr["id"], usr["avatar"])
|
usr["avatar_url"] = "https://cdn.discordapp.com/avatars/{}/{}.png".format(usr["id"], usr["avatar"])
|
||||||
usr["roles"] = member["roles"]
|
usr["roles"] = member["roles"]
|
||||||
usr["discordbotsorgvoted"] = bool(redis_store.get("DiscordBotsOrgVoted/" + str(member["id"])))
|
usr["discordbotsorgvoted"] = bool(redis_store.get("DiscordBotsOrgVoted/" + str(member["id"])))
|
||||||
print("test4")
|
|
||||||
emit("lookup_user_info", usr)
|
emit("lookup_user_info", usr)
|
||||||
self.teardown_db_session()
|
self.teardown_db_session()
|
@ -194,7 +194,11 @@ def check_user_in_guild(guild_id):
|
|||||||
|
|
||||||
def get_member_roles(guild_id, user_id):
|
def get_member_roles(guild_id, user_id):
|
||||||
q = redisqueue.get_guild_member(guild_id, user_id)
|
q = redisqueue.get_guild_member(guild_id, user_id)
|
||||||
return q["roles"]
|
roles = q["roles"]
|
||||||
|
role_converted = []
|
||||||
|
for role in roles:
|
||||||
|
role_converted.append(str(role))
|
||||||
|
return role_converted
|
||||||
|
|
||||||
def get_guild_channels(guild_id, force_everyone=False):
|
def get_guild_channels(guild_id, force_everyone=False):
|
||||||
if user_unauthenticated() or force_everyone:
|
if user_unauthenticated() or force_everyone:
|
||||||
|
Loading…
Reference in New Issue
Block a user