diff --git a/discordbot/titanembeds/database/__init__.py b/discordbot/titanembeds/database/__init__.py index 1911793..3c22c11 100644 --- a/discordbot/titanembeds/database/__init__.py +++ b/discordbot/titanembeds/database/__init__.py @@ -81,8 +81,6 @@ class DatabaseInterface(object): def get_message_mentions(self, mentions): ments = [] for author in mentions: - if author.nick: - author.name = author.nick ments.append({ "username": author.name, "discriminator": author.discriminator, diff --git a/webapp/titanembeds/database/messages.py b/webapp/titanembeds/database/messages.py index 16f1f04..fbe497f 100644 --- a/webapp/titanembeds/database/messages.py +++ b/webapp/titanembeds/database/messages.py @@ -54,5 +54,10 @@ def get_channel_messages(guild_id, channel_id, after_snowflake=None): message["author"]["nickname"] = None if member: message["author"]["nickname"] = member.nickname + for mention in message["mentions"]: + author = get_guild_member(guild_id, mention["id"]) + mention["nickname"] = None + if author: + mention["nickname"] = author.nickname msgs.append(message) return msgs diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index 64e5de5..cc20b0b 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -510,8 +510,12 @@ var mentions = message.mentions; for (var i = 0; i < mentions.length; i++) { var mention = mentions[i]; - message.content = message.content.replace(new RegExp("<@" + mention.id + ">", 'g'), "@" + mention.username + "#" + mention.discriminator); - message.content = message.content.replace(new RegExp("<@!" + mention.id + ">", 'g'), "@" + mention.username + "#" + mention.discriminator); + var username = mention.username; + if (mention.nickname) { + username = mention.nickname; + } + message.content = message.content.replace(new RegExp("<@" + mention.id + ">", 'g'), "@" + username + "#" + mention.discriminator); + message.content = message.content.replace(new RegExp("<@!" + mention.id + ">", 'g'), "@" + username + "#" + mention.discriminator); message.content = message.content.replace("<@&" + guild_id + ">", "@everyone"); } return message;