Nubis / Getting started
Démarrer
Getting started
Create a bot, connect it to a Discord application and run it in your test server.
La documentation de Nubis est en anglais, comme l’API du framework et ses messages.
You need Node 20 or later, or Bun, and a Discord account with a server you can test in.
Create the project
npx create-nubis my-bot
cd my-bot
npm installcreate-nubis asks nothing. It writes a small working bot: /ping, /echo, /fun roll, a button that counts its clicks, a ready event and tests for all of them. It notices the package manager you ran it with (bunx, pnpm dlx, yarn create), or takes --pm bun|npm|pnpm|yarn. With Bun the tests use bun:test; with npm, pnpm or Yarn they use Vitest.
Create a Discord application
- Open the Developer Portal and create an application.
- Under Bot, reset the token and copy it.
- Under General Information, copy the application id and the public key.
- Under Installation, give the guild install the
botandapplications.commandsscopes, open the install link and add the bot to your test server. - In Discord, turn on Developer Mode (Settings → Advanced), right-click your test server and copy its id.
Fill in .env
cp .env.example .envDISCORD_TOKEN= the bot token
DISCORD_APPLICATION_ID= the application id
DISCORD_PUBLIC_KEY= the public key (only the HTTP transport needs it)
DISCORD_DEV_GUILD_ID= your test server's idThe token is a password for your bot. .env is in the project's .gitignore; keep it there. Nubis looks for .env in the project folder and the folders above it.
Run it
npm run devnubis dev registers your commands in the test server, where they appear at once, connects the bot and restarts it when a file changes. Type /ping in your server.
Run the tests
npm testThe tests call the commands the way Discord would and check what they sent back, with no network and no token. See Testing.
Where to go next
- Commands and Options: the slash commands themselves.
- Replies: what
reply()does for you. - Components: buttons and selects with typed state.
- Running: putting the bot on a server.