Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

### Fixed

- Prevent profile responses from triggering Discord mentions from stored profile text.
- Prevent mixed reaction replies from narrating the bot's internal choice to react while preserving natural reaction-plus-text responses.
- Run Discord-initiated Claude login in a pseudo-terminal so the CLI accepts submitted OAuth codes.
- Isolate saved history and summaries by Discord channel ID in dedicated storage namespaces so same-named channels do not share automatic context.
Expand Down
17 changes: 13 additions & 4 deletions src/discord/commands/profile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { Message, TextChannel } from "discord.js";
import { getUserProfile } from "../../storage/profiles.js";

export function createProfileMessageOptions(content: string) {
return {
content,
allowedMentions: { parse: [] as const },
};
}

export async function handleProfile(msg: Message): Promise<void> {
const mentioned = msg.mentions.users.first();
const targetUser = mentioned || msg.author;
Expand All @@ -9,21 +16,23 @@ export async function handleProfile(msg: Message): Promise<void> {
const header = `**Profile for ${targetUser.tag}:**\n`;
const full = header + profile;
if (full.length <= 2000) {
await msg.reply(full);
await msg.reply(createProfileMessageOptions(full));
} else {
const firstMax = 2000 - header.length;
await msg.reply(header + profile.slice(0, firstMax));
await msg.reply(createProfileMessageOptions(header + profile.slice(0, firstMax)));
let remaining = profile.slice(firstMax);
while (remaining.length > 0) {
await (msg.channel as TextChannel).send(
remaining.slice(0, 2000),
createProfileMessageOptions(remaining.slice(0, 2000)),
);
remaining = remaining.slice(2000);
}
}
} else {
await msg.reply(
`No profile found for ${targetUser.tag}. Profiles are built automatically as users interact with the bot.`,
createProfileMessageOptions(
`No profile found for ${targetUser.tag}. Profiles are built automatically as users interact with the bot.`,
),
);
}
}
16 changes: 16 additions & 0 deletions tests/profileCommand.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import assert from "node:assert/strict";
import test from "node:test";

import {
createProfileMessageOptions,
} from "../build/discord/commands/profile.js";

test("profile replies disable Discord mention parsing", () => {
assert.deepEqual(
createProfileMessageOptions("**Profile:** @everyone"),
{
content: "**Profile:** @everyone",
allowedMentions: { parse: [] },
},
);
});