fix: show correct name in entityReference when base name is private

This commit is contained in:
spiral 2022-02-05 09:26:14 -05:00
parent 47e501da81
commit 375758206e
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31
8 changed files with 72 additions and 68 deletions

View File

@ -71,10 +71,10 @@ public class GroupMember
if (pctx == LookupContext.ByOwner) if (pctx == LookupContext.ByOwner)
{ {
msg += msg +=
$"\n\nTo add this member to one or more groups, use `pk;m {target.Reference()} group add <group> [group 2] [group 3...]`"; $"\n\nTo add this member to one or more groups, use `pk;m {target.Reference(ctx)} group add <group> [group 2] [group 3...]`";
if (groups.Count > 0) if (groups.Count > 0)
msg += msg +=
$"\nTo remove this member from one or more groups, use `pk;m {target.Reference()} group remove <group> [group 2] [group 3...]`"; $"\nTo remove this member from one or more groups, use `pk;m {target.Reference(ctx)} group remove <group> [group 2] [group 3...]`";
} }
await ctx.Reply(msg, new EmbedBuilder().Title($"{target.Name}'s groups").Description(description).Build()); await ctx.Reply(msg, new EmbedBuilder().Title($"{target.Name}'s groups").Description(description).Build());

View File

@ -81,16 +81,18 @@ public class Groups
EventData = dispatchData EventData = dispatchData
}); });
var reference = newGroup.Reference(ctx);
var eb = new EmbedBuilder() var eb = new EmbedBuilder()
.Description( .Description(
$"Your new group, **{groupName}**, has been created, with the group ID **`{newGroup.Hid}`**.\nBelow are a couple of useful commands:") $"Your new group, **{groupName}**, has been created, with the group ID **`{newGroup.Hid}`**.\nBelow are a couple of useful commands:")
.Field(new Embed.Field("View the group card", $"> pk;group **{newGroup.Reference()}**")) .Field(new Embed.Field("View the group card", $"> pk;group **{reference}**"))
.Field(new Embed.Field("Add members to the group", .Field(new Embed.Field("Add members to the group",
$"> pk;group **{newGroup.Reference()}** add **MemberName**\n> pk;group **{newGroup.Reference()}** add **Member1** **Member2** **Member3** (and so on...)")) $"> pk;group **{reference}** add **MemberName**\n> pk;group **{reference}** add **Member1** **Member2** **Member3** (and so on...)"))
.Field(new Embed.Field("Set the description", .Field(new Embed.Field("Set the description",
$"> pk;group **{newGroup.Reference()}** description **This is my new group, and here is the description!**")) $"> pk;group **{reference}** description **This is my new group, and here is the description!**"))
.Field(new Embed.Field("Set the group icon", .Field(new Embed.Field("Set the group icon",
$"> pk;group **{newGroup.Reference()}** icon\n*(with an image attached)*")); $"> pk;group **{reference}** icon\n*(with an image attached)*"));
await ctx.Reply($"{Emojis.Success} Group created!", eb.Build()); await ctx.Reply($"{Emojis.Success} Group created!", eb.Build());
if (existingGroupCount >= Limits.WarnThreshold(groupLimit)) if (existingGroupCount >= Limits.WarnThreshold(groupLimit))
@ -128,7 +130,7 @@ public class Groups
var noDisplayNameSetMessage = "This group does not have a display name set."; var noDisplayNameSetMessage = "This group does not have a display name set.";
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
noDisplayNameSetMessage += noDisplayNameSetMessage +=
$" To set one, type `pk;group {target.Reference()} displayname <display name>`."; $" To set one, type `pk;group {target.Reference(ctx)} displayname <display name>`.";
// No perms check, display name isn't covered by member privacy // No perms check, display name isn't covered by member privacy
@ -153,11 +155,13 @@ public class Groups
.Field(new Embed.Field("Name", target.Name)) .Field(new Embed.Field("Name", target.Name))
.Field(new Embed.Field("Display Name", target.DisplayName)); .Field(new Embed.Field("Display Name", target.DisplayName));
var reference = target.Reference(ctx);
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
eb.Description( eb.Description(
$"To change display name, type `pk;group {target.Reference()} displayname <display name>`." $"To change display name, type `pk;group {reference} displayname <display name>`."
+ $"To clear it, type `pk;group {target.Reference()} displayname -clear`." + $"To clear it, type `pk;group {reference} displayname -clear`."
+ $"To print the raw display name, type `pk;group {target.Reference()} displayname -raw`."); + $"To print the raw display name, type `pk;group {reference} displayname -raw`.");
await ctx.Reply(embed: eb.Build()); await ctx.Reply(embed: eb.Build());
} }
@ -194,7 +198,7 @@ public class Groups
var noDescriptionSetMessage = "This group does not have a description set."; var noDescriptionSetMessage = "This group does not have a description set.";
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
noDescriptionSetMessage += noDescriptionSetMessage +=
$" To set one, type `pk;group {target.Reference()} description <description>`."; $" To set one, type `pk;group {target.Reference(ctx)} description <description>`.";
if (ctx.MatchRaw()) if (ctx.MatchRaw())
{ {
@ -214,9 +218,9 @@ public class Groups
.Title("Group description") .Title("Group description")
.Description(target.Description) .Description(target.Description)
.Field(new Embed.Field("\u200B", .Field(new Embed.Field("\u200B",
$"To print the description with formatting, type `pk;group {target.Reference()} description -raw`." $"To print the description with formatting, type `pk;group {target.Reference(ctx)} description -raw`."
+ (ctx.System?.Id == target.System + (ctx.System?.Id == target.System
? $" To clear it, type `pk;group {target.Reference()} description -clear`." ? $" To clear it, type `pk;group {target.Reference(ctx)} description -clear`."
: ""))) : "")))
.Build()); .Build());
return; return;
@ -289,7 +293,7 @@ public class Groups
.Image(new Embed.EmbedImage(target.Icon.TryGetCleanCdnUrl())); .Image(new Embed.EmbedImage(target.Icon.TryGetCleanCdnUrl()));
if (target.System == ctx.System?.Id) if (target.System == ctx.System?.Id)
eb.Description($"To clear, use `pk;group {target.Reference()} icon -clear`."); eb.Description($"To clear, use `pk;group {target.Reference(ctx)} icon -clear`.");
await ctx.Reply(embed: eb.Build()); await ctx.Reply(embed: eb.Build());
} }
@ -353,7 +357,7 @@ public class Groups
.Image(new Embed.EmbedImage(target.BannerImage)); .Image(new Embed.EmbedImage(target.BannerImage));
if (target.System == ctx.System?.Id) if (target.System == ctx.System?.Id)
eb.Description($"To clear, use `pk;group {target.Reference()} banner clear`."); eb.Description($"To clear, use `pk;group {target.Reference(ctx)} banner clear`.");
await ctx.Reply(embed: eb.Build()); await ctx.Reply(embed: eb.Build());
} }
@ -389,7 +393,7 @@ public class Groups
if (target.Color == null) if (target.Color == null)
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
await ctx.Reply( await ctx.Reply(
$"This group does not have a color set. To set one, type `pk;group {target.Reference()} color <color>`."); $"This group does not have a color set. To set one, type `pk;group {target.Reference(ctx)} color <color>`.");
else else
await ctx.Reply("This group does not have a color set."); await ctx.Reply("This group does not have a color set.");
else else
@ -399,7 +403,7 @@ public class Groups
.Thumbnail(new Embed.EmbedThumbnail($"https://fakeimg.pl/256x256/{target.Color}/?text=%20")) .Thumbnail(new Embed.EmbedThumbnail($"https://fakeimg.pl/256x256/{target.Color}/?text=%20"))
.Description($"This group's color is **#{target.Color}**." .Description($"This group's color is **#{target.Color}**."
+ (ctx.System?.Id == target.System + (ctx.System?.Id == target.System
? $" To clear it, type `pk;group {target.Reference()} color -clear`." ? $" To clear it, type `pk;group {target.Reference(ctx)} color -clear`."
: "")) : ""))
.Build()); .Build());
} }
@ -481,7 +485,7 @@ public class Groups
.Field(new Embed.Field("Metadata (creation date)", target.MetadataPrivacy.Explanation())) .Field(new Embed.Field("Metadata (creation date)", target.MetadataPrivacy.Explanation()))
.Field(new Embed.Field("Visibility", target.Visibility.Explanation())) .Field(new Embed.Field("Visibility", target.Visibility.Explanation()))
.Description( .Description(
$"To edit privacy settings, use the command:\n> pk;group **{target.Reference()}** privacy **<subject>** **<level>**\n\n- `subject` is one of `name`, `description`, `icon`, `members`, `metadata`, `visibility`, or `all`\n- `level` is either `public` or `private`.") $"To edit privacy settings, use the command:\n> pk;group **{target.Reference(ctx)}** privacy **<subject>** **<level>**\n\n- `subject` is one of `name`, `description`, `icon`, `members`, `metadata`, `visibility`, or `all`\n- `level` is either `public` or `private`.")
.Build()); .Build());
return; return;
} }

View File

@ -30,7 +30,7 @@ public class MemberAvatar
{ {
if (mgs?.AvatarUrl != null) if (mgs?.AvatarUrl != null)
await ctx.Reply( await ctx.Reply(
$"{Emojis.Success} Member avatar cleared. Note that this member has a server-specific avatar set here, type `pk;member {target.Reference()} serveravatar clear` if you wish to clear that too."); $"{Emojis.Success} Member avatar cleared. Note that this member has a server-specific avatar set here, type `pk;member {target.Reference(ctx)} serveravatar clear` if you wish to clear that too.");
else else
await ctx.Reply($"{Emojis.Success} Member avatar cleared."); await ctx.Reply($"{Emojis.Success} Member avatar cleared.");
} }
@ -57,7 +57,7 @@ public class MemberAvatar
if (location == AvatarLocation.Server) if (location == AvatarLocation.Server)
throw new PKError( throw new PKError(
$"This member does not have a server avatar set. Type `pk;member {target.Reference()} avatar` to see their global avatar."); $"This member does not have a server avatar set. Type `pk;member {target.Reference(ctx)} avatar` to see their global avatar.");
} }
var field = location == AvatarLocation.Server ? $"server avatar (for {ctx.Guild.Name})" : "avatar"; var field = location == AvatarLocation.Server ? $"server avatar (for {ctx.Guild.Name})" : "avatar";
@ -67,7 +67,7 @@ public class MemberAvatar
.Title($"{target.NameFor(ctx)}'s {field}") .Title($"{target.NameFor(ctx)}'s {field}")
.Image(new Embed.EmbedImage(currentValue?.TryGetCleanCdnUrl())); .Image(new Embed.EmbedImage(currentValue?.TryGetCleanCdnUrl()));
if (target.System == ctx.System?.Id) if (target.System == ctx.System?.Id)
eb.Description($"To clear, use `pk;member {target.Reference()} {cmd} clear`."); eb.Description($"To clear, use `pk;member {target.Reference(ctx)} {cmd} clear`.");
await ctx.Reply(embed: eb.Build()); await ctx.Reply(embed: eb.Build());
} }

View File

@ -66,7 +66,7 @@ public class MemberEdit
var noDescriptionSetMessage = "This member does not have a description set."; var noDescriptionSetMessage = "This member does not have a description set.";
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
noDescriptionSetMessage += noDescriptionSetMessage +=
$" To set one, type `pk;member {target.Reference()} description <description>`."; $" To set one, type `pk;member {target.Reference(ctx)} description <description>`.";
if (ctx.MatchRaw()) if (ctx.MatchRaw())
{ {
@ -86,9 +86,9 @@ public class MemberEdit
.Title("Member description") .Title("Member description")
.Description(target.Description) .Description(target.Description)
.Field(new Embed.Field("\u200B", .Field(new Embed.Field("\u200B",
$"To print the description with formatting, type `pk;member {target.Reference()} description -raw`." $"To print the description with formatting, type `pk;member {target.Reference(ctx)} description -raw`."
+ (ctx.System?.Id == target.System + (ctx.System?.Id == target.System
? $" To clear it, type `pk;member {target.Reference()} description -clear`." ? $" To clear it, type `pk;member {target.Reference(ctx)} description -clear`."
: ""))) : "")))
.Build()); .Build());
return; return;
@ -119,7 +119,7 @@ public class MemberEdit
{ {
var noPronounsSetMessage = "This member does not have pronouns set."; var noPronounsSetMessage = "This member does not have pronouns set.";
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
noPronounsSetMessage += $"To set some, type `pk;member {target.Reference()} pronouns <pronouns>`."; noPronounsSetMessage += $"To set some, type `pk;member {target.Reference(ctx)} pronouns <pronouns>`.";
ctx.CheckSystemPrivacy(target.System, target.PronounPrivacy); ctx.CheckSystemPrivacy(target.System, target.PronounPrivacy);
@ -138,9 +138,9 @@ public class MemberEdit
await ctx.Reply(noPronounsSetMessage); await ctx.Reply(noPronounsSetMessage);
else else
await ctx.Reply( await ctx.Reply(
$"**{target.NameFor(ctx)}**'s pronouns are **{target.Pronouns}**.\nTo print the pronouns with formatting, type `pk;member {target.Reference()} pronouns -raw`." $"**{target.NameFor(ctx)}**'s pronouns are **{target.Pronouns}**.\nTo print the pronouns with formatting, type `pk;member {target.Reference(ctx)} pronouns -raw`."
+ (ctx.System?.Id == target.System + (ctx.System?.Id == target.System
? $" To clear them, type `pk;member {target.Reference()} pronouns -clear`." ? $" To clear them, type `pk;member {target.Reference(ctx)} pronouns -clear`."
: "")); : ""));
return; return;
} }
@ -243,7 +243,7 @@ public class MemberEdit
if (target.Color == null) if (target.Color == null)
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
await ctx.Reply( await ctx.Reply(
$"This member does not have a color set. To set one, type `pk;member {target.Reference()} color <color>`."); $"This member does not have a color set. To set one, type `pk;member {target.Reference(ctx)} color <color>`.");
else else
await ctx.Reply("This member does not have a color set."); await ctx.Reply("This member does not have a color set.");
else else
@ -253,7 +253,7 @@ public class MemberEdit
.Thumbnail(new Embed.EmbedThumbnail($"https://fakeimg.pl/256x256/{target.Color}/?text=%20")) .Thumbnail(new Embed.EmbedThumbnail($"https://fakeimg.pl/256x256/{target.Color}/?text=%20"))
.Description($"This member's color is **#{target.Color}**." .Description($"This member's color is **#{target.Color}**."
+ (ctx.System?.Id == target.System + (ctx.System?.Id == target.System
? $" To clear it, type `pk;member {target.Reference()} color -clear`." ? $" To clear it, type `pk;member {target.Reference(ctx)} color -clear`."
: "")) : ""))
.Build()); .Build());
} }
@ -293,12 +293,12 @@ public class MemberEdit
if (target.Birthday == null) if (target.Birthday == null)
await ctx.Reply("This member does not have a birthdate set." await ctx.Reply("This member does not have a birthdate set."
+ (ctx.System?.Id == target.System + (ctx.System?.Id == target.System
? $" To set one, type `pk;member {target.Reference()} birthdate <birthdate>`." ? $" To set one, type `pk;member {target.Reference(ctx)} birthdate <birthdate>`."
: "")); : ""));
else else
await ctx.Reply($"This member's birthdate is **{target.BirthdayString}**." await ctx.Reply($"This member's birthdate is **{target.BirthdayString}**."
+ (ctx.System?.Id == target.System + (ctx.System?.Id == target.System
? $" To clear it, type `pk;member {target.Reference()} birthdate -clear`." ? $" To clear it, type `pk;member {target.Reference(ctx)} birthdate -clear`."
: "")); : ""));
} }
else else
@ -322,6 +322,7 @@ public class MemberEdit
} }
} }
private string boldIf(string str, bool condition) => condition ? $"**{str}**" : str;
private async Task<EmbedBuilder> CreateMemberNameInfoEmbed(Context ctx, PKMember target) private async Task<EmbedBuilder> CreateMemberNameInfoEmbed(Context ctx, PKMember target)
{ {
var lcx = ctx.LookupContextFor(target.System); var lcx = ctx.LookupContextFor(target.System);
@ -335,28 +336,25 @@ public class MemberEdit
.Footer(new Embed.EmbedFooter( .Footer(new Embed.EmbedFooter(
$"Member ID: {target.Hid} | Active name in bold. Server name overrides display name, which overrides base name.")); $"Member ID: {target.Hid} | Active name in bold. Server name overrides display name, which overrides base name."));
if (target.DisplayName == null && memberGuildConfig?.DisplayName == null) var showDisplayName = target.NamePrivacy.CanAccess(lcx);
eb.Field(new Embed.Field("Name", $"**{target.NameFor(ctx)}**"));
else
eb.Field(new Embed.Field("Name", target.NameFor(ctx)));
if (target.NamePrivacy.CanAccess(lcx)) eb.Field(new Embed.Field("Name", boldIf(
{ target.NameFor(ctx),
if (target.DisplayName != null && memberGuildConfig?.DisplayName == null) (!showDisplayName || target.DisplayName == null) && memberGuildConfig?.DisplayName == null
eb.Field(new Embed.Field("Display Name", $"**{target.DisplayName}**")); )));
else
eb.Field(new Embed.Field("Display Name", target.DisplayName ?? "*(none)*")); if (showDisplayName)
} eb.Field(new Embed.Field("Display name", target.DisplayName != null
? boldIf(target.DisplayName, memberGuildConfig?.DisplayName == null)
: "*(none)*"
));
if (ctx.Guild != null) if (ctx.Guild != null)
{
if (memberGuildConfig?.DisplayName != null)
eb.Field(new Embed.Field($"Server Name (in {ctx.Guild.Name})", eb.Field(new Embed.Field($"Server Name (in {ctx.Guild.Name})",
$"**{memberGuildConfig.DisplayName}**")); memberGuildConfig?.DisplayName != null
else ? $"**{memberGuildConfig.DisplayName}**"
eb.Field(new Embed.Field($"Server Name (in {ctx.Guild.Name})", : "*(none)*"
memberGuildConfig?.DisplayName ?? "*(none)*")); ));
}
return eb; return eb;
} }
@ -380,7 +378,7 @@ public class MemberEdit
var noDisplayNameSetMessage = "This member does not have a display name set."; var noDisplayNameSetMessage = "This member does not have a display name set.";
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
noDisplayNameSetMessage += noDisplayNameSetMessage +=
$" To set one, type `pk;member {target.Reference()} displayname <display name>`."; $" To set one, type `pk;member {target.Reference(ctx)} displayname <display name>`.";
// No perms check, display name isn't covered by member privacy // No perms check, display name isn't covered by member privacy
@ -396,11 +394,12 @@ public class MemberEdit
if (!ctx.HasNext(false)) if (!ctx.HasNext(false))
{ {
var eb = await CreateMemberNameInfoEmbed(ctx, target); var eb = await CreateMemberNameInfoEmbed(ctx, target);
var reference = target.Reference(ctx);
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
eb.Description( eb.Description(
$"To change display name, type `pk;member {target.Reference()} displayname <display name>`." $"To change display name, type `pk;member {reference} displayname <display name>`."
+ $"To clear it, type `pk;member {target.Reference()} displayname -clear`." + $"To clear it, type `pk;member {reference} displayname -clear`."
+ $"To print the raw display name, type `pk;member {target.Reference()} displayname -raw`."); + $"To print the raw display name, type `pk;member {reference} displayname -raw`.");
await ctx.Reply(embed: eb.Build()); await ctx.Reply(embed: eb.Build());
return; return;
} }
@ -437,7 +436,7 @@ public class MemberEdit
var noServerNameSetMessage = "This member does not have a server name set."; var noServerNameSetMessage = "This member does not have a server name set.";
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
noServerNameSetMessage += noServerNameSetMessage +=
$" To set one, type `pk;member {target.Reference()} servername <server name>`."; $" To set one, type `pk;member {target.Reference(ctx)} servername <server name>`.";
// No perms check, display name isn't covered by member privacy // No perms check, display name isn't covered by member privacy
var memberGuildConfig = await ctx.Repository.GetMemberGuild(ctx.Guild.Id, target.Id); var memberGuildConfig = await ctx.Repository.GetMemberGuild(ctx.Guild.Id, target.Id);
@ -454,9 +453,10 @@ public class MemberEdit
if (!ctx.HasNext(false)) if (!ctx.HasNext(false))
{ {
var eb = await CreateMemberNameInfoEmbed(ctx, target); var eb = await CreateMemberNameInfoEmbed(ctx, target);
var reference = target.Reference(ctx);
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
eb.Description( eb.Description(
$"To change server name, type `pk;member {target.Reference()} servername <server name>`.\nTo clear it, type `pk;member {target.Reference()} servername -clear`.\nTo print the raw server name, type `pk;member {target.Reference()} servername -raw`."); $"To change server name, type `pk;member {reference} servername <server name>`.\nTo clear it, type `pk;member {reference} servername -clear`.\nTo print the raw server name, type `pk;member {reference} servername -raw`.");
await ctx.Reply(embed: eb.Build()); await ctx.Reply(embed: eb.Build());
return; return;
} }
@ -658,7 +658,7 @@ public class MemberEdit
if (subject == MemberPrivacySubject.Avatar && level == PrivacyLevel.Private && if (subject == MemberPrivacySubject.Avatar && level == PrivacyLevel.Private &&
guildSettings?.AvatarUrl == null) guildSettings?.AvatarUrl == null)
await ctx.Reply( await ctx.Reply(
$"{Emojis.Warn} This member does not have a server avatar set, so *proxying* will **still show the member avatar**. If you want to hide your avatar when proxying here, set a server avatar: `pk;member {target.Reference()} serveravatar`"); $"{Emojis.Warn} This member does not have a server avatar set, so *proxying* will **still show the member avatar**. If you want to hide your avatar when proxying here, set a server avatar: `pk;member {target.Reference(ctx)} serveravatar`");
} }
if (ctx.Match("all") || newValueFromCommand != null) if (ctx.Match("all") || newValueFromCommand != null)

View File

@ -64,7 +64,7 @@ public class MemberProxy
throw new PKSyntaxError("You must pass an example proxy to add (eg. `[text]` or `J:text`)."); throw new PKSyntaxError("You must pass an example proxy to add (eg. `[text]` or `J:text`).");
var tagToAdd = ParseProxyTags(ctx.RemainderOrNull(false)); var tagToAdd = ParseProxyTags(ctx.RemainderOrNull(false));
if (tagToAdd.IsEmpty) throw Errors.EmptyProxyTags(target); if (tagToAdd.IsEmpty) throw Errors.EmptyProxyTags(target, ctx);
if (target.ProxyTags.Contains(tagToAdd)) if (target.ProxyTags.Contains(tagToAdd))
throw Errors.ProxyTagAlreadyExists(tagToAdd, target); throw Errors.ProxyTagAlreadyExists(tagToAdd, target);
if (tagToAdd.ProxyString.Length > Limits.MaxProxyTagLength) if (tagToAdd.ProxyString.Length > Limits.MaxProxyTagLength)
@ -88,7 +88,7 @@ public class MemberProxy
throw new PKSyntaxError("You must pass a proxy tag to remove (eg. `[text]` or `J:text`)."); throw new PKSyntaxError("You must pass a proxy tag to remove (eg. `[text]` or `J:text`).");
var tagToRemove = ParseProxyTags(ctx.RemainderOrNull(false)); var tagToRemove = ParseProxyTags(ctx.RemainderOrNull(false));
if (tagToRemove.IsEmpty) throw Errors.EmptyProxyTags(target); if (tagToRemove.IsEmpty) throw Errors.EmptyProxyTags(target, ctx);
if (!target.ProxyTags.Contains(tagToRemove)) if (!target.ProxyTags.Contains(tagToRemove))
throw Errors.ProxyTagDoesNotExist(tagToRemove, target); throw Errors.ProxyTagDoesNotExist(tagToRemove, target);
@ -103,7 +103,7 @@ public class MemberProxy
else else
{ {
var requestedTag = ParseProxyTags(ctx.RemainderOrNull(false)); var requestedTag = ParseProxyTags(ctx.RemainderOrNull(false));
if (requestedTag.IsEmpty) throw Errors.EmptyProxyTags(target); if (requestedTag.IsEmpty) throw Errors.EmptyProxyTags(target, ctx);
// This is mostly a legacy command, so it's gonna warn if there's // This is mostly a legacy command, so it's gonna warn if there's
// already more than one proxy tag. // already more than one proxy tag.

View File

@ -170,11 +170,11 @@ public static class Errors
public static PKError ProxyTagDoesNotExist(ProxyTag tagToRemove, PKMember member) => new( public static PKError ProxyTagDoesNotExist(ProxyTag tagToRemove, PKMember member) => new(
$"That member does not have the proxy tag {tagToRemove.ProxyString.AsCode()}. The member currently has these tags: {member.ProxyTagsString()}"); $"That member does not have the proxy tag {tagToRemove.ProxyString.AsCode()}. The member currently has these tags: {member.ProxyTagsString()}");
public static PKError LegacyAlreadyHasProxyTag(ProxyTag requested, PKMember member) => new( public static PKError LegacyAlreadyHasProxyTag(ProxyTag requested, PKMember member, Context ctx) => new(
$"This member already has more than one proxy tag set: {member.ProxyTagsString()}\nConsider using the {$"pk;member {member.Reference()} proxy add {requested.ProxyString}".AsCode()} command instead."); $"This member already has more than one proxy tag set: {member.ProxyTagsString()}\nConsider using the {$"pk;member {member.Reference(ctx)} proxy add {requested.ProxyString}".AsCode()} command instead.");
public static PKError EmptyProxyTags(PKMember member) => new( public static PKError EmptyProxyTags(PKMember member, Context ctx) => new(
$"The example proxy `text` is equivalent to having no proxy tags at all, since there are no symbols or brackets on either end. If you'd like to clear your proxy tags, use `pk;member {member.Reference()} proxy clear`."); $"The example proxy `text` is equivalent to having no proxy tags at all, since there are no symbols or brackets on either end. If you'd like to clear your proxy tags, use `pk;member {member.Reference(ctx)} proxy clear`.");
public static PKError GenericCancelled() => new("Operation cancelled."); public static PKError GenericCancelled() => new("Operation cancelled.");

View File

@ -279,11 +279,11 @@ public class EmbedService
if (memberCount == 0 && pctx == LookupContext.ByOwner) if (memberCount == 0 && pctx == LookupContext.ByOwner)
// Only suggest the add command if this is actually the owner lol // Only suggest the add command if this is actually the owner lol
eb.Field(new Embed.Field("Members (0)", eb.Field(new Embed.Field("Members (0)",
$"Add one with `pk;group {target.Reference()} add <member>`!")); $"Add one with `pk;group {target.Reference(ctx)} add <member>`!"));
else else
{ {
var name = pctx == LookupContext.ByOwner var name = pctx == LookupContext.ByOwner
? target.Reference() ? target.Reference(ctx)
: target.Hid; : target.Hid;
eb.Field(new Embed.Field($"Members ({memberCount})", $"(see `pk;group {name} list`)")); eb.Field(new Embed.Field($"Members ({memberCount})", $"(see `pk;group {name} list`)"));
} }

View File

@ -21,8 +21,8 @@ public static class ModelUtils
public static string DisplayName(this PKMember member) => public static string DisplayName(this PKMember member) =>
member.DisplayName ?? member.Name; member.DisplayName ?? member.Name;
public static string Reference(this PKMember member) => EntityReference(member.Hid, member.Name); public static string Reference(this PKMember member, Context ctx) => EntityReference(member.Hid, member.NameFor(ctx));
public static string Reference(this PKGroup group) => EntityReference(group.Hid, group.Name); public static string Reference(this PKGroup group, Context ctx) => EntityReference(group.Hid, group.NameFor(ctx));
private static string EntityReference(string hid, string name) private static string EntityReference(string hid, string name)
{ {