Ir al contenido

Zumito Config

Esta página aún no está disponible en tu idioma.

This guide will help you to understand the zumito.config.ts file.

The zumito.config.ts file must export a constant named config that implements the LauncherConfig interface.

import type { LauncherConfig } from 'zumito-framework';
export const config: LauncherConfig = {
// Your configuration here
};

The LauncherConfig extends Partial<FrameworkSettings>, so all settings are defined at the top level of the exported config object. The main properties are:

  • discordClientOptions: Discord client configuration (token, intents, clientId).
  • defaultPrefix: Default bot prefix for text commands.
  • database: zumito-db multi-driver configuration.
  • bundles: An array of Bundle objects to load external modules.

The modules array is the recommended way to load Zumito modules. It accepts either a module npm package name string or a ModuleEntry created by a module’s factory function, giving you full type safety and autocomplete.

Each module exports a factory function that returns a typed ModuleEntry. This gives you autocomplete on the config object and ensures types are correct at compile time:

import { defineConfig } from 'zumito-framework';
import { adminModule } from '@zumito-team/admin-module';
import { userPanelModule } from '@zumito-team/user-panel-module';
export default defineConfig({
modules: [
adminModule(),
userPanelModule(),
]
});

Modules that support configuration can receive it directly in the factory call:

import { analyticsModule } from '@zumito-team/analytics-module';
export default defineConfig({
modules: [
analyticsModule({
defaultTrackCommandPerformance: true,
defaultRetentionDays: 30,
})
]
});

You can also pass module names as plain strings:

export default defineConfig({
modules: [
'@zumito-team/admin-module',
'@zumito-team/user-panel-module',
'@zumito-team/analytics-module',
]
});

Bundles are the legacy way to organize your bot’s code. Each bundle is a directory that contains commands, events, and other modules.

import path from 'path';
import type { LauncherConfig } from 'zumito-framework';
const __dirname = process.cwd();
export const config: LauncherConfig = {
bundles: [{
path: path.join(__dirname, "node_modules", "@zumito-team", "admin-module"),
}, {
path: path.join(__dirname, "node_modules", "@zumito-team", "user-panel-module"),
}],
};

The zumito.config.ts file exports a LauncherConfig object. Framework settings are defined at the top level of the config (not nested):

import type { LauncherConfig } from 'zumito-framework';
export const config: LauncherConfig = {
discordClientOptions: {
intents: 3276799,
token: process.env.DISCORD_TOKEN!,
clientId: process.env.DISCORD_CLIENT_ID!,
},
defaultPrefix: process.env.BOT_PREFIX || "z-",
logLevel: parseInt(process.env.LOG_LEVEL || "3"),
};

The database property configures zumito-db:

export const config: LauncherConfig = {
mongoQueryString: process.env.MONGO_URI!,
database: {
default: 'mongo',
drivers: {
mongo: { uri: process.env.MONGO_URI! },
},
migrations: [], // optional: array of Migration instances
},
models: [Guild, Member], // auto-register models on startup
};
PropertyTypeDescription
database.defaultstringDefault driver name ('mongo', 'sqlite', 'tingo', 'memory')
database.driversRecord<string, object>Per-driver connection config
database.migrationsMigration[]Optional migration classes
modelsany[]Model classes to auto-register