Nubis / Project layout
Démarrer
Project layout
The folders Nubis reads, how file paths become command names, and what it skips.
La documentation de Nubis est en anglais, comme l’API du framework et ses messages.
Nubis loads a bot from four folders next to nubis.config.ts. Each one is optional, and root in the configuration can move them into a subfolder such as src/.
| Folder | What goes in it | What a file exports |
|---|---|---|
commands/ | Slash commands | export default command(...) |
components/ | Buttons, selects and modals | Any number of named exports |
menus/ | Right-click commands | export default userCommand(...) or messageCommand(...) |
events/ | Gateway events | export default event(...), or an array of them |
Paths become names
Inside commands/, the path is the command:
commands/ping.ts → /ping
commands/config/set.ts → /config set
commands/config/roles/add.ts → /config roles addA folder becomes a command with subcommands, and a folder inside it becomes a subcommand group, which is as deep as Discord goes. A file and a folder can't share a name at the same level: Discord doesn't let you run a command that has subcommands, so commands/config.ts next to commands/config/ is an error.
File names are the names Discord shows, so they follow Discord's rules: lowercase letters, digits, - and _. Nubis checks this when it loads the file, and the error names it:
NubisError: commands/Config/set: "Config" is not a valid Discord command or option name. Use 1-32 lowercase letters, digits, "-" or "_".Folder settings
A folder's _folder.ts describes it and can set guards, middleware and permissions for every command inside:
// commands/config/_folder.ts
import { folder, hasPermission } from "nubis";
import { PermissionFlagsBits } from "discord-api-types/v10";
export default folder({
description: "Server settings",
guards: [hasPermission(PermissionFlagsBits.ManageGuild)],
defaultMemberPermissions: [PermissionFlagsBits.ManageGuild],
});Settings Discord only reads on top-level commands — defaultMemberPermissions, contexts, integrationTypes and nsfw — go on the top-level folder for a command with subcommands.
What Nubis skips
Files starting with _ (other than _folder.ts), test files (*.test.ts, *.spec.ts) and type declarations (*.d.ts) are not loaded. Keep helpers in _utils.ts, or in a folder outside the four, such as lib/.
Components are found by export
A component is routed by its id, not by its file, so components/ can be organised any way you like and one file can export several. Nubis loads every export that is a button, select or modal, and refuses a file that exports none.