Skip to content

Getting Started

@thezombiepl/zombieclient is a plugin-based framework built on top of discord.js v15. It provides a structured, loader-driven architecture for Discord bots.

Installation

The library requires discord.js v15 as a peer dependency.

bash
bun add @thezombiepl/zombieclient
bun add discord.js@15.0.0-dev.1784246195-c73e2a76d

Basic Setup

This is the canonical way to wire up a ZombieClient bot:

ts
import { GatewayIntentBits } from 'discord.js';
import 'dotenv/config';
import path from 'node:path';

import ZombieClient from '@thezombiepl/zombieclient';
import { CommandLoader, EventLoader, FileLoader } from '@thezombiepl/zombieclient/loaders';

const commandsDir = path.resolve(process.cwd(), 'src/commands');
const eventsDir = path.resolve(process.cwd(), 'src/events');

async function main() {
    // 1. Create the client
    const client = new ZombieClient({
        intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers],
        ownerId: process.env.OWNER_ID,
    });

    // 2. Create FileLoader via async factory
    const fileLoader = await FileLoader.create();

    // 3. Create loaders
    const commandLoader = new CommandLoader(client, fileLoader, commandsDir, {
        autoDeploy: true,
        useGlobal: true,
        defaultGuilds: [process.env.TEST_GUILD_ID!],
        defaultCooldown: 5,
    });
    
    const eventLoader = new EventLoader(client, fileLoader, eventsDir);

    // 4. Register all loaders
    client.registerLoaders([commandLoader, eventLoader]);

    // 5. Initialize (calls .load() on every registered loader)
    await client.init();

    // 6. Start listening for interactions
    commandLoader.listen();

    // 7. Login
    await client.login(process.env.TOKEN);
}

main().catch((error) => {
    console.error('[FATAL]', error);
    process.exit(1);
});

Wszelkie prawa zastrzeżone.