Nubis / Configuration
Ship
Configuration
nubis.config.ts, every setting in it, and the settings that come from .env.
Settings for the whole bot go in nubis.config.ts, next to its folders. Every key is optional, and a bot without the file runs with the defaults.
import { defineConfig } from "nubis";
export default defineConfig({
presence: { status: "online", activity: { type: "watching", name: "for /help" } },
intents: ["MessageContent"],
guards: [notBlocked],
onError: (error, info) => report(error, info),
});.ts, .mts, .js and .mjs all work. Nubis checks the file when it starts, so a misspelt key fails with its name instead of being ignored.
Settings
| Setting | What it does |
|---|---|
root | Where commands/, components/, menus/ and events/ are, relative to the config. Defaults to the config's folder. |
intents | Intents beyond what your events need, by name: ["MessageContent", "GuildMembers"]. See Events. |
presence | What the member list shows under the bot. |
guards | Guards for every command, component, modal and menu. |
middleware | Middleware around every handler. |
onError | Receives every handler error after the user has been told. Defaults to logging. See Errors. |
autoDeferMs | When Nubis shows "thinking…" for a slow handler. 2000 by default; false turns it off. |
transport | "gateway" (the default) or "http". See Running. |
http | For the HTTP transport: port (defaults to PORT, then 3000) and path (defaults to /interactions). |
devGuildId | The test server for nubis dev and nubis sync, instead of DISCORD_DEV_GUILD_ID. |
Presence
presence: {
status: "idle", // online, idle, dnd or invisible
activity: { type: "playing", name: "with slash commands" },
},The activity type is playing, listening, watching, competing or custom. For custom, name is the status text itself.
Environment
Secrets stay out of the config and come from the environment, or from a .env file in the project folder or one above it:
| Variable | Used by |
|---|---|
DISCORD_TOKEN | Everything that talks to Discord |
DISCORD_APPLICATION_ID | Everything that talks to Discord |
DISCORD_PUBLIC_KEY | The HTTP transport, to verify Discord's requests |
DISCORD_DEV_GUILD_ID | nubis dev and nubis sync |
PORT | The HTTP transport, when http.port isn't set |