From 10e3d39acf2d24f6e894ed8eff6c2a22d2450b5f Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Tue, 16 Jan 2018 10:40:27 +0000 Subject: [PATCH] Targeting user messages by roles is now possible --- webapp/titanembeds/blueprints/gateway/gateway.py | 2 ++ webapp/titanembeds/static/js/embed.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/webapp/titanembeds/blueprints/gateway/gateway.py b/webapp/titanembeds/blueprints/gateway/gateway.py index f86ce58..9532d35 100644 --- a/webapp/titanembeds/blueprints/gateway/gateway.py +++ b/webapp/titanembeds/blueprints/gateway/gateway.py @@ -164,6 +164,7 @@ class Gateway(Namespace): usr["color"] = self.get_user_color(guild_id, usr["id"]) if (usr["avatar"]): usr["avatar_url"] = "https://cdn.discordapp.com/avatars/{}/{}.jpg".format(usr["id"], usr["avatar"]) + usr["roles"] = json.loads(member.roles) usr["stargazer"] = "star" in get_badges(member.user_id) else: member = db.session.query(GuildMembers).filter(GuildMembers.guild_id == guild_id, GuildMembers.nickname == name, GuildMembers.discriminator == discriminator).first() @@ -175,6 +176,7 @@ class Gateway(Namespace): usr["color"] = self.get_user_color(guild_id, usr["id"]) if (usr["avatar"]): usr["avatar_url"] = "https://cdn.discordapp.com/avatars/{}/{}.jpg".format(usr["id"], usr["avatar"]) + usr["roles"] = json.loads(member.roles) usr["stargazer"] = "star" in get_badges(member.user_id) emit("lookup_user_info", usr) self.teardown_db_session() \ No newline at end of file diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index a283eca..01fa04c 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -1200,9 +1200,10 @@ parent.find(".chatusername").addClass("stargazer"); } if (usr.avatar_url) { - parent.attr("discord_userid", usr.id); parent.find(".authoravatar").prop("src", usr.avatar_url); } + parent.attr("discord_userid", usr.id); + parent.attr("discord_userroles", usr.roles.join(" ")); } collapse_messages(); }