feat(admin): add user account management

This commit is contained in:
dmg
2026-08-01 14:16:46 -04:00
parent c5de0a1810
commit 10554eeaff
10 changed files with 690 additions and 6 deletions
+8
View File
@@ -38,6 +38,14 @@ export function formatDiscordNickname(firstName: string, minecraftUsername: stri
return `${shortenedName}${suffix}`;
}
export function formatManagedDiscordNickname(
firstName: string,
minecraftUsername: string | null,
) {
if (minecraftUsername) return formatDiscordNickname(firstName, minecraftUsername);
return [...firstName.trim()].slice(0, DISCORD_NICKNAME_LIMIT).join("").trimEnd();
}
export async function updateGuildNickname(
input: {
guildId: string;
+6 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it, vi } from "vitest";
import { formatDiscordNickname, lookupJavaProfile } from "../src/index";
import { formatDiscordNickname, formatManagedDiscordNickname, lookupJavaProfile } from "../src/index";
describe("Java Edition profiles", () => {
it("returns Mojang's canonical UUID and username", async () => {
@@ -27,4 +27,9 @@ describe("Java Edition profiles", () => {
);
expect(formatDiscordNickname("Sam", "Notch")).toBe("Sam (Notch)");
});
it("falls back to the user's name when an admin removes their final account", () => {
expect(formatManagedDiscordNickname("Alexandria Catherine", null)).toBe("Alexandria Catherine");
expect(formatManagedDiscordNickname("A name that is definitely longer than Discord allows", null)).toHaveLength(32);
});
});