Skip to content
On this page

Main

ts
import { ... } from "cocoa-discord";

This module contains general utilities class and functions that will help you save time writing your bots

Note: This documentation/guide is partially done.

Table of Contents

[Class] CocoaEmbed

CocoaEmbed is a class that derived Embed from @discordjs/builders

Guild for Embed from discord.js

Full implementation See Code

ts
/**
 * Extended {@link EmbedBuilder} with {@link addInlineFields}.
 * This allow you to save a line of `inline: true`
 */
export class CocoaEmbed extends EmbedBuilder {
  /** Adds fields to the embed (max 25), automatically set inline to true */
  addInlineFields(...fields: Array<Omit<APIEmbedField, "inline">>) {
    return this.addFields(
      fields.map((field) => {
        return {
          ...field,
          inline: true,
        };
      }),
    );
  }
}

[Function] setConsoleEvent

Full Implementation, does what it say

ts
/**
 * On Enter in Console
 *
 * *The full implementation*
 *
 * ```ts
 * export function setConsoleEvent(handler: (cmd: string) => void) {
 * rl.on("line", (cmd: string) => {
 *     handler(cmd);
 *  });
 * }
 * ```
 */
export function setConsoleEvent(handler: (cmd: string) => void) {
  getReadlineInterface().on("line", (cmd: string) => {
    handler(cmd);
  });
}

Trigger handler everytime you press enter in the console

[Class] ConsoleManager

Allow you to add command into console, the class also provide template for logout and reload command

Example Usage

ts
new ConsoleManager().useLogout(client).useReload(activity);

For full list of functions, please look at TypeDoc

Documentation generated by Vitepress. This project/library is released under the MIT License