Skip to main content
Glama
README.md1.66 kB
# Discord Bot Starter Template ## Project Structure ``` discord-bot/ ├── src/ │ ├── index.ts # Entry point │ ├── config.ts # Bot configuration │ ├── commands/ │ │ ├── index.ts │ │ ├── ping.ts │ │ └── help.ts │ ├── events/ │ │ ├── ready.ts │ │ └── interactionCreate.ts │ └── utils/ │ └── logger.ts ├── package.json ├── tsconfig.json └── .env ``` ## index.ts ```typescript import { Client, GatewayIntentBits, Collection } from "discord.js"; import { config } from "./config"; import { commands } from "./commands"; const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, ], }); client.commands = new Collection(); commands.forEach((cmd) => client.commands.set(cmd.name, cmd)); client.once("ready", () => { console.log(`Logged in as ${client.user?.tag}`); }); client.on("interactionCreate", async (interaction) => { if (!interaction.isChatInputCommand()) return; const command = client.commands.get(interaction.commandName); if (!command) return; try { await command.execute(interaction); } catch (error) { console.error(error); await interaction.reply({ content: "Error!", ephemeral: true }); } }); client.login(config.token); ``` ## Best Practices - Use slash commands (not prefix commands) - Handle errors gracefully - Use ephemeral replies for sensitive data - Implement rate limiting awareness - Cache data appropriately - Use embeds for rich content

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/millsydotdev/Code-MCP'

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