discord_edit_dm
Edit a text message previously sent by the bot in a DM by providing the user ID, message ID, and new content.
Instructions
Edit a text message previously sent by the bot in a DM.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | Yes | The Discord user ID. | |
| message_id | Yes | The message ID (must be a bot message). | |
| content | Yes | New text content for the message. |
Implementation Reference
- src/tools/dm.ts:98-111 (registration)Tool definition registration for discord_edit_dm including name, description, and inputSchema (requires user_id, message_id, content).
{ name: "discord_edit_dm", description: "Edit a text message previously sent by the bot in a DM.", inputSchema: { type: "object", properties: { ...userIdProp, ...messageIdProp, content: { type: "string", description: "New text content for the message." }, }, required: ["user_id", "message_id", "content"], }, }, - src/tools/dm.ts:191-199 (handler)Handler implementation for discord_edit_dm: fetches user, creates DM channel, fetches the message, verifies it was sent by the bot, then edits it with new text content.
case "discord_edit_dm": { const user = await discord.users.fetch(validateId(args.user_id, "user_id")); const dm = await user.createDM(); const msgId = validateId(args.message_id, "message_id"); const msg = await dm.messages.fetch(msgId); if (msg.author.id !== discord.user?.id) throw new Error("Can only edit messages sent by the bot."); await msg.edit(args.content as string); return { content: [{ type: "text", text: `✅ DM message ${msgId} edited for ${user.username}.` }] }; } - src/tools/dm.ts:102-110 (schema)Input schema for discord_edit_dm: userIdProp (user_id), messageIdProp (message_id), and content — all required.
inputSchema: { type: "object", properties: { ...userIdProp, ...messageIdProp, content: { type: "string", description: "New text content for the message." }, }, required: ["user_id", "message_id", "content"], }, - src/tools/index.ts:26-26 (registration)Import of the dm module (which contains discord_edit_dm) into the central tool registry.
import dm from "./dm.js"; - src/tools/dm.ts:61-67 (helper)Helper property definitions for userIdProp and messageIdProp used across DM tool schemas including discord_edit_dm.
const userIdProp = { user_id: { type: "string", description: "The Discord user ID." }, } as const; const messageIdProp = { message_id: { type: "string", description: "The message ID (must be a bot message)." }, } as const;