Fix mentions with nicknames

This commit is contained in:
Jeremy Zhang 2017-08-10 02:56:45 +00:00
parent 77bde8f258
commit 68d8882d3e
3 changed files with 11 additions and 4 deletions

View File

@ -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,

View File

@ -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

View File

@ -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;