delete_automod_rule
Remove an auto-moderation rule from a Discord server by specifying the server and rule IDs to manage content moderation settings.
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:173-199 (handler)Full implementation of the delete_automod_rule tool, including input schema (guildId, ruleId, optional reason), handler logic that uses Discord.js to fetch the guild and rule then deletes the rule with optional reason, wrapped in error handling, and returns JSON response.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) }] }; } );
- src/index.ts:64-64 (registration)Top-level registration call to registerAuditTools which registers the delete_automod_rule tool along with other audit and moderation tools.registerAuditTools(server);
- src/tools/audit-tools.ts:176-180 (schema)Zod input schema definition for the delete_automod_rule tool parameters.{ 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'), },