Skip to content

Getting Started

In this guide we will be making a few simple commands using aoi.canvas.

This guide assumes you have a basic understanding of aoi.js. It also assumes you defined your AoiClient as client

Installation

Terminal window
npm i @aoijs/aoi.canvas

Setup

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

Before creating your first image

In order to create images using aoi.canvas, we need to learn a few basic functions.

The following functions will be used in almost every sngle command:

We also need to know about:

  • $drawImage - to add external images. (like user avatars)
  • $fillRect - to draw rects on your canvas.
  • $fillText - to write text on your canvas.