Popii - v0.5.1
    Preparing search index...

    Interface Pop<TState, TInput, TLocals>

    The full execution context provided to command and snap handlers.

    Extends EventPop with interaction-specific members: reply(), defer(), options (typed slash command arguments), input (schema-validated input), and references to the raw interaction and message objects.

    Use the TInput type parameter when you supply a schema to the command — the validated result is then available as pop.input with full type inference.

    async do(pop) {
    await pop.reply({
    embeds: [{ title: "Hello!", description: `Hey ${pop.user.username}` }],
    ephemeral: true
    });
    }
    async do(pop) {
    await pop.defer();
    const result = await someSlowOperation();
    await pop.reply(result);
    }
    interface Pop<
        TState = any,
        TInput = any,
        TLocals = PopiiLocals & Record<string, any>,
    > {
        ai: {
            generate(prompt: string): Promise<string>;
            chat(
                history: { role: "user" | "system" | "assistant"; content: string }[],
            ): Promise<string>;
        };
        canvas: {
            create(width: number, height: number): Promise<CanvasBuilder>;
            nowPlayingCard(
                track: NowPlayingTrack,
                opts?: NowPlayingCardOptions,
            ): Promise<AttachmentBuilder>;
        };
        captcha: { sendVerificationPanel(channelId: string): Promise<void> };
        desk: {
            sendPanel(channelId: string): Promise<void>;
            closeTicket(): Promise<void>;
        };
        economy: {
            currencyName: string;
            getProfile(
                userId: string,
            ): Promise<
                | { xp: number; level: number; balance: number; last_daily: number }
                | null,
            >;
            addXp(userId: string, amount: number): Promise<boolean>;
            addBalance(userId: string, amount: number): Promise<void>;
        };
        giveaways: {
            start(
                channelId: string,
                prize: string,
                winners: number,
                durationMs: number,
            ): Promise<void>;
        };
        lastfm: {
            getAccount(
                userId: string,
            ): Promise<{ username: string; sessionKey: string } | null>;
        };
        mongoose: __module;
        db: Database;
        success(message: string): Promise<void>;
        error(message: string): Promise<void>;
        info(message: string): Promise<void>;
        paginate(
            source:
                | EmbedBuilder[]
                | {
                    fetch: (page: number) => Promise<EmbedBuilder | null>;
                    totalPages?: number;
                },
            timeoutMs?: number,
        ): Promise<void>;
        prompt(
            embed: EmbedBuilder,
            buttons: string[],
            timeoutMs?: number,
        ): Promise<string | null>;
        form(
            title: string,
            fields: FormField[],
            timeoutMs?: number,
        ): Promise<Record<string, string> | null>;
        awaitMessage(timeoutMs?: number, promptMessageId?: string): Promise<any>;
        wizard(
            steps: WizardStep[],
            timeoutMs?: number,
        ): Promise<Record<string, string> | null>;
        joinVoice(): Promise<any>;
        playAudio(
            urlOrStream: any,
        ): Promise<{ player: any; title: string; metadata?: any }>;
        leaveVoice(): Promise<void>;
        getQueue(): any[];
        getNowPlaying(): | {
            title: string;
            artist: string;
            duration: string;
            thumbnail?: string;
            requestedBy?: string;
            elapsedMs: number;
            elapsed: string;
            progress: number;
        }
        | null;
        getNowPlayingCard(
            opts?: { accentColor?: string },
        ): Promise<AttachmentBuilder | null>;
        sponsorblock: {
            isEnabled(): boolean;
            setEnabled(enabled: boolean): void;
            getCategories(): string[];
            setCategories(cats: string[]): void;
            forceSkip(): Promise<boolean>;
        };
        client: PopiiClient<TState>;
        locale: string;
        log: PopLogger;
        createAttachment(path: string, name?: string): any;
        fetchJSON<T = unknown>(
            url: string | Request | URL,
            init?: RequestInit,
        ): Promise<T>;
        fetchText(url: string | Request | URL, init?: RequestInit): Promise<string>;
        fetchBuffer(
            url: string | Request | URL,
            init?: RequestInit,
        ): Promise<ArrayBuffer>;
        fetchForm<T = unknown>(
            url: string | Request | URL,
            data: FormData,
            init?: RequestInit,
        ): Promise<T>;
        cache<T>(
            key: string,
            ttlMs: number,
            fetcher: () => T | Promise<T>,
        ): Promise<T>;
        translate(key: string, args?: Record<string, any>): string;
        t(key: string, args?: Record<string, any>): string;
        cooler: {
            get<T = any>(key: string): Promise<T | null>;
            set(key: string, value: any, ttlMs?: number): Promise<void>;
            delete(key: string): Promise<void>;
        };
        pack(customId: string, data: any): string;
        state: TState;
        locals: TLocals;
        guild: Guild | null;
        channel: TextBasedChannel | null;
        schedule(taskName: string, payload?: any, delayMs?: number): Promise<void>;
        reply(
            payload:
                | string
                | {
                    content?: string;
                    embeds?: any[];
                    components?: any[];
                    files?: any[];
                    ephemeral?: boolean;
                },
        ): Promise<any>;
        defer(options?: { ephemeral?: boolean }): Promise<void>;
        respond(choices: { name: string; value: string | number }[]): Promise<void>;
        respondFiltered(
            choices: { name: string; value: string | number }[],
            userInput: string,
        ): Promise<void>;
        user: User;
        member: GuildMember | APIInteractionGuildMember | null;
        options: PopOptions;
        input: TInput;
        interaction?: Interaction | MessageComponentInteraction<CacheType>;
        message?: Message<boolean>;
        snapMatches?: RegExpMatchArray | null;
        snapData?: any;
        targetMessage?: Message<boolean> | null;
        targetUser?: User | null;
    }

    Type Parameters

    • TState = any
    • TInput = any
    • TLocals = PopiiLocals & Record<string, any>

    Hierarchy (View Summary)

    Index

    Methods

    • Parameters

      • source:
            | EmbedBuilder[]
            | {
                fetch: (page: number) => Promise<EmbedBuilder | null>;
                totalPages?: number;
            }
      • OptionaltimeoutMs: number

      Returns Promise<void>

    • Parameters

      • embed: EmbedBuilder
      • buttons: string[]
      • OptionaltimeoutMs: number

      Returns Promise<string | null>

    • Parameters

      • title: string
      • fields: FormField[]
      • OptionaltimeoutMs: number

      Returns Promise<Record<string, string> | null>

    • Parameters

      • OptionaltimeoutMs: number
      • OptionalpromptMessageId: string

      Returns Promise<any>

    • Parameters

      • steps: WizardStep[]
      • OptionaltimeoutMs: number

      Returns Promise<Record<string, string> | null>

    • Parameters

      • urlOrStream: any

      Returns Promise<{ player: any; title: string; metadata?: any }>

    • Returns
          | {
              title: string;
              artist: string;
              duration: string;
              thumbnail?: string;
              requestedBy?: string;
              elapsedMs: number;
              elapsed: string;
              progress: number;
          }
          | null

    • Parameters

      • Optionalopts: { accentColor?: string }

      Returns Promise<AttachmentBuilder | null>

    • Type Parameters

      • T = unknown

      Parameters

      • url: string | Request | URL
      • Optionalinit: RequestInit

      Returns Promise<T>

    • Parameters

      • url: string | Request | URL
      • Optionalinit: RequestInit

      Returns Promise<string>

    • Parameters

      • url: string | Request | URL
      • Optionalinit: RequestInit

      Returns Promise<ArrayBuffer>

    • Type Parameters

      • T = unknown

      Parameters

      • url: string | Request | URL
      • data: FormData
      • Optionalinit: RequestInit

      Returns Promise<T>

    • Type Parameters

      • T

      Parameters

      • key: string
      • ttlMs: number
      • fetcher: () => T | Promise<T>

      Returns Promise<T>

    • Parameters

      • key: string
      • Optionalargs: Record<string, any>

      Returns string

    • Parameters

      • key: string
      • Optionalargs: Record<string, any>

      Returns string

    • Parameters

      • customId: string
      • data: any

      Returns string

    • Parameters

      • taskName: string
      • Optionalpayload: any
      • OptionaldelayMs: number

      Returns Promise<void>

    • Parameters

      • payload:
            | string
            | {
                content?: string;
                embeds?: any[];
                components?: any[];
                files?: any[];
                ephemeral?: boolean;
            }

      Returns Promise<any>

    • Parameters

      • Optionaloptions: { ephemeral?: boolean }

      Returns Promise<void>

    • Parameters

      • choices: { name: string; value: string | number }[]

      Returns Promise<void>

    • Parameters

      • choices: { name: string; value: string | number }[]
      • userInput: string

      Returns Promise<void>

    Properties

    ai: {
        generate(prompt: string): Promise<string>;
        chat(
            history: { role: "user" | "system" | "assistant"; content: string }[],
        ): Promise<string>;
    }
    canvas: {
        create(width: number, height: number): Promise<CanvasBuilder>;
        nowPlayingCard(
            track: NowPlayingTrack,
            opts?: NowPlayingCardOptions,
        ): Promise<AttachmentBuilder>;
    }
    captcha: { sendVerificationPanel(channelId: string): Promise<void> }
    desk: {
        sendPanel(channelId: string): Promise<void>;
        closeTicket(): Promise<void>;
    }
    economy: {
        currencyName: string;
        getProfile(
            userId: string,
        ): Promise<
            | { xp: number; level: number; balance: number; last_daily: number }
            | null,
        >;
        addXp(userId: string, amount: number): Promise<boolean>;
        addBalance(userId: string, amount: number): Promise<void>;
    }
    giveaways: {
        start(
            channelId: string,
            prize: string,
            winners: number,
            durationMs: number,
        ): Promise<void>;
    }
    lastfm: {
        getAccount(
            userId: string,
        ): Promise<{ username: string; sessionKey: string } | null>;
    }
    mongoose: __module
    db: Database
    sponsorblock: {
        isEnabled(): boolean;
        setEnabled(enabled: boolean): void;
        getCategories(): string[];
        setCategories(cats: string[]): void;
        forceSkip(): Promise<boolean>;
    }
    locale: string
    cooler: {
        get<T = any>(key: string): Promise<T | null>;
        set(key: string, value: any, ttlMs?: number): Promise<void>;
        delete(key: string): Promise<void>;
    }
    state: TState
    locals: TLocals
    guild: Guild | null
    channel: TextBasedChannel | null
    user: User
    member: GuildMember | APIInteractionGuildMember | null
    options: PopOptions
    input: TInput
    interaction?: Interaction | MessageComponentInteraction<CacheType>
    message?: Message<boolean>
    snapMatches?: RegExpMatchArray | null
    snapData?: any
    targetMessage?: Message<boolean> | null
    targetUser?: User | null