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
npm i @aoijs/aoi.canvas
yarn add @aoijs/aoi.canvas
pnpm add @aoijs/aoi.canvas
Setup
1// Import packages2const { AoiClient } = require("aoi.js");3const { AoiCanvas } = require("aoi.canvas");4
5// Aoi.js client6const 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.canvas21const 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:
- $createCanvas - to create canvases.
- $attachCanvas - to send canvases.
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.