Skip to main content
Glama

list_automod_rules

Retrieve and display all auto-moderation rules configured for a Discord server to manage content filtering and moderation settings.

Instructions

List all auto-moderation rules in a server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)

Implementation Reference

  • The core handler logic for the list_automod_rules tool. Fetches all auto-moderation rules from the specified Discord guild and serializes them to JSON.
    async ({ guildId }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const rules = await guild.autoModerationRules.fetch(); return rules.map((rule) => ({ id: rule.id, name: rule.name, enabled: rule.enabled, eventType: rule.eventType, triggerType: rule.triggerType, triggerMetadata: rule.triggerMetadata, actions: rule.actions.map((action) => ({ type: action.type, metadata: action.metadata, })), 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) }] }; }
  • Zod input schema defining the required guildId parameter.
    { guildId: z.string().describe('The ID of the server (guild)'), },
  • Registers the list_automod_rules tool on the MCP server within the registerAuditTools function.
    server.tool( 'list_automod_rules', 'List all auto-moderation rules in a server', { guildId: z.string().describe('The ID of the server (guild)'), }, async ({ guildId }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const rules = await guild.autoModerationRules.fetch(); return rules.map((rule) => ({ id: rule.id, name: rule.name, enabled: rule.enabled, eventType: rule.eventType, triggerType: rule.triggerType, triggerMetadata: rule.triggerMetadata, actions: rule.actions.map((action) => ({ type: action.type, metadata: action.metadata, })), 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:64-64 (registration)
    Higher-level registration call that invokes registerAuditTools to set up all audit tools including list_automod_rules.
    registerAuditTools(server);
  • src/index.ts:22-22 (registration)
    Import of the registerAuditTools function used to register the audit tools.
    import { registerAuditTools } from './tools/audit-tools.js';

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