fix(bot): format ids correctly in a few places

This commit is contained in:
alyssa 2024-05-11 21:32:16 +09:00
parent f6fceffc3f
commit c3a30a59cd
7 changed files with 13 additions and 13 deletions

View file

@ -240,7 +240,7 @@ public class Admin
var existingAccount = await ctx.Repository.GetSystemByAccount(account.Id);
if (existingAccount != null)
throw Errors.AccountInOtherSystem(existingAccount);
throw Errors.AccountInOtherSystem(existingAccount, ctx.Config);
var system = await ctx.Repository.GetSystem(systemId.Value!);

View file

@ -40,7 +40,7 @@ public class Member
var existingMember = await ctx.Repository.GetMemberByName(ctx.System.Id, memberName);
if (existingMember != null)
{
var msg = $"{Emojis.Warn} You already have a member in your system with the name \"{existingMember.NameFor(ctx)}\" (with ID `{existingMember.Hid}`). Do you want to create another member with the same name?";
var msg = $"{Emojis.Warn} You already have a member in your system with the name \"{existingMember.NameFor(ctx)}\" (with ID `{existingMember.DisplayHid(ctx.Config)}`). Do you want to create another member with the same name?";
if (!await ctx.PromptYesNo(msg, "Create")) throw new PKError("Member creation cancelled.");
}

View file

@ -339,7 +339,7 @@ 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.DisplayHid(ctx.Config)} | Active name in bold. Server name overrides display name, which overrides base name."
+ (target.DisplayName != null && ctx.System?.Id == target.System ? $" 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." : "")));

View file

@ -76,7 +76,7 @@ public class SystemFront
var members = await ctx.Database.Execute(c => ctx.Repository.GetSwitchMembers(c, sw.Id)).ToListAsync();
var membersStr = members.Any()
? string.Join(", ", members.Select(m => $"**{m.NameFor(ctx)}**{(showMemberId ? $" (`{m.Hid}`)" : "")}"))
? string.Join(", ", members.Select(m => $"**{m.NameFor(ctx)}**{(showMemberId ? $" (`{m.DisplayHid(ctx.Config)}`)" : "")}"))
: "**no fronter**";
var switchSince = SystemClock.Instance.GetCurrentInstant() - sw.Timestamp;
@ -138,13 +138,13 @@ public class SystemFront
if (ctx.Guild != null)
guildSettings = await ctx.Repository.GetSystemGuild(ctx.Guild.Id, system.Id);
if (group != null)
title.Append($"{group.NameFor(ctx)} (`{group.Hid}`)");
title.Append($"{group.NameFor(ctx)} (`{group.DisplayHid(ctx.Config)}`)");
else if (ctx.Guild != null && guildSettings.DisplayName != null)
title.Append($"{guildSettings.DisplayName} (`{system.Hid}`)");
title.Append($"{guildSettings.DisplayName} (`{system.DisplayHid(ctx.Config)}`)");
else if (system.NameFor(ctx) != null)
title.Append($"{system.NameFor(ctx)} (`{system.Hid}`)");
title.Append($"{system.NameFor(ctx)} (`{system.DisplayHid(ctx.Config)}`)");
else
title.Append($"`{system.Hid}`");
title.Append($"`{system.DisplayHid(ctx.Config)}`");
var frontpercent = await ctx.Database.Execute(c => ctx.Repository.GetFrontBreakdown(c, system.Id, group?.Id, rangeStart.Value.ToInstant(), now));
await ctx.Reply(embed: await _embeds.CreateFrontPercentEmbed(frontpercent, system, group, ctx.Zone,

View file

@ -18,7 +18,7 @@ public class SystemLink
var existingAccount = await ctx.Repository.GetSystemByAccount(account.Id);
if (existingAccount != null)
throw Errors.AccountInOtherSystem(existingAccount);
throw Errors.AccountInOtherSystem(existingAccount, ctx.Config);
var msg = $"{account.Mention()}, please confirm the link.";
if (!await ctx.PromptYesNo(msg, "Confirm", account, false)) throw Errors.MemberLinkCancelled;

View file

@ -120,8 +120,8 @@ public static class Errors
public static PKError UrlTooLong(string url) =>
new($"The given URL is too long ({url.Length}/{Limits.MaxUriLength} characters).");
public static PKError AccountInOtherSystem(PKSystem system) =>
new($"The mentioned account is already linked to another system (see `pk;system {system.Hid}`).");
public static PKError AccountInOtherSystem(PKSystem system, SystemConfig config) =>
new($"The mentioned account is already linked to another system (see `pk;system {system.DisplayHid(config)}`).");
public static PKError SameSwitch(ICollection<PKMember> members, LookupContext ctx)
{

View file

@ -255,7 +255,7 @@ public class EmbedService
// More than 5 groups show in "compact" format without ID
var content = groups.Count > 5
? string.Join(", ", groups.Select(g => g.DisplayName ?? g.Name))
: string.Join("\n", groups.Select(g => $"[`{g.Hid}`] **{g.DisplayName ?? g.Name}**"));
: string.Join("\n", groups.Select(g => $"[`{g.DisplayHid(ccfg)}`] **{g.DisplayName ?? g.Name}**"));
eb.Field(new Embed.Field($"Groups ({groups.Count})", content.Truncate(1000)));
}
@ -324,7 +324,7 @@ public class EmbedService
{
var name = pctx == LookupContext.ByOwner
? target.Reference(ctx)
: target.Hid;
: target.DisplayHid(ctx.Config);
eb.Field(new Embed.Field($"Members ({memberCount})", $"(see `pk;group {name} list`)"));
}
}