Skip to main content
Glama

Discord Agent MCP

by aj-geddes
guild-validation.ts1.02 kB
import { Client, Guild } from "discord.js"; import { GuildNotFoundError } from "../errors/discord.js"; /** * Validates that the bot has access to a guild and fetches it * @param client Discord client instance * @param guildId Guild ID to validate * @returns Guild object if accessible * @throws GuildNotFoundError if guild is not accessible */ export async function validateGuildAccess( client: Client, guildId: string, ): Promise<Guild> { const guild = await client.guilds.fetch(guildId).catch(() => null); if (!guild) { throw new GuildNotFoundError(guildId); } return guild; } /** * Checks if the bot is a member of a guild without throwing * @param client Discord client instance * @param guildId Guild ID to check * @returns true if bot has access, false otherwise */ export async function hasGuildAccess( client: Client, guildId: string, ): Promise<boolean> { try { const guild = await client.guilds.fetch(guildId); return !!guild; } catch { return false; } }

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/aj-geddes/discord-agent-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server