Main constructor - Paultje52/BananenBase GitHub Wiki

To use the BananenBase, you must call a BananenBase class constructor (https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes).

Loading the BananenBase package:

const BananenBase = require("bananenbase");

Next, you need to construct BananenBase.

// Load in the package
const BananenBase = require("bananenbase");

// Constructing the base
let myBot = new BananenBase("TOKEN");

Console.warn

The BananenBase changes the console.warn function. It adds a yellow prefix ([Warn]) before the message.

addModule()

After you created your bot, you can add modules. By default, only the start module is loaded. Use the .addModule function to add a module.
You can click here to see a list of all the modules! Want to make your own module? Take a look at this!

Take a look at the documentation of the modules to see what each module does and how you can use it.

Warning: You can also enable modules made by other users. Those modules can be harmful. Only load modules from third-parties if you’re sure what you're doing!!!

A module has to be a class or string you can load multiple modules at once in an array.

Full function: myBot.addModule("MODULE", {module: "options"}) However we recommend to use the config.

The option parameter needs to be an object. You can also use your config, take a look at the setConfig function.

Example

// Load in the package
const BananenBase = require("bananenbase");

// Constructing the base
let myBot = new BananenBase("TOKEN");

// Adding the "loader" module with a command option.
myBot.addModule("loader", {
  commands: "/commands"
});

setConfig()

You can also set a config for your bot.

The BananenBase uses one option: prefix. This needs to be a string. It's the prefix used for all your commands.

You can add an object, named modules for module configuration. In this object, make objects with the name of your module. Within this object you can set your options.

The setConfig() function wants an object. You can make the object in the same file, or you can load the config from an external JSON file with NodeJS's require("filename").

Example

This example has !!! as prefix, and for the loader module the command in the config.

// Load in the package
const BananenBase = require("bananenbase");

// Constructing the base and add the config
let myBot = new BananenBase("TOKEN").setConfig({
  prefix: "!!!",
  modules: {
    loader: {
      command: "/commands"
    }
  }
});
// Or: .setConfig(require("./config.json"));

// Loading the modules
myBot.addModule(["loader"]);

Ready()

When you've added all your modules, you have to wait untill the bot is ready. This can be with an await keywoard (keep in mind your function needs to be async to use await!) or a callback.

When the BananenBase is ready, your bot won't be online yet! Use the Start Module to start your bot!

Example

// Load in the package
const BananenBase = require("bananenbase");

// Constructing the base and add the config
let myBot = new BananenBase("TOKEN");

// When the BananenBase is ready
myBot.ready(() => {
  // TODO: Start your bot!
});

API reference

Class: BananenBase

Methods

.set(KEY, Value) > Sets a key to a value, same as BananenBase. =

.addModule(Module||Array, options: {}) > Adds one or multiple modules. A module can be a string or a class. Also gives options for that module.

.setConfig(config: {}) > Adds the config to BananenBase

.ready(callback) > Do something when BananenBase is ready

Variables

token > Your bot's token

loading > If the BananenBase is loading something, this is a boolean

toConfigure > An object with the module names that BananenBase is configuring

commandChecks > An array with functions that will be executed when a command is runned

modules > An array with all the loaded modules

config > An object with the bot's config

⚠️ **GitHub.com Fallback** ⚠️