Move proxy name/avatar logic to the bot itself

This commit is contained in:
Ske 2020-06-12 23:24:36 +02:00
parent 3d62a0d33c
commit 2a39489c4d
2 changed files with 34 additions and 10 deletions

View File

@ -11,7 +11,20 @@ namespace PluralKit.Core
public int Id { get; set; } public int Id { get; set; }
public IReadOnlyCollection<ProxyTag> ProxyTags { get; set; } = new ProxyTag[0]; public IReadOnlyCollection<ProxyTag> ProxyTags { get; set; } = new ProxyTag[0];
public bool KeepProxy { get; set; } public bool KeepProxy { get; set; }
public string ProxyName { get; set; } = "";
public string? ProxyAvatar { get; set; } public string? ServerName { get; set; }
public string? DisplayName { get; set; }
public string Name { get; set; } = "";
public string? SystemTag { get; set; }
public string? ServerAvatar { get; set; }
public string? Avatar { get; set; }
public string? SystemIcon { get; set; }
public string ProxyName => SystemTag != null
? $"{ServerName ?? DisplayName ?? Name} {SystemTag}"
: ServerName ?? DisplayName ?? Name;
public string? ProxyAvatar => ServerAvatar ?? Avatar ?? SystemIcon;
} }
} }

View File

@ -49,8 +49,15 @@ create function proxy_members(account_id bigint, guild_id bigint)
id int, id int,
proxy_tags proxy_tag[], proxy_tags proxy_tag[],
keep_proxy bool, keep_proxy bool,
proxy_name text,
proxy_avatar text server_name text,
display_name text,
name text,
system_tag text,
server_avatar text,
avatar text,
system_icon text
) )
as $$ as $$
select select
@ -59,12 +66,16 @@ as $$
members.proxy_tags as proxy_tags, members.proxy_tags as proxy_tags,
members.keep_proxy as keep_proxy, members.keep_proxy as keep_proxy,
-- Proxy info -- Name info
case member_guild.display_name as server_name,
when systems.tag is not null then (coalesce(member_guild.display_name, members.display_name, members.name) || ' ' || systems.tag) members.display_name as display_name,
else coalesce(member_guild.display_name, members.display_name, members.name) members.name as name,
end as proxy_name, systems.tag as system_tag,
coalesce(member_guild.avatar_url, members.avatar_url, systems.avatar_url) as proxy_avatar
-- Avatar info
member_guild.avatar_url as server_avatar,
members.avatar_url as avatar,
systems.avatar_url as system_icon
from accounts from accounts
inner join systems on systems.id = accounts.system inner join systems on systems.id = accounts.system
inner join members on members.system = systems.id inner join members on members.system = systems.id