Building AI Discord Bots with NeuroLink A developer built a fully-featured AI Discord bot using Discord.js and NeuroLink's generation API. The bot includes slash commands, multi-turn conversations, AI-powered moderation, and production deployment, with NeuroLink handling AI generation. The tutorial covers setup, configuration, and integration of NeuroLink as the AI backend. You will build a fully-featured AI Discord bot using Discord.js and NeuroLink's generation API. By the end of this tutorial, you will have slash commands, multi-turn conversations, AI-powered moderation, and production deployment -- all using NeuroLink as the AI backend. Tip:This tutorial builds a custom Discord bot from scratch. NeuroLink does not provide a built-in Discord integration -- you will build the bot infrastructure yourself using Discord.js, with NeuroLink handling AI generation. {: .prompt-tip } This tutorial requires several npm packages for building Discord bots: npm install @juspay/neurolink discord.js npm install dotenv npm install -D typescript @types/node ts-node nodemon Required Packages: @juspay/neurolink - NeuroLink SDK for AI generation discord.js v14.x - Discord's official JavaScript library dotenv - Environment variable management typescript and @types/node - TypeScript support ts-node and nodemon - Development toolsBefore we begin, ensure you have the following: Important: This tutorial uses Discord.js v14.x. If you're upgrading from v13 or earlier, review the Discord.js v14 migration guide . First, we need to create a Discord application and bot user through the Discord Developer Portal. Under the Bot section, configure these essential settings: Privileged Gateway Intents: - MESSAGE CONTENT INTENT: Enabled required for reading messages - SERVER MEMBERS INTENT: Enabled if tracking member events - PRESENCE INTENT: Optional for user status features Navigate to OAuth2 URL Generator and select: bot , applications.commands Send Messages , Read Message History , Use Slash Commands , Embed Links , Attach Files Copy the generated URL and use it to invite your bot to your test server. Let's initialize our project and install the necessary dependencies. mkdir neurolink-discord-bot cd neurolink-discord-bot npm init -y Install the required packages: npm install discord.js @juspay/neurolink dotenv npm install -D typescript @types/node ts-node nodemon Initialize TypeScript: npx tsc --init Update your tsconfig.json : { "compilerOptions": { "target": "ES2022", "module": "commonjs", "lib": "ES2022" , "outDir": "./dist", "rootDir": "./src", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true }, "include": "src/ / " , "exclude": "node modules", "dist" } Organize your project with a clean structure: neurolink-discord-bot/ ├── src/ │ ├── index.ts Main entry point │ ├── config.ts Configuration │ ├── commands/ Slash commands │ │ ├── index.ts │ │ ├── ask.ts │ │ ├── chat.ts │ │ └── summarize.ts │ ├── events/ Discord event handlers │ │ ├── ready.ts │ │ └── interactionCreate.ts │ ├── services/ NeuroLink integration │ │ ├── neurolink.ts │ │ └── conversation.ts │ └── utils/ Helper functions │ ├── embed.ts │ └── logger.ts ├── .env ├── package.json └── tsconfig.json Create a .env file in your project root: DISCORD TOKEN=your discord bot token DISCORD CLIENT ID=your application client id NEUROLINK API KEY=your neurolink api key Create src/config.ts : python import dotenv from 'dotenv'; dotenv.config ; export const config = { discord: { token: process.env.DISCORD TOKEN , clientId: process.env.DISCORD CLIENT ID , }, neurolink: { apiKey: process.env.NEUROLINK API KEY , }, }; // Validate required environment variables const requiredEnvVars = 'DISCORD TOKEN', 'DISCORD CLIENT ID', 'NEUROLINK API KEY' ; for const envVar of requiredEnvVars { if process.env envVar { throw new Error Missing required environment variable: ${envVar} ; } } Create the NeuroLink service layer in src/services/neurolink.ts : js import { NeuroLink } from '@juspay/neurolink'; import { config } from '../config'; const neurolink = new NeuroLink ; export interface ChatMessage { role: 'user' | 'assistant' | 'system'; content: string; } export interface GenerateOptions { systemPrompt?: string; maxTokens?: number; temperature?: number; } export async function generateResponse prompt: string, options: GenerateOptions = {} : Promise