DJS Commandsv2 docs
Concepts

Storage

User-owned persistence for djs-commands framework features.

@djs-commands/core ships without a database. You own schema, migrations, indexes, names, and connection lifecycle.

First-party storage adapters only translate djs-commands framework models. Use your ORM/client directly for your own app data.

Framework models

Import model constants from @djs-commands/core and map only the models for features you enable.

ModelRequired logical fieldsRecommended unique constraint
GuildPrefixModelguild_id, prefixguild_id
DisabledCommandsModelguild_id, command_nameguild_id, command_name
ChannelLocksModelguild_id, command_name, channel_idguild_id, command_name, channel_id

Enabled feature + missing mapping fails at handler boot. Direct helper use against an unmapped model fails loudly from the adapter.

Feature flags

createCommandHandler({
	client,
	storage,
	legacy: { enabled: true, defaultPrefix: "!" }, // enables GuildPrefixModel storage by default
	storageFeatures: {
		disabledCommands: true,
		channelLocks: true,
	},
});

Defaults:

  • guildPrefixes: follows legacy.enabled
  • disabledCommands: false
  • channelLocks: false

Disabled features do not query storage.

Helpers

import {
	clearGuildPrefix,
	disableCommand,
	enableCommand,
	getChannelLocks,
	getGuildPrefix,
	isCommandDisabled,
	lockCommandToChannel,
	setGuildPrefix,
	unlockCommandFromChannel,
} from "@djs-commands/core";

The helpers use logical fields. Adapters translate those fields to your real columns/document fields.

See the Adapter Cookbook for Drizzle, Prisma, and Mongoose mappings.

Last updated on

On this page