discord_send_dm_embed
Send a direct message with a customizable rich embed to any Discord user, including text, fields, images, and timestamps.
Instructions
Send a rich embed as a direct message to a user.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | Yes | The Discord user ID. | |
| content | No | Optional text content above the embed. | |
| title | No | ||
| url | No | URL that makes the title clickable. | |
| description | No | ||
| color | No | Hex color e.g. #5865F2 | |
| fields | No | ||
| author | No | Author block shown at the top of the embed. | |
| thumbnail_url | No | Small image shown in the top-right corner. | |
| footer | No | ||
| image_url | No | ||
| timestamp | No | If true, adds the current timestamp to the embed. |
Implementation Reference
- src/tools/dm.ts:181-189 (handler)Handler for discord_send_dm_embed — fetches the user, builds an embed from args, and sends it as a DM.
case "discord_send_dm_embed": { const user = await discord.users.fetch(validateId(args.user_id, "user_id")); const embed = buildEmbed(args); const sent = await user.send({ content: (args.content as string) || undefined, embeds: [embed], }); return { content: [{ type: "text", text: `✅ DM embed sent to ${user.username} (message id: ${sent.id}).` }] }; } - src/tools/dm.ts:84-97 (schema)Schema definition for discord_send_dm_embed — defines the name, description, and input schema (user_id, optional content, and all embed properties).
{ name: "discord_send_dm_embed", description: "Send a rich embed as a direct message to a user.", inputSchema: { type: "object", properties: { ...userIdProp, content: { type: "string", description: "Optional text content above the embed." }, ...embedProperties, }, required: ["user_id"], }, }, - src/tools/index.ts:26-43 (registration)Registration of the dm module in the central tool registry — imports and adds the dm module to the modules array, making discord_send_dm_embed available for routing.
import dm from "./dm.js"; const modules: ToolModule[] = [ discovery, messages, channels, permissions, members, roles, moderation, screening, stats, forums, webhooks, scheduledEvents, invites, dm, ]; - src/tools/dm.ts:6-25 (helper)buildEmbed helper — constructs a Discord.js EmbedBuilder from flat arguments, used by discord_send_dm_embed to create the embed.
function buildEmbed(args: Record<string, unknown>): EmbedBuilder { const embed = new EmbedBuilder(); if (args.title) embed.setTitle(args.title as string); if (args.url) embed.setURL(args.url as string); if (args.description) embed.setDescription(args.description as string); if (args.color) embed.setColor(args.color as ColorResolvable); if (args.footer) embed.setFooter({ text: args.footer as string }); if (args.image_url) embed.setImage(args.image_url as string); if (args.thumbnail_url) embed.setThumbnail(args.thumbnail_url as string); if (args.timestamp) embed.setTimestamp(); if (args.author) { const a = args.author as { name: string; icon_url?: string; url?: string }; embed.setAuthor({ name: a.name, iconURL: a.icon_url, url: a.url }); } if (args.fields) { const fields = args.fields as { name: string; value: string; inline?: boolean }[]; embed.addFields(fields.map((f) => ({ name: f.name, value: f.value, inline: f.inline ?? false }))); } return embed; } - src/tools/dm.ts:28-59 (helper)embedProperties — shared schema properties for embed fields (title, url, description, color, fields, author, thumbnail_url, footer, image_url, timestamp), used by discord_send_dm_embed input schema.
const embedProperties = { title: { type: "string" }, url: { type: "string", description: "URL that makes the title clickable." }, description: { type: "string" }, color: { type: "string", description: "Hex color e.g. #5865F2" }, fields: { type: "array", items: { type: "object", properties: { name: { type: "string" }, value: { type: "string" }, inline: { type: "boolean" }, }, required: ["name", "value"], }, }, author: { type: "object", description: "Author block shown at the top of the embed.", properties: { name: { type: "string" }, icon_url: { type: "string" }, url: { type: "string" }, }, required: ["name"], }, thumbnail_url: { type: "string", description: "Small image shown in the top-right corner." }, footer: { type: "string" }, image_url: { type: "string" }, timestamp: { type: "boolean", description: "If true, adds the current timestamp to the embed." }, } as const;