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
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) | |
| ruleId | Yes | The ID of the rule |
Implementation Reference
- src/tools/audit-tools.ts:144-169 (handler)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) }] }; }
- src/tools/audit-tools.ts:140-143 (schema)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'), },
- src/tools/audit-tools.ts:138-170 (registration)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) }] }; } );