Discord has become the central hub for crypto projects, gaming communities, SaaS products and creator audiences. A well-built bot turns a passive server into an interactive, self-moderating community that runs 24/7 without manual work. This guide walks through every layer — from your first slash command to verified NFT role gating at scale.
Why communities need a custom bot
Off-the-shelf bots like MEE6 cover basics but can't integrate with your own API, verify on-chain wallet holdings, sync with your CRM, or run custom game logic. Custom bots are the difference between a generic server and a platform.
The tech stack
discord.js
Bot framework
Node.js
Runtime
PostgreSQL
Member data
Redis
Rate limiting
Slash commands — the modern approach
Discord's slash command API is the standard for modern bots. Commands are registered globally or per-guild, auto-complete in the UI, and support subcommands, options and modals.
import { SlashCommandBuilder } from "discord.js"; export const data = new SlashCommandBuilder() .setName("verify") .setDescription("Verify your NFT holdings to unlock roles"); export async function execute(interaction) { const userId = interaction.user.id; const link = await generateVerifyLink(userId); await interaction.reply({ content: link, ephemeral: true });}Role gating & NFT verification
The most requested Discord bot feature in Web3: connect a wallet, check on-chain balances, and assign Discord roles automatically. We use a web-based verify flow that signs a message with the user's wallet, then our API confirms the holding and calls Discord's role API.
- ✓User runs /verify
- ✓Bot sends a unique link (ephemeral, expires in 10 min)
- ✓User signs with MetaMask or Phantom
- ✓API checks token balance on-chain
- ✓Bot assigns matching role(s) in real time
Auto-moderation at scale
Large communities face spam, raid attacks and scam links the moment they grow. A proper moderation system layers multiple signals: new account age, join velocity, message rate, known scam URLs and keyword filters.
const SCAM_PATTERNS = [/free-nft./, /discord-nitro-gift./]; client.on("messageCreate", async (msg) => { if (msg.author.bot) return; if (SCAM_PATTERNS.some((p) => p.test(msg.content))) { await msg.delete(); await msg.member?.timeout(10 * 60 * 1000, "Scam link"); await msg.channel.send(`⚠️ ${msg.author} was timed out.`); }});Hosting & uptime
Discord bots need 24/7 uptime with auto-restart on crash. We deploy to a VPS or container (Railway, Fly.io, or a dedicated server) with PM2 or Docker for process management, and a health-check webhook that alerts if the bot goes offline.
Need this built? Explore our Telegram & Discord Bots service.
View service →Written by Zahid Ghotia · Published 1 June 2026 · 9 min read


