Update Guide: V3 to V4 - Paultje52/BananenBase GitHub Wiki
This is the update guild to update your code if you want to go to BananenBase V4.
V3 is still supported for security updates and bug fixes, but it won’t get new features. V4 is a compleat rewrite with many new and improved features, including a better documentation!
Content
Main class
Also, take a look at the Main Constructor Page
We made a module system, in stead of just throwing everything in one big piece of code. This gives users the ability to only load the modules that they need, and even make custom modules to fit there needs.
Constructor
When you’re making the bot, you don’t give up the whole settings object. You only give your bot token.
Old
new BananenBase({
token: “TOKEN”,
database: {...},
// Other settings
});
New
let myBot = new BananenBase(“TOKEN”);
// Load modules, wait for ready and start your boot
Modules
For more information, take a look at the Modules page!
Starting
The BananenBase don’t automatically start your discord bot. You have to wait until the BananenBase is ready, and then use the start module to start your bot. For more information, take a look at the Start Module Page.
The start module is the only module that loads by default. To load commands, databases, etc, you have to load the module for that, or make your own.
Old
new BananenBase({
token: “TOKEN”,
database: {...},
// Other settings
});
// Bot is online
New
let myBot = new BananenBase(“TOKEN”);
// Load modules
myBot.ready(() => {
// This code is executed when all the modules are ready!
myBot.start(); // Uses the start module
});
Loading commands and events
The BananenBase doesn’t load all the commands and events by default. You have to load the loader
module to load your commands and events. Take a look at the Loader module page for more information.
New
let myBot = new BananenBase(“TOKEN”);
myBot.addModule(“loader”, {
commands: “/commands”
// Add “events” option to load events
});
// Start when BananenBase is ready
Databases
Databases aren’t added yet. Please come back later!
Modules
Like I sad earlier, we now have a module—bases system. There are pre-made modules (Found on the Modules Page), but you can also make your own modules! For more information, take a look at by clicking here.
Commands
We didn’t change much to the commands. You still need a class for each command, and the parent class is still BananenBase.command
. We changed some small things to support modules.
- Aliases (subCommands) is a module, so it isn’t an option in the main settings anymore.
- Security options (Permission levels, permissions, etc) is also a module. — Command options for modules are for each module in a different object.
Command options for modules
When making your class constructor for your command, you give your parent class the client (now the BananenBase, but you don’t have to worry about that) basic help options and for each module a different object, like this: super(BananenBase, {HELP_OPTIONS}, {MODULE_1_OPTIONS}, {MODULE_2_OPTIONS}, etc)
.
A module options object needs to be this format.
{
name: “MODULE_NAME”,
value: {/* Options that the module wants */}
}
The value can be different depending on the module. For example, the alias module wants a string array with all the command’s aliases, like this: [“alias1”, “alias2”, “alias3”]
. Look at the module’s documentation for more information about what it wants.
Help options
This is a list with all the help options. The name is the only one that is required, because it’s used to check if the command needs to be executed.
super(BananenBase, {
// Help options
name: "STRING",
description: "STRING",
enabled: BOOLEAN
});
BananenBase instead of client
When you’re command is constructed, you get the whole BananenBase object. The parent class will set the Discord.js client on this.client
and the BananenBase on this._BananenBase
.
This isn’t a big change, and you can just keep the name the same.
Ready
If you wanted to do some additional configuration for the command, in the command file, you would do it in the constructor. But because of the way the BananenBase handles errors in command constructors, this isn’t really that smart. Use the ready
method instead.
Old
class Command extends BananenBase.command {
constructor(client) {
super(client, {
name: "ping"
});
// Doing stuff
}
async run(message) {
// When the command is executed
}
}
New
class Command extends BananenBase.command {
constructor(client) {
super(client, {
name: "ping"
});
}
ready() {
// Do stuff here
}
async run(message) {
// When the command is executed
}
}
Events
Events haven’t changed at all, except for the BananenBase object instead of the client object, like it is explained here.