discord_delete_dm
Delete a bot-sent message from a Discord DM using the user ID and message ID.
Instructions
Delete a message 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). |
Implementation Reference
- src/tools/dm.ts:127-138 (schema)Schema definition for discord_delete_dm, requiring user_id and message_id.
{ name: "discord_delete_dm", description: "Delete a message sent by the bot in a DM.", inputSchema: { type: "object", properties: { ...userIdProp, ...messageIdProp, }, required: ["user_id", "message_id"], }, - src/tools/dm.ts:215-223 (handler)Handler logic for discord_delete_dm: fetches user, creates DM, fetches message, checks it was sent by the bot, and deletes it.
case "discord_delete_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 delete messages sent by the bot."); await msg.delete(); return { content: [{ type: "text", text: `✅ DM message ${msgId} deleted for ${user.username}.` }] }; } - src/tools/index.ts:26-26 (registration)The dm module (which defines discord_delete_dm) is registered as a tool module in the modules array.
import dm from "./dm.js";