feat: show member color in reply embed

This commit is contained in:
spiral 2021-05-01 19:20:00 +01:00
parent cf93b8b3cc
commit 517abf7ff1
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31
3 changed files with 13 additions and 4 deletions

View File

@ -116,7 +116,7 @@ namespace PluralKit.Bot
if (repliedTo != null)
{
var nickname = await FetchReferencedMessageAuthorNickname(trigger, repliedTo);
var embed = CreateReplyEmbed(trigger, repliedTo, nickname);
var embed = CreateReplyEmbed(match, trigger, repliedTo, nickname);
if (embed != null)
embeds.Add(embed);
}
@ -160,7 +160,7 @@ namespace PluralKit.Bot
}
}
private Embed CreateReplyEmbed(Message trigger, Message repliedTo, string? nickname)
private Embed CreateReplyEmbed(ProxyMatch match, Message trigger, Message repliedTo, string? nickname)
{
// repliedTo doesn't have a GuildId field :/
var jumpLink = $"https://discord.com/channels/{trigger.GuildId}/{repliedTo.ChannelId}/{repliedTo.Id}";
@ -194,11 +194,14 @@ namespace PluralKit.Bot
var username = nickname ?? repliedTo.Author.Username;
var avatarUrl = $"https://cdn.discordapp.com/avatars/{repliedTo.Author.Id}/{repliedTo.Author.Avatar}.png";
Console.WriteLine($"color {match.Member.Color}");
return new Embed
{
// unicodes: [three-per-em space] [left arrow emoji] [force emoji presentation]
Author = new($"{username}\u2004\u21a9\ufe0f", IconUrl: avatarUrl),
Description = content.ToString()
Description = content.ToString(),
Color = match.Member.Color?.ToDiscordColor(),
};
}

View File

@ -19,7 +19,9 @@ namespace PluralKit.Core
public string? ServerAvatar { get; }
public string? Avatar { get; }
public bool AllowAutoproxy { get; }
public string? Color { get; }
public string ProxyName(MessageContext ctx) => ctx.SystemTag != null
? $"{ServerName ?? DisplayName ?? Name} {ctx.SystemTag}"

View File

@ -68,6 +68,8 @@ create function proxy_members(account_id bigint, guild_id bigint)
server_avatar text,
avatar text,
color char(6),
allow_autoproxy bool
)
as $$
@ -86,6 +88,8 @@ as $$
member_guild.avatar_url as server_avatar,
members.avatar_url as avatar,
members.color as color,
members.allow_autoproxy as allow_autoproxy
from accounts
inner join systems on systems.id = accounts.system