Skip to content

Getting Started

To get started, we need to create a Discord Bot.

  1. Go to the Discord Developer Portal.
  2. Choose a cool name for your new Discord Bot.
  3. Accept Discord’s ToS.
  4. Click on the “Create” button.

Discord Developer Portal showing the "New Application" button
Discord Developer Portal showing the “New Application” button

Now you have created your Discord Bot. Next, we’re going to allow some intents for the bot so it can read our messages.


  1. Head to the “Bot” tab on the left sidebar.
Discord Developer Portal showing the "Bot" tab
Discord Developer Portal showing the “Bot” tab
  1. Scroll down until you see “Privileged Gateway Intents”.
  2. Check all three Intents.
Discord Developer Portal showing the "Privileged Gateway Intents" section
Discord Developer Portal showing the “Privileged Gateway Intents” section


Now we need to invite our newly created bot to our server!

  1. Go to the “OAuth2” tab on the left sidebar.
Discord Developer Portal showing the "OAuth2" tab
Discord Developer Portal showing the “OAuth2” tab
  1. Scroll down until you see “OAuth2 URL Generator”.

Check the following scopes:

  • bot
  • application.commands

Preferably, you should also check the “Administrator” permission to avoid any permission issues.

Discord Developer Portal showing the "OAuth2 URL Generator" section
Discord Developer Portal showing the “OAuth2 URL Generator” section
  1. Copy the generated URL and paste it into your browser and select the server you want to invite the bot to.
Showing how to Invite the bot
Showing how to Invite the Bot

You should now see your bot in your invited server. Next, we will set up a project to start coding our bot.

Showing the bot in the server
Showing the bot in the server


The last thing to do is getting our new bot up and running. But first, let’s get our Discord Bot Token.

  1. Go back to the Developer Portal.
  2. Go to the “Bot” tab on the left sidebar.
  3. Reset the token.
Discord Developer Portal showing the "Bot" tab
Discord Developer Portal showing the “Bot” tab
  1. Copy the Token, and keep it safe.

Now that we have our bot token, we can start coding our bot.

We are going to use Visual Studio Code for this, you can however use any code editor you prefer.

  1. Open Visual Studio Code.

Choose what option you want to use.

  1. Open a new terminal.

    Opening a new terminal
    Opening a new terminal
  2. Run the following command to create a new project:

Installing aoi.cli and starting a new project
npx @akarui/aoi.cli create

This might take a while, depending on your internet connection.

Running CLI
Running CLI
  1. You will be asked to enter your bot token. Paste the token you copied earlier.
  • Head to the created index.js file, you should see a couple of placeholders.

You need to replace the DISCORD BOT TOKEN with the token you copied earlier, and the DISCORD BOT PREFIX with the prefix you want to use for your bot.

Adding the base of your bot
Adding the base of your bot

To continue with this guide, follow this link.


To start from scratch we need to manually create our files and folders.

  1. Create a new folder for your project.
  2. Open the folder in Visual Studio Code.
  3. Create a commands folder.
  4. Create a index.js file.
Creating a new folder
Creating a new folder
  1. Run npm init -y in the terminal to create a package.json file.

Make sure you’re in the project folder before running the command.

Running cd
Running cd
  1. Install the aoi.js package by running the following command:

    You can use either npm, pnpm, yarn, or bun to install the package. If you don’t know what to use, you can use npm.

Terminal window
npm install aoi.js
Running npm install
Running npm install

Your file structure should look like this:

File Structure
File Structure
  1. We now need to add the base of your bot.
  • This is the code that will be in your index.js file.
  • You require the previously copied token!
  • You can ignore everything else for now besides the token.
index.js
1
const { AoiClient } = require("aoi.js");
2
3
const client = new AoiClient({
4
token: "Discord Bot Token", // Here goes the Token you copied earlier!
5
prefix: "!", // Here goes the prefix you want to use for your bot!
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
});
16
17
// Ping Command which responds when doing "!ping"
18
client.command({
19
name: "ping",
20
code: `Pong! $pingms`
21
});
22
23
client.loadCommands("./commands");
Adding the base of your bot
Adding the base of your bot

To continue with this guide, follow this link.



Now that we have the base of our bot, let’s create our first command.

  1. Create a new file in the commands folder.
  2. Name the file avatar.js.

We will now use several functions to return the avatar of the user who used the command.

avatar.js
1
module.exports = {
2
name: "avatar",
3
code: `
4
$author[$username's Avatar!]
5
$color[Random]
6
$image[$authorAvatar]
7
$footer[Requested by $username]
8
$addTimestamp
9
`
10
};
Creating the avatar command
Creating the avatar command

Now that we have our bot set up, we can run it.

Head back to your terminal and run the following command:

Running the bot
node index.js

This will run our bot, and you should see it come online in your server.

When running !avatar or !ping in your server, you should see the bot respond with the avatar of the user who used the command or with “Pong!“.