PopiiClientConfig
Popii / PopiiClientConfig
Interface: PopiiClientConfig<TState>
Section titled “Interface: PopiiClientConfig<TState>”Defined in: types.ts:659
Configuration passed to popiiClient when creating the bot.
Only token is required. Everything else has sensible defaults.
Examples
Section titled “Examples”const client = popiiClient({ token: process.env.DISCORD_TOKEN! });const client = popiiClient({ token: process.env.DISCORD_TOKEN!, devGuildId: process.env.DEV_GUILD_ID, owners: ["your_discord_user_id"], prefix: "!", status: ["Serving {{guilds}} servers", "Try /help"], plugins: [sqlitePlugin(), webPlugin(), errorHandlerPlugin()],});Type Parameters
Section titled “Type Parameters”TState
Section titled “TState”TState = any
Properties
Section titled “Properties”token:
string
Defined in: types.ts:661
Your Discord bot token. Keep this in .env — never commit it.
optionalmode?:"websocket"|"http"
Defined in: types.ts:667
Connection mode.
"websocket"(default) — standard Gateway connection."http"— HTTP interactions endpoint for serverless deployments. RequirespublicKeyandport.
publicKey?
Section titled “publicKey?”
optionalpublicKey?:string
Defined in: types.ts:669
Required when mode is "http". Your application’s public key from the Discord Developer Portal.
optionalport?:number
Defined in: types.ts:671
Port for the HTTP interactions server when mode is "http". Defaults to 3000.
prefix?
Section titled “prefix?”
optionalprefix?:string| ((message) =>string|string[] |Promise<string|string[] |null> |null)
Defined in: types.ts:676
Enables legacy text commands. Provide a string prefix (e.g. "!") or a function
that returns the prefix(es) per message.
intents?
Section titled “intents?”
optionalintents?:number[]
Defined in: types.ts:678
Override the auto-detected Gateway intents. Popii infers intents from your event filenames by default.
redisUrl?
Section titled “redisUrl?”
optionalredisUrl?:string
Defined in: types.ts:680
Redis connection URL (e.g. "redis://localhost:6379"). Enables Redis-backed storage and sharding coordination.
redis?
Section titled “redis?”
optionalredis?:string|Record<string,unknown>
Defined in: types.ts:682
Alternative to redisUrl. Pass a connection string or an ioredis options object.
storage?
Section titled “storage?”
optionalstorage?:PopiiStorageAdapter
Defined in: types.ts:684
Provide a custom storage adapter to replace the built-in in-process Map with any backend.
partials?
Section titled “partials?”
optionalpartials?:Partials[]
Defined in: types.ts:686
Override the auto-detected Discord.js Partials. Popii infers partials from your event filenames by default.
devGuildId?
Section titled “devGuildId?”
optionaldevGuildId?:string
Defined in: types.ts:692
A guild ID used to register slash commands during development. Guild commands sync instantly; global commands can take up to an hour. Remove or leave empty in production.
onError?
Section titled “onError?”
optionalonError?: (error,pop) =>void|Promise<void>
Defined in: types.ts:694
Called when a command or snap throws an error that is not caught by a middleware.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”void | Promise<void>
onGlobalError?
Section titled “onGlobalError?”
optionalonGlobalError?: (error) =>void|Promise<void>
Defined in: types.ts:696
Called for unhandled promise rejections and uncaught exceptions not tied to a command.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”void | Promise<void>
owners?
Section titled “owners?”
optionalowners?:string[]
Defined in: types.ts:698
Discord user IDs that have bot-owner privileges (e.g. ownerOnly: true commands).
state?
Section titled “state?”
optionalstate?:TState
Defined in: types.ts:700
Initial value for pop.state and client.state. Persisted to Redis/storage between restarts.
commands?
Section titled “commands?”
optionalcommands?:object
Defined in: types.ts:701
optionaldir?:string
folderRouting?
Section titled “folderRouting?”
optionalfolderRouting?:boolean
Automatically maps nested folders into subcommands and subcommand groups.
e.g. src/commands/config/set.ts becomes /config set.
Default
Section titled “Default”trueautoSync?
Section titled “autoSync?”
optionalautoSync?:boolean
Automatically sync Slash Commands to Discord on startup.
Disable this in production to prevent rate-limits, and use popii sync instead.
Default
Section titled “Default”true
optionalhelp?:boolean| {enabled?:boolean;command?:string;aliases?:string[]; }
Defined in: types.ts:721
Configure or disable the built-in /help command.
Set to false to disable it entirely, or an object to customise the command name and aliases.
status?
Section titled “status?”
optionalstatus?:string|string[]
Defined in: types.ts:730
Bot status/activity string. Pass an array to rotate between multiple statuses.
Supports template tokens: {{guilds}}, {{users}}, {{shardId}}.
statusInterval?
Section titled “statusInterval?”
optionalstatusInterval?:number
Defined in: types.ts:732
Interval in ms between status rotations when status is an array. Defaults to 30000.
plugins?
Section titled “plugins?”
optionalplugins?:PopiiPlugin<TState>[]
Defined in: types.ts:734
Plugins to load. Plugins run in list order (highest priority first within that order).
pluginCommands?
Section titled “pluginCommands?”
optionalpluginCommands?:object
Defined in: types.ts:749
Fine-grained control over commands that plugins bundle via their commands array.
User commands in src/commands/ always take priority regardless of this config.
disable?
Section titled “disable?”
optionaldisable?:string[]
Command names to suppress. The command won’t be registered or synced to Discord.
overrides?
Section titled “overrides?”
optionaloverrides?:Pick<PopiiCommandDefinition<any,any,PopiiLocals&Record<string,any>>,"name"> &Partial<Omit<PopiiCommandDefinition<any,any,PopiiLocals&Record<string,any>>,"name">>[]
Partial overrides merged on top of a plugin’s command definition.
Useful for changing permissions, cooldowns, or descriptions without a full fork.
The name field identifies which command to patch.
Example
Section titled “Example”pluginCommands: { // Suppress the economy daily command entirely disable: ['daily'], // Tighten permissions on the lastfm command without replacing it overrides: [{ name: 'lastfm', ownerOnly: true }],}autoDiscover?
Section titled “autoDiscover?”
optionalautoDiscover?:boolean
Defined in: types.ts:765
When true, Popii scans node_modules for installed popii-plugin-* packages
(identified by a "popii" field in their package.json) and loads them automatically.
Explicitly registered plugins in plugins always take precedence.
Default
Section titled “Default”falsepluginConfig?
Section titled “pluginConfig?”
optionalpluginConfig?:Record<string,unknown>
Defined in: types.ts:766
events?
Section titled “events?”
optionalevents?:object
Defined in: types.ts:768
Override the directory Popii scans for event files. Defaults to "./src/events".
optionaldir?:string
snaps?
Section titled “snaps?”
optionalsnaps?:object
Defined in: types.ts:772
Override the directory Popii scans for snap files. Defaults to "./src/snaps".
optionaldir?:string
middlewares?
Section titled “middlewares?”
optionalmiddlewares?:object
Defined in: types.ts:776
Override the directory Popii scans for middleware files. Defaults to "./src/middlewares".
optionaldir?:string
tasks?
Section titled “tasks?”
optionaltasks?:object
Defined in: types.ts:780
Override the directory Popii scans for task files. Defaults to "./src/tasks".
optionaldir?:string
locales?
Section titled “locales?”
optionallocales?:object
Defined in: types.ts:789
Localization configuration.
dir— directory containing<locale>.jsonfiles. Defaults to"./src/locales".default— fallback locale code. Defaults to"en-US".url— remote URL to fetch locale files from (fetched at startup).
optionaldir?:string
default?
Section titled “default?”
optionaldefault?:string
optionalurl?:string
logger?
Section titled “logger?”
optionallogger?:PopLogger
Defined in: types.ts:795
Custom logger implementation. Defaults to the built-in Popii logger.
logLevel?
Section titled “logLevel?”
optionallogLevel?:"debug"|"info"|"warn"|"error"
Defined in: types.ts:804
Minimum log level to emit. Messages below this level are silently dropped.
"debug"— everything (verbose)"info"— info, warn, error (default)"warn"— warn and error only"error"— errors only
Default
Section titled “Default”"info"fileLogging?
Section titled “fileLogging?”
optionalfileLogging?:boolean
Defined in: types.ts:806
Write logs to rotating files in ./logs/. Defaults to false.
structuredLogs?
Section titled “structuredLogs?”
optionalstructuredLogs?:boolean
Defined in: types.ts:808
Emit log lines as newline-delimited JSON instead of human-readable text.
presenceStrategy?
Section titled “presenceStrategy?”
optionalpresenceStrategy?:"local"|"coordinated"
Defined in: types.ts:816
Controls how rotating status messages are coordinated across shards.
'local'(default): each shard rotates independently.'coordinated': shard 0 leads rotation and broadcasts the active status to all other shards via Redis pub/sub or IPC so they all show the same string. Supports template tokens:{{shardId}},{{guilds}},{{users}}.
stateTtlMs?
Section titled “stateTtlMs?”
optionalstateTtlMs?:number
Defined in: types.ts:818
TTL in milliseconds for persisted bot state in Redis/storage. Defaults to 90 days.
serverSettings?
Section titled “serverSettings?”
optionalserverSettings?:PopiiServerSetting[]
Defined in: types.ts:819