Skip to content

Getting Started

To get started with aoi.js, you will need to install the package. You can do so by running the following command in your terminal.

    • using the package manager of your choice, run the following command to install aoi.js.
    Terminal window
    npm install aoi.js

  1. After doing so you will need to create an application from the Developer Portal and get the bot token from there.

    • Make sure all the intents are enabled, as some functions require them. If you can’t do so then ignore this step.
    • Copy the Discord Bot Token for later.

  2. Before we get started, create a new file called index.js within your project folder. This will be the main file for your bot.

    • index.js
    • package.json
    • Directorynode_modules

    To get the bot running we need to create a new instance of the AoiClient class. This class is the main class for the bot and is used to interact with the Discord API.

    Basically this will be the content of your index.js file.

    index.js
    1
    const { AoiClient } = require("aoi.js");
    2
    3
    const client = new AoiClient({
    4
    token: "Discord Bot Token",
    5
    prefix: "Discord Bot Prefix",
    6
    intents: ["MessageContent", "Guilds", "GuildMessages"],
    7
    events: ["onMessage", "onInteractionCreate"],
    8
    database: {
    9
    type: "aoi.db",
    10
    db: require("@akarui/aoi.db"),
    11
    dbType: "KeyValue",
    12
    tables: ["main"],
    13
    securityKey: "a-32-characters-long-string-here"
    14
    }
    15
    });

    The token part is where your Discord Bot Token goes, which you previously copied from the Developer Portal.

    index.js
    1
    token: "Your Discord Bot Token"

    The prefix part is where your bot’s prefix goes, you can even have multiple prefixes.

    1
    // To have one prefix
    2
    prefix: "Your Discord Bot Prefix"
    3
    4
    // You can also have multiple prefixes
    5
    prefix: ["Your Prefix", "Another Prefix"]

    Now we can run our bot, but there isn’t any functionality yet.

    Continue to the next page to learn how to add commands to your bot.

Already know how to use commands? Continue to the next page to learn how to use events.