feat: suppress Discord link embed previews on bot messages

Add MessageFlags.SuppressEmbeds to all send() calls so URLs in
agent responses don't generate large preview cards.
This commit is contained in:
Eyejoker
2026-03-14 03:29:26 +09:00
parent f388323987
commit e4eca65c7c
2 changed files with 6 additions and 0 deletions

View File

@@ -98,6 +98,7 @@ vi.mock('discord.js', () => {
Client: MockClient,
Events,
GatewayIntentBits,
MessageFlags: { SuppressEmbeds: 1 << 2 },
TextChannel,
};
});
@@ -760,10 +761,12 @@ describe('DiscordChannel', () => {
expect(mockChannel.send).toHaveBeenNthCalledWith(1, {
content: 'x'.repeat(2000),
files: undefined,
flags: 1 << 2,
});
expect(mockChannel.send).toHaveBeenNthCalledWith(2, {
content: 'x'.repeat(1000),
files: undefined,
flags: 1 << 2,
});
});
});

View File

@@ -7,6 +7,7 @@ import {
Events,
GatewayIntentBits,
Message,
MessageFlags,
TextChannel,
} from 'discord.js';
@@ -457,6 +458,7 @@ export class DiscordChannel implements Channel {
await textChannel.send({
content: cleaned || undefined,
files: files.length > 0 ? files : undefined,
flags: MessageFlags.SuppressEmbeds,
});
} else {
// Send text in chunks, attach images to the first chunk
@@ -465,6 +467,7 @@ export class DiscordChannel implements Channel {
await textChannel.send({
content: chunk,
files: i === 0 && files.length > 0 ? files : undefined,
flags: MessageFlags.SuppressEmbeds,
});
}
}