Skip to main content
Glama

get_automod_rule

Retrieve details of a specific Discord auto-moderation rule by providing the server and rule IDs to view its configuration and settings.

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

  • The main handler function that executes the tool logic: fetches the auto-moderation rule by guildId and ruleId using Discord API, formats the response, and handles errors.
    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 defined with 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'), },
  • Registration of the 'get_automod_rule' tool on the MCP server, including name, description, schema, and handler.
    '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) }] }; } );

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