Skip to main content
Glama

list_automod_rules

Retrieve all auto-moderation rules configured in a Discord server to review content filtering settings and moderation policies.

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 function that implements the list_automod_rules tool logic: fetches auto-moderation rules from 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 guildId parameter for the tool.
    { guildId: z.string().describe('The ID of the server (guild)'), },
  • Registration of the list_automod_rules tool using server.tool(), including name, description, schema, and handler reference.
    // List auto-moderation rules 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:65-65 (registration)
    Top-level registration call to registerAuditTools which includes the list_automod_rules tool among audit tools.
    registerAuditTools(server);

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