Skip to content

1) Setup

BaumianerNiklas edited this page Jul 18, 2022 · 7 revisions

Installation

First you'll need to install iubus and discord.js via your package manager of choice. Be sure that your discord.js version always matches the discord.js version Iubus uses, otherwise things, especially typings, will probably break (iubus should pretty much always be up-to date and use the latest discord.js release). Also note that iubus does NOT work with discord.js v13 or lower.

npm i discord.js iubus

Iubus is ESM only, as it is written in ESM itself. This means you cannot use this library if you're using CJS (i.e. require syntax). For a migration guide and further reasons, see here and here.

Setting up Iubus

To get started with Iubus, you will have to tell it some things about how your project is structured (like where your command files live). This is really simple and only consists of constructing a new IubusClient object and logging it in with the usual #login method. This IubusClient acts as your discord.js client and an entry point to Iubus that controls everything needed for the framework to function. You should do this in your entry file:

import { IubusClient } from "iubus";

const client = new IubusClient({
    intents: /* ... */,
    dirs: {
        commands: "./dist/commands/",
        events: "./dist/events/",
        iubusEvents: "./dist/iubusEvents/",
        inhibitors: "./dist/events/",
    },
    deploy: {
        token: "YOUR_TOKEN",
        applicationId: "YOUR_APPLICATION_ID",
        guildId: "YOUR_GUILD_ID", // will be ignored if `deployGlobally` is set to true
        deployGlobally: true, // defaults to false
        deployOnChange: true, // re-deploy commands whenever Iubus detects a change in the command data
    },
});

client.login("YOUR_TOKEN");

And that's all that should be necessary for setting up Iubus! Upon calling #login, Iubus automatically scans your command directory (if one is provided) and looks for exports that are Commands (and the same for events). It also automatically attaches an interactionCreate listener to your client required for Iubus to function that deals with processing interactions.

Note for the *Dir properties: These have to be relative to where you start your node process. So, if you start your process at /path/to/project/, then, with the above example, Iubus will scan /path/to/project/dist/commands/ for command files.

IubusClientOptions

The options that can be passed into the constructor when creating a new IubusClient are all the standard ClientOptions for a standard discord.js Client plus...

  • dirs? - DirectoryOptions: Contains the various directories your project is made up of.
    • dirs.commands? - string: The path to the directory containing your command files.
    • dirs.events? - string: The path to the directory containing your event files.
    • dirs.iubusEvents? - string: The path to the directory containing your iubus event files, see the IubusEvents section
    • dirs.inhibitors? - string: The path to the directory containing your inhibitor files, see the Inhibitor section
  • deploy? - DeployOptions & { deployOnChange?: boolean }: See the Command Deployment section
Clone this wiki locally