Addon class

The Addon class extends the NodeJS built-in EventEmitter class.

const addon = new Addon({
    name: string,
    description: string,
    author: string,
    version: string,
    permissions: [number]
});

constructor

The Addon class requires one argument in the constructor which is an object with information about the addon. The object must contain the following information:

  • name: The name of your addon to communicate to the owner of the bot. A string between 1-50 characters.

  • description: A brief description about what your addon does to communicate to the owner of the bot. A string between 1-100 characters.

  • author: The (user)name of the author of your addon to communicate to the owner of the bot. A string between 1-50 characters.

  • version: The version of your addon to communicate to the owner of the bot. A string between 1-10 characters.

  • permissions: An array with the permissions your addon requires in order to functionate.

Properties

name

The name of the addon which was provided in the constructor.

description

The description of the addon which was provided in the constructor.

author

The author of the addon which was provided in the constructor.

version

The version of the addon which was provided in the constructor.

permissions

A number which defines which permissions the addon has based on the permissions which were provided in the constructor.

ready

A boolean which defines whether the addon was accepted by the owner and can be used.

guilds

A save which provides the guilds the bot has access to.

Save<id(string), Guild>

channels

A save which provides the channels the bot has access to.

Save<channelId, TextChannel | VoiceChannel | CategoryChannel | StageChannel | DirectoryChannel | ForumChannel | ThreadChannel | DMChannel>

commands

A save which provides the commands that have been created by the addon.

Save<command name(string), CommandHandler>

Functions

createCommand

addon.createCommand(command: CommandBuilder) : Promise<CommandHandler>;

Creates a new command with the data of the CommandBuilder and returns a Promise which returns a CommandHandler once the Promise is fulfilled.

removeCommand

addon.removeCommand(commandName: string) : Promise<void>;

Removes a command which was created earlier by the same addon. The function returns a Promise which will be fulfilled once the command has been deleted.

getCommandData

addon.getCommandData(commandName: string) : Promise<{
    name: string;
    description?: string;
    nsfw: boolean;
    dm_permission: boolean;
    permissions?: string | null | undefined;
    overwrite: boolean;
    category: string;
    options: [{
            name: string;
            description: string;
            options: [];
            nsfw: boolean;
            permission: string;
            default_member_permissions: boolean;
            overwrite: boolean;
            category: "General" | "Polls" | "Games" | "Fun" | "Giveaway" | "Music" | "Moderation" | "Economy" | "Level" | "Tickets" | "Bot" | "Admin";
    }]
} | undefined>;

Gets the information about a certain command. This is the raw data for a CommandBuilder class which can be used in the constructor to build a command.

createEventListener

addon.createEventListener() : EventEmitter;

Returns an EventEmitter which gets emitted when certain events happen. Only the events where your addon has permissions for, will be emitted. You can see here which events there are and which permissions are required for the events.

createCommandListener

addon.createCommandListener() : EventEmitter;

Returns an EventEmitter which gets emitted when a command gets executed. The addon needs the COMMANDS permission for the EventEmitter to emit events. The event name is the same as the command's name.

Listener parameters:

getBot

addon.getBot() : Promise<Bot>;

Returns a Promise which returns a Bot class once the Promise is fulfilled. To fulfill the Promise, your addon needs the BOT permission.

getHTTPServer

addon.getHTTPServer() : Promise<HTTPServer>;

Returns a Promise which returns a HTTPServer. The HTTPServer will be returned if a port is set by the owner of the bot for the HTTP server to listen to and if the addon has the SERVERS permission. The HTTPServer listens to GET and POST requests and can respond to them.

getWSServer

addon.getWSServer() : Promise<WebSocketHandler>;

Returns a Promise which returns a WebSocketHandler. The WebSocketHandler will be returned if a port is set by the owner of the bot for the WebSocket server to listen to and if the addon has the SERVERS permission. The WebSocketHandler allows for client users to connect with a WebSocket server and to communicate between the server and client user.

getRawSaves

addon.getRawSaves() : Promise<object>;

Returns a Promise which returns an object with the raw data of the saves of the bot. The Promise will be fulfilled if the addon has the SAVES permission. The object has the following structure:

{
    tickets: Save<user id(string), [object]>,
    level: Save<user id(string), [object]>,
    economy: Save<user id(string), [object]>,
    afk: Save<user id(string), [object]>,
    badwords: Save<server id(string), [string]>,
    giveaways: Save<message id(string), object>,
    reactrole: Save<message id(string), [object]>,
    suggestions: Save<message id(string), object>,
    warns: Save<user id(string), [object]>
}

Events

Last updated