Quick Start
Letβs build a small, useful Discord bot with Lunibee and Bun.
1. Create the project
Section titled β1. Create the projectβmkdir my-botcd my-botbun initbun add lunibee2. Add your token
Section titled β2. Add your tokenβCreate a .env file:
DISCORD_TOKEN="your-bot-token-here"Never commit your real bot token to Git.
3. Create src/index.ts
Section titled β3. Create src/index.tsβimport { Client, IntentBits } from "lunibee";
const client = new Client({ token: process.env.DISCORD_TOKEN!, intents: [ IntentBits.guilds, IntentBits.guildMessages, IntentBits.messageContent, ],});
client.on("ready", (user) => { console.log(`π Logged in as ${user.username} (${user.id})`);});
client.on("messageCreate", async (message) => { if (message.author.bot) return;
if (message.content === "!ping") { await message.reply("Pong! π"); }});
await client.login();import { Client, IntentBits } from "lunibee";
const client = new Client({ token: process.env.DISCORD_TOKEN, intents: [ IntentBits.guilds, IntentBits.guildMessages, IntentBits.messageContent, ],});
client.on("ready", (user) => { console.log(`π Logged in as ${user.username} (${user.id})`);});
client.on("messageCreate", async (message) => { if (message.author.bot) return;
if (message.content === "!ping") { await message.reply("Pong π"); }});
await client.login();4. Run it
Section titled β4. Run itβbun run src/index.tsDuring development:
bun --watch src/index.tsSend !ping in a channel the bot can access.
What next?
Section titled βWhat next?βOnce the bot is running, these are the most useful next steps:
// Send a messageawait channel.send({ content: "Hello!" });
// Edit a messageawait message.edit({ content: "Updated!" });
// Get a message's channelconst channel = message.channel;
// Rename a channelawait channel.editName("support");
// Reply to an interactionawait interaction.reply({ content: "Done!" });// Send a messageawait channel.send({ content: "Hello!" });
// Edit a messageawait message.edit({ content: "Updated!" });
// Get a message's channelconst channel = message.channel;
// Rename a channelawait channel.editName("support");
// Reply to an interactionawait interaction.reply({ content: "Done!" });For slash commands, build the command with SlashCommandBuilder, register its payload through the application-command API, and handle it with interactionCreate. See the Builders and Interactions guides for the command payload and interaction lifecycle.