mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
fix(bot): use proxy name format even when tag is disabled/null
This commit is contained in:
parent
b26ca69071
commit
2555f7922c
1 changed files with 4 additions and 6 deletions
|
|
@ -34,18 +34,16 @@ public class ProxyMember
|
||||||
// If not set, this formatting will be applied to the proxy name
|
// If not set, this formatting will be applied to the proxy name
|
||||||
public static string DefaultFormat = "{name} {tag}";
|
public static string DefaultFormat = "{name} {tag}";
|
||||||
|
|
||||||
public static string FormatTag(string template, string tag, string name) => StringUtils.SafeFormat(template, new[] {
|
public static string FormatTag(string template, string? tag, string name) => StringUtils.SafeFormat(template, new[] {
|
||||||
("{tag}", tag),
|
("{tag}", tag ?? ""),
|
||||||
("{name}", name)
|
("{name}", name)
|
||||||
});
|
}).Trim();
|
||||||
|
|
||||||
public string ProxyName(MessageContext ctx)
|
public string ProxyName(MessageContext ctx)
|
||||||
{
|
{
|
||||||
// TODO: if tag is null it should still format but only if it appears in the formatting.
|
|
||||||
var memberName = ServerName ?? DisplayName ?? Name;
|
var memberName = ServerName ?? DisplayName ?? Name;
|
||||||
var tag = ctx.SystemGuildTag ?? ctx.SystemTag;
|
var tag = ctx.SystemGuildTag ?? ctx.SystemTag;
|
||||||
if (!ctx.TagEnabled || tag == null)
|
if (!ctx.TagEnabled) tag = null;
|
||||||
return memberName;
|
|
||||||
|
|
||||||
return FormatTag(ctx.NameFormat ?? DefaultFormat, tag, memberName);
|
return FormatTag(ctx.NameFormat ?? DefaultFormat, tag, memberName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue