Developer Guides

Complete documentation and tutorials for building applications with Discord's API and tools.

Getting Started

Create a Bot

// Install discord.js const Discord = require('discord.js'); const client = new Discord.Client(); client.on('ready', () => { console.log(`Logged in as ${client.user.tag}!`); }); client.on('message', message => { if (message.content === '!ping') { message.reply('Pong!'); } }); client.login('YOUR_BOT_TOKEN');

Best Practices

Handle Events

Use event listeners for user interactions.

const fs = require('fs'); const { Client, Intents } = require('discord.js'); const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); client.once('ready', () => { client.user.setActivity('with code'); console.log('Ready!'); }); client.login('YOUR_TOKEN');

Slash Commands

Use Application Commands for modern interaction.

const { SlashCommandBuilder } = require('@discordjs/builders'); module.exports = { data: new SlashCommandBuilder() .setName('ping') .setDescription('Replies with Pong!'), };