Skip to main content
Glama
scarecr0w12

discord-mcp

get_automod_rule

Retrieve details of a specific auto-moderation rule in a Discord server by providing the guild ID and rule ID.

Instructions

Get details of a specific auto-moderation rule

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
ruleIdYesThe ID of the rule

Implementation Reference

  • Executes the tool logic: fetches the auto-moderation rule by guildId and ruleId using Discord client, processes the data, handles errors with withErrorHandling, and returns JSON stringified response.
    async ({ guildId, ruleId }) => {
      const result = await withErrorHandling(async () => {
        const client = await getDiscordClient();
        const guild = await client.guilds.fetch(guildId);
        const rule = await guild.autoModerationRules.fetch(ruleId);
    
        return {
          id: rule.id,
          name: rule.name,
          enabled: rule.enabled,
          eventType: rule.eventType,
          triggerType: rule.triggerType,
          triggerMetadata: rule.triggerMetadata,
          actions: rule.actions,
          exemptRoles: rule.exemptRoles.map((r) => ({ id: r.id, name: r.name })),
          exemptChannels: rule.exemptChannels.map((c) => ({ id: c.id, name: c.name })),
          creatorId: rule.creatorId,
        };
      });
    
      if (!result.success) {
        return { content: [{ type: 'text', text: result.error }], isError: true };
      }
    
      return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
    }
  • Input schema using Zod for validating guildId and ruleId parameters.
    {
      guildId: z.string().describe('The ID of the server (guild)'),
      ruleId: z.string().describe('The ID of the rule'),
    },
  • Registers the 'get_automod_rule' tool on the MCP server with name, description, input schema, and handler function inside registerAuditTools.
    server.tool(
      'get_automod_rule',
      'Get details of a specific auto-moderation rule',
      {
        guildId: z.string().describe('The ID of the server (guild)'),
        ruleId: z.string().describe('The ID of the rule'),
      },
      async ({ guildId, ruleId }) => {
        const result = await withErrorHandling(async () => {
          const client = await getDiscordClient();
          const guild = await client.guilds.fetch(guildId);
          const rule = await guild.autoModerationRules.fetch(ruleId);
    
          return {
            id: rule.id,
            name: rule.name,
            enabled: rule.enabled,
            eventType: rule.eventType,
            triggerType: rule.triggerType,
            triggerMetadata: rule.triggerMetadata,
            actions: rule.actions,
            exemptRoles: rule.exemptRoles.map((r) => ({ id: r.id, name: r.name })),
            exemptChannels: rule.exemptChannels.map((c) => ({ id: c.id, name: c.name })),
            creatorId: rule.creatorId,
          };
        });
    
        if (!result.success) {
          return { content: [{ type: 'text', text: result.error }], isError: true };
        }
    
        return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
      }
    );
  • src/index.ts:65-65 (registration)
    Calls registerAuditTools to register all audit tools including get_automod_rule on the MCP server instance.
    registerAuditTools(server);

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/scarecr0w12/discord-mcp'

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