commit
Add d$member to show a member's card
Looks a member up by name and replies with the same card as the info reaction. d$m works too. Co-Authored-By: Sandrone <[email protected]>
diff --git a/src/commands/help.ts b/src/commands/help.ts
index e341f76..974b950 100644
--- a/src/commands/help.ts
+++ b/src/commands/help.ts
@@ -8,6 +8,7 @@ const helpText = [
"`d$autoproxy` shows the state for this server, `d$autoproxy on|off` sets it. Add `-g` for every server, like `d$autoproxy -g off`. `d$ap` works too.",
"`d$reproxy <member>` resends the message you reply to, or your latest proxied message, as someone else, like `d$reproxy c1`. `d$rp` works too.",
"`d$switch <member>` sets who's fronting on the site, like `d$switch c1 c2`. `d$switch out` clears it. `d$sw` works too.",
+ "`d$member <member>` shows a member's card, like `d$member aether`. `d$m` works too.",
"-# React ❌ to delete a proxied message, ❓ to see who sent it.",
].join("\n");
diff --git a/src/commands/index.ts b/src/commands/index.ts
index d0e836d..e24fdfd 100644
--- a/src/commands/index.ts
+++ b/src/commands/index.ts
@@ -6,6 +6,7 @@ import { autoproxyCommand } from "./autoproxy.ts";
import { editCommand } from "./edit.ts";
import { explainCommand } from "./explain.ts";
import { helpCommand } from "./help.ts";
+import { memberCommand } from "./member.ts";
import { parseCommand } from "./parse.ts";
import { reproxyCommand } from "./reproxy.ts";
import { switchCommand } from "./switch.ts";
@@ -27,6 +28,8 @@ const commands: Record<string, CommandHandler> = {
rp: reproxyCommand,
switch: switchCommand,
sw: switchCommand,
+ member: memberCommand,
+ m: memberCommand,
help: helpCommand
};
diff --git a/src/commands/member.ts b/src/commands/member.ts
new file mode 100644
index 0000000..ace38ed
--- /dev/null
+++ b/src/commands/member.ts
@@ -0,0 +1,33 @@
+/* src/commands/member.ts */
+
+import {
+ type APIMessageTopLevelComponent,
+ type Message,
+ MessageFlags,
+} from "discord.js";
+
+import { memberCard } from "../discord/infoCard.ts";
+import { membersByName } from "../proxy/names.ts";
+import { system } from "../state/system.ts";
+
+export async function memberCommand(
+ message: Message,
+ args: string[],
+): Promise<void> {
+ if (args.length !== 1) {
+ await message.reply("Use `d$member <member>`, like `d$member aether`.");
+ return;
+ }
+
+ const match = membersByName(system.members, args).found[0];
+
+ if (!match) {
+ await message.reply(`No member called \`${args[0]}\`.`);
+ return;
+ }
+
+ await message.reply({
+ flags: MessageFlags.IsComponentsV2,
+ components: [memberCard(match)] as APIMessageTopLevelComponent[],
+ });
+}
diff --git a/src/discord/infoCard.ts b/src/discord/infoCard.ts
index ce90aa9..aa019a3 100644
--- a/src/discord/infoCard.ts
+++ b/src/discord/infoCard.ts
@@ -69,7 +69,7 @@ export function header(text: string, avatarUrl: string | null): ComponentJson {
}
// Mirrors the site's member page: name, pronouns, status, then about, tags, pride
-function memberCard(member: Member): ComponentJson {
+export function memberCard(member: Member): ComponentJson {
const top = [`## ${member.display_name || member.name}`];
if (member.pronouns) top.push(member.pronouns);
if (member.status) {