delete_automod_rule
Remove an auto-moderation rule from a Discord server by specifying the guild ID and rule ID. This action deletes the rule permanently.
Instructions
Delete an 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 to delete | |
| reason | No | Reason for deletion |
Implementation Reference
- src/tools/audit-tools.ts:181-198 (handler)The handler function for delete_automod_rule tool. Fetches the Discord guild and auto-moderation rule, deletes the rule with optional reason, handles errors, and returns success message or error.async ({ guildId, ruleId, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const rule = await guild.autoModerationRules.fetch(ruleId); const ruleName = rule.name; await rule.delete(reason); return { ruleId, ruleName, message: 'Auto-moderation rule deleted successfully' }; }); 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:176-180 (schema)Input schema for delete_automod_rule tool using Zod validation: guildId (required string), ruleId (required string), reason (optional string).{ guildId: z.string().describe('The ID of the server (guild)'), ruleId: z.string().describe('The ID of the rule to delete'), reason: z.string().optional().describe('Reason for deletion'), },
- src/tools/audit-tools.ts:173-199 (registration)Registration of the delete_automod_rule tool on the MCP server within registerAuditTools function.server.tool( 'delete_automod_rule', 'Delete an auto-moderation rule', { guildId: z.string().describe('The ID of the server (guild)'), ruleId: z.string().describe('The ID of the rule to delete'), reason: z.string().optional().describe('Reason for deletion'), }, async ({ guildId, ruleId, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const rule = await guild.autoModerationRules.fetch(ruleId); const ruleName = rule.name; await rule.delete(reason); return { ruleId, ruleName, message: 'Auto-moderation rule deleted successfully' }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );