Skip to main content
Glama

discord_send_dm

Send a private direct message to a Discord user via their user ID. The bot must share a server with the target user. Provide the user ID and message content.

Instructions

Send a direct message to a user by their user ID. The bot must share at least one server with the user.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idYesThe Discord user ID.
contentYesThe message content to send.

Implementation Reference

  • Handler for discord_send_dm: fetches the user by ID, sends a DM with the provided content, and returns a success message with the message ID.
    case "discord_send_dm": {
      const user = await discord.users.fetch(validateId(args.user_id, "user_id"));
      const sent = await user.send(args.content as string);
      return { content: [{ type: "text", text: `✅ DM sent to ${user.username} (message id: ${sent.id}).` }] };
    }
  • Schema definition for discord_send_dm: requires user_id (string) and content (string).
    {
      name: "discord_send_dm",
      description:
        "Send a direct message to a user by their user ID. The bot must share at least one server with the user.",
      inputSchema: {
        type: "object",
        properties: {
          ...userIdProp,
          content: { type: "string", description: "The message content to send." },
        },
        required: ["user_id", "content"],
      },
  • Tool routing function that iterates over all modules (including dm) and delegates to the correct handler.
    export async function handleTool(name: string, args: Record<string, unknown>): Promise<ToolResult> {
      for (const mod of modules) {
        const result = await mod.handle(name, args);
        if (result) return result;
      }
      throw new Error(`Unknown tool: ${name}`);
    }
  • The dm module is imported and added to the modules array, registering all its tool definitions (including discord_send_dm).
    import dm from "./dm.js";
    
    const modules: ToolModule[] = [
      discovery,
      messages,
      channels,
      permissions,
      members,
      roles,
      moderation,
      screening,
      stats,
      forums,
      webhooks,
      scheduledEvents,
      invites,
      dm,
    ];
  • validateId helper used by the handler to validate Discord snowflake IDs before making API calls.
    export function validateId(value: unknown, label: string): string {
      const id = String(value ?? "");
      if (!/^\d{17,20}$/.test(id)) throw new Error(`Invalid ${label}: "${id}". Must be a Discord snowflake ID (17-20 digits).`);
      return id;
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions a prerequisite but lacks details on what happens on failure, rate limits, or confirmation of success.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences, no filler, front-loaded with essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a simple 2-parameter tool with no output schema. The prerequisite is useful context, though response format is omitted.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema covers both parameters completely (100% description coverage). The description adds no extra meaning beyond schema, so baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('send a direct message'), the target ('by their user ID'), and adds a prerequisite (bot must share a server), distinguishing it from siblings like discord_send_dm_embed and discord_reply_dm.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides a clear prerequisite ('bot must share at least one server with the user'), but does not explicitly contrast with siblings or state when not to use (e.g., for sending embeds).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/PaSympa/discord-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server