ZombieClient Class
The ZombieClient class extends the standard Client from discord.js. It acts as the kernel that orchestrates all your registered loaders.
Constructor
typescript
import ZombieClient from '@thezombiepl/zombieclient';
import { GatewayIntentBits } from 'discord.js';
import { CommandLoader, EventLoader } from '@thezombiepl/zombieclient/loaders';
const client = new ZombieClient({
intents: [GatewayIntentBits.Guilds],
ownerId: '123456789012345678', // Optional: Bot owner Discord ID
loaders: [ // Optional: Array of ILoaders to register
new CommandLoader(path.resolve(process.cwd(), 'src/commands'), {
autoDeploy: true,
}),
new EventLoader(path.resolve(process.cwd(), 'src/events')),
],
});Properties
| Property | Type | Description |
|---|---|---|
colors | typeof BOT_COLORS | A set of predefined hex colors for embeds. |
ownerId | string | undefined | The ID of the bot developer. Used for commands with dev: true. Falls back to process.env.OWNER_ID. |
loaders | ILoader[] | An array of all currently registered plugins/loaders. |
Methods
login(token?: string): Promise<string>
Initializes all registered loaders (creates a shared FileLoader, calls load(ctx) on each loader sequentially), then logs in to Discord. If any loader throws, login() fails with the error.
typescript
await client.login(process.env.TOKEN);registerLoaders(loaders: ILoader[]): void
Registers an array of loaders. This does not initialize them, it only pushes them into the loaders array. Useful for dynamic/conditional registration.
typescript
if (isDev) {
client.registerLoaders([new DebugLoader()]);
}getLoader<T>(name: string): T | undefined
Retrieves a registered loader by its name property. Useful if one loader needs to access another loader at runtime.
typescript
const cmdLoader = client.getLoader<CommandLoader>('CommandLoader');