You can install the package using npm:
npm install @aoijs/aoi.plugins
const {AoiClient} = require("aoi.js");
const {PluginManager} = require("@aoijs/aoi.plugins");
const bot = new AoiClient({
token: "DISCORD BOT TOKEN",
prefix: "DISCORD BOT PREFIX",
intents: ["MessageContent", "Guilds", "GuildMessages"],
events: ["onMessage"],
database: {
type: "aoi.db",
db: require("@aoijs/aoi.db"),
tables: ["main"],
path: "./database/",
extraOptions: {
dbType: "KeyValue"
}
}
});
// Ping Command
bot.command({
name: "ping",
code: `Pong! $pingms`
});
const pluginManager = new PluginManager(bot);
pluginManager.loadPlugins("default/comment"); //Loads the from the default folder ($comment function)
The Plugins class provides a way to load and manage plugins for your Discord bot.
To load plugins:
pluginManager.loadPlugins(
"default/os",
"default/comment",
)
or
pluginManager.load(); // if plugins are added via command line interface
To create your own plugins you can use the command line interface.
npx aoilib create username/pluginname
This will generate a boilerplate project for your plugin.
After adding your code to the plugin you can prepare it for library by using the command line interface.
npx aoilib bundle username/pluginname
This will generate a bundle file for your plugin which can be used in the library.
To add your plugins to the library, you can add via Pull Request on the GitHub Repository.
You can also add plugins via the command line interface.
npx aoilib add default/os default/comment
This will add the plugins to aoijs.plugins
file
As well the setup must change if you this method.
const pluginManager = new PluginManager(bot);
- pluginManager.loadPlugins(
- "default/os",
- "default/comment",
- ); // Load all Plugins Functions from @aoijs/aoi.plugins
+ pluginManager.load();