Popii - v0.5.1
    Preparing search index...

    Interface PopiiPlugin<TState>

    The interface all Popii plugins must implement.

    A plugin is a plain object returned from a factory function. It hooks into the client lifecycle via setup, ready, reload, and cleanup, and can also intercept every command execution via onCommandExecute and onCommandError.

    import type { PopiiPlugin } from "popii";

    export function myPlugin(): PopiiPlugin {
    return {
    name: "my-plugin",
    setup(client) {
    // runs once at startup — register listeners, create DB tables, etc.
    },
    ready(client) {
    // runs after Discord connects — safe to use client.discord.guilds.cache
    },
    cleanup(client) {
    // runs on graceful shutdown — clear intervals, close connections
    }
    };
    }
    interface PopiiPlugin<TState = any> {
        name: string;
        requires?: string[];
        conflicts?: string[];
        priority?: number;
        settingsSchema?: PopiiServerSetting[];
        setup(client: PopiiClient<TState>): void | Promise<void>;
        ready?(client: PopiiClient<TState>): void | Promise<void>;
        reload?(client: PopiiClient<TState>): void | Promise<void>;
        cleanup?(client: PopiiClient<TState>): void | Promise<void>;
        onCommandExecute?(
            pop: Pop<TState>,
            command:
                | PopiiCommandDefinition<
                    TState,
                    any,
                    PopiiLocals & Record<string, any>,
                >
                | PopiiComponentDefinition<
                    TState,
                    any,
                    PopiiLocals & Record<string, any>,
                >,
        ): void | Promise<void>;
        onCommandError?(error: unknown, pop: Pop<TState>): void | Promise<void>;
        onContextCreate?(pop: EventPop<TState>): void;
    }

    Type Parameters

    • TState = any
    Index

    Methods

    • Runs once at startup, before connecting to Discord. Register listeners and create DB tables here.

      Parameters

      Returns void | Promise<void>

    • Runs after the bot successfully connects to Discord. Safe to access guild and user caches.

      Parameters

      Returns void | Promise<void>

    • Called when a command or snap throws an unhandled error.

      Parameters

      Returns void | Promise<void>

    Properties

    name: string
    requires?: string[]

    Plugin names that must be loaded before this plugin. Popii throws at startup if any listed plugin is missing.

    conflicts?: string[]

    Plugin names this plugin cannot coexist with. Popii throws at startup if any listed plugin is also present.

    priority?: number

    Execution order during the setup lifecycle. Higher values run first.

    0
    
    settingsSchema?: PopiiServerSetting[]

    Declarative per-guild settings exposed in the web dashboard's server settings form. The category defaults to the plugin name if omitted.