feat: show character amount for string fields

This commit is contained in:
Jake Fulmine 2022-08-27 11:25:44 +02:00
parent e23b1048c9
commit c77b2bb4fc
4 changed files with 32 additions and 22 deletions

View File

@ -118,7 +118,7 @@ public class Groups
await ctx.Repository.UpdateGroup(target.Id, new GroupPatch { Name = newName });
await ctx.Reply($"{Emojis.Success} Group name changed from **{target.Name}** to **{newName}**.");
await ctx.Reply($"{Emojis.Success} Group name changed from **{target.Name}** to **{newName}** (using {newName.Length}/{Limits.MaxGroupNameLength} characters).");
}
public async Task GroupDisplayName(Context ctx, PKGroup target)
@ -159,6 +159,8 @@ public class Groups
+ $"To clear it, type `pk;group {reference} displayname -clear`."
+ $"To print the raw display name, type `pk;group {reference} displayname -raw`.");
eb.Footer(new Embed.EmbedFooter($"Using {target.DisplayName.Length}/{Limits.MaxGroupNameLength} characters."));
await ctx.Reply(embed: eb.Build());
}
@ -183,7 +185,7 @@ public class Groups
var patch = new GroupPatch { DisplayName = Partial<string>.Present(newDisplayName) };
await ctx.Repository.UpdateGroup(target.Id, patch);
await ctx.Reply($"{Emojis.Success} Group display name changed.");
await ctx.Reply($"{Emojis.Success} Group display name changed (using {newDisplayName.Length}/{Limits.MaxGroupNameLength} characters).");
}
}
@ -217,7 +219,8 @@ public class Groups
$"To print the description with formatting, type `pk;group {target.Reference(ctx)} description -raw`."
+ (ctx.System?.Id == target.System
? $" To clear it, type `pk;group {target.Reference(ctx)} description -clear`."
: "")))
: "")
+ $" Using {target.Description.Length}/{Limits.MaxDescriptionLength} characters."))
.Build());
return;
}
@ -239,7 +242,7 @@ public class Groups
var patch = new GroupPatch { Description = Partial<string>.Present(description) };
await ctx.Repository.UpdateGroup(target.Id, patch);
await ctx.Reply($"{Emojis.Success} Group description changed.");
await ctx.Reply($"{Emojis.Success} Group description changed (using {description.Length}/{Limits.MaxDescriptionLength} characters).");
}
}

View File

@ -42,7 +42,7 @@ public class MemberEdit
var patch = new MemberPatch { Name = Partial<string>.Present(newName) };
await ctx.Repository.UpdateMember(target.Id, patch);
await ctx.Reply($"{Emojis.Success} Member renamed.");
await ctx.Reply($"{Emojis.Success} Member renamed (using {newName.Length}/{Limits.MaxMemberNameLength} characters).");
if (newName.Contains(" "))
await ctx.Reply(
$"{Emojis.Note} Note that this member's name now contains spaces. You will need to surround it with \"double quotes\" when using commands referring to it.");
@ -89,7 +89,8 @@ public class MemberEdit
$"To print the description with formatting, type `pk;member {target.Reference(ctx)} description -raw`."
+ (ctx.System?.Id == target.System
? $" To clear it, type `pk;member {target.Reference(ctx)} description -clear`."
: "")))
: "")
+ $" Using {target.Description.Length}/{Limits.MaxDescriptionLength} characters."))
.Build());
return;
}
@ -111,7 +112,7 @@ public class MemberEdit
var patch = new MemberPatch { Description = Partial<string>.Present(description) };
await ctx.Repository.UpdateMember(target.Id, patch);
await ctx.Reply($"{Emojis.Success} Member description changed.");
await ctx.Reply($"{Emojis.Success} Member description changed (using {description.Length}/{Limits.MaxDescriptionLength} characters).");
}
}
@ -141,7 +142,8 @@ public class MemberEdit
$"**{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
? $" To clear them, type `pk;member {target.Reference(ctx)} pronouns -clear`."
: ""));
: "")
+ $" Using {target.Pronouns.Length}/{Limits.MaxPronounsLength} characters.");
return;
}
@ -162,7 +164,7 @@ public class MemberEdit
var patch = new MemberPatch { Pronouns = Partial<string>.Present(pronouns) };
await ctx.Repository.UpdateMember(target.Id, patch);
await ctx.Reply($"{Emojis.Success} Member pronouns changed.");
await ctx.Reply($"{Emojis.Success} Member pronouns changed (using {pronouns.Length}/{Limits.MaxPronounsLength} characters).");
}
}
@ -333,7 +335,9 @@ public class MemberEdit
var eb = new EmbedBuilder()
.Title("Member names")
.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."
+ (target.DisplayName != null ? $" Using {target.DisplayName.Length}/{Limits.MaxMemberNameLength} characters for the display name." : "")
+ (memberGuildConfig?.DisplayName != null ? $" Using {memberGuildConfig?.DisplayName.Length}/{Limits.MaxMemberNameLength} characters for the server name." : "")));
var showDisplayName = target.NamePrivacy.CanAccess(lcx);
@ -423,7 +427,7 @@ public class MemberEdit
await ctx.Repository.UpdateMember(target.Id, patch);
await PrintSuccess(
$"{Emojis.Success} Member display name changed. This member will now be proxied using the name \"{newDisplayName}\".");
$"{Emojis.Success} Member display name changed (using {newDisplayName.Length}/{Limits.MaxMemberNameLength} characters). This member will now be proxied using the name \"{newDisplayName}\".");
}
}
@ -480,7 +484,7 @@ public class MemberEdit
new MemberGuildPatch { DisplayName = newServerName });
await ctx.Reply(
$"{Emojis.Success} Member server name changed. This member will now be proxied using the name \"{newServerName}\" in this server ({ctx.Guild.Name}).");
$"{Emojis.Success} Member server name changed (using {newServerName.Length}/{Limits.MaxMemberNameLength} characters). This member will now be proxied using the name \"{newServerName}\" in this server ({ctx.Guild.Name}).");
}
}

View File

@ -79,7 +79,7 @@ public class MemberProxy
var patch = new MemberPatch { ProxyTags = Partial<ProxyTag[]>.Present(newTags.ToArray()) };
await ctx.Repository.UpdateMember(target.Id, patch);
await ctx.Reply($"{Emojis.Success} Added proxy tags {tagToAdd.ProxyString.AsCode()}.");
await ctx.Reply($"{Emojis.Success} Added proxy tags {tagToAdd.ProxyString.AsCode()} (using {tagToAdd.ProxyString.Length}/{Limits.MaxProxyTagLength} characters).");
}
// Subcommand: "remove"
else if (ctx.Match("remove", "delete"))
@ -121,7 +121,7 @@ public class MemberProxy
var patch = new MemberPatch { ProxyTags = Partial<ProxyTag[]>.Present(newTags) };
await ctx.Repository.UpdateMember(target.Id, patch);
await ctx.Reply($"{Emojis.Success} Member proxy tags set to {requestedTag.ProxyString.AsCode()}.");
await ctx.Reply($"{Emojis.Success} Member proxy tags set to {requestedTag.ProxyString.AsCode()} (using {requestedTag.ProxyString.Length}/{Limits.MaxProxyTagLength} characters).");
}
}
}

View File

@ -48,7 +48,8 @@ public class SystemEdit
if (target.Name != null)
await ctx.Reply(
$"{(isOwnSystem ? "Your" : "This")} system's name is currently **{target.Name}**."
+ (isOwnSystem ? " Type `pk;system name -clear` to clear it." : ""));
+ (isOwnSystem ? " Type `pk;system name -clear` to clear it." : "")
+ $" Using {target.Name.Length}/{Limits.MaxSystemNameLength} characters.");
else
await ctx.Reply(noNameSetMessage);
return;
@ -71,7 +72,7 @@ public class SystemEdit
await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { Name = newSystemName });
await ctx.Reply($"{Emojis.Success} System name changed.");
await ctx.Reply($"{Emojis.Success} System name changed (using {newSystemName.Length}/{Limits.MaxSystemNameLength} characters).");
}
}
@ -104,7 +105,8 @@ public class SystemEdit
.Description(target.Description)
.Footer(new Embed.EmbedFooter(
"To print the description with formatting, type `pk;s description -raw`."
+ (isOwnSystem ? "To clear it, type `pk;s description -clear`. To change it, type `pk;s description <new description>`." : "")))
+ (isOwnSystem ? " To clear it, type `pk;s description -clear`. To change it, type `pk;s description <new description>`." : "")
+ $" Using {target.Description.Length}/{Limits.MaxDescriptionLength} characters."))
.Build());
return;
}
@ -125,7 +127,7 @@ public class SystemEdit
await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { Description = newDescription });
await ctx.Reply($"{Emojis.Success} System description changed.");
await ctx.Reply($"{Emojis.Success} System description changed (using {newDescription.Length}/{Limits.MaxDescriptionLength} characters).");
}
}
@ -224,7 +226,7 @@ public class SystemEdit
await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { Tag = newTag });
await ctx.Reply(
$"{Emojis.Success} System tag changed. Member names will now end with {newTag.AsCode()} when proxied.");
$"{Emojis.Success} System tag changed (using {newTag.Length}/{Limits.MaxSystemTagLength} characters). Member names will now end with {newTag.AsCode()} when proxied.");
}
}
@ -275,7 +277,7 @@ public class SystemEdit
await ctx.Repository.UpdateSystemGuild(target.Id, ctx.Guild.Id, new SystemGuildPatch { Tag = newTag });
await ctx.Reply(
$"{Emojis.Success} System server tag changed. Member names will now end with {newTag.AsCode()} when proxied in the current server '{ctx.Guild.Name}'.");
$"{Emojis.Success} System server tag changed (using {newTag.Length}/{Limits.MaxSystemTagLength} characters). Member names will now end with {newTag.AsCode()} when proxied in the current server '{ctx.Guild.Name}'.");
if (!settings.TagEnabled)
await ctx.Reply(setDisabledWarning);
@ -375,7 +377,8 @@ public class SystemEdit
else
await ctx.Reply($"{(isOwnSystem ? "Your" : "This system's")} current pronouns are **{target.Pronouns}**.\nTo print the pronouns with formatting, type `pk;system pronouns -raw`."
+ (isOwnSystem ? " To clear them, type `pk;system pronouns -clear`."
: ""));
: "")
+ $" Using {target.Pronouns.Length}/{Limits.MaxPronounsLength} characters.");
return;
}
@ -397,7 +400,7 @@ public class SystemEdit
await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { Pronouns = newPronouns });
await ctx.Reply(
$"{Emojis.Success} System pronouns changed.");
$"{Emojis.Success} System pronouns changed (using {newPronouns.Length}/{Limits.MaxPronounsLength} characters).");
}
}