Skip to content

API Usage & AI Chatbot [Aoi.js]

The Arcwise Domain

This will show you Code for AI Chatbot and you will also get an Text Version of Tutorial for API Usage, originally you could also watch the video! Your Folder should be like this:

  • AI-Chatbot
    • ai.js

Code

index.js - Variables

client.variables({
api: "API Key"
})

variables.js - Variables Requires require("./variables.js")(client); in index.js

module.exports = (client) => {
client.variables({
api: "API Key"
}, "main");
};

index.js

const { AoiClient } = require("aoi.js");
const client = new AoiClient({
token: "Your Token",
prefix: "Your Prefix",
intents: ["MessageContent", "Guilds", "GuildMessages"],
events: ["onMessage", "onInteractionCreate"],
database: {
type: "aoi.db",
db: require("@aoijs/aoi.db"),
dbType: "KeyValue",
tables: ["main"]
}
});
client.command({
name: "ping",
code: `Pong! $pingms`
});
client.variables({
api: "Your API Key"
})
client.status({
name: "dsc.gg/arcwisedomain",
type: 'STREAMING',
time: 12,
status: "idle",
url: "https://dsc.gg/arcwisedomain"
})
client.loadCommands("./commands", true);

ai.js

module.exports={
name: "$alwaysExecute",
code: `
$description[$getObjectProperty[response;message.content]]
$color[White]
$createObject[response;$httpRequest[https://rialabs.xyz/api/chatgpt;POST;
{
"prompt": "Your name is Blume, you are a kind and helpful bot! JosipFX is your Creator, AudiRo has assisted by sharing API",
"content": "$message"
};;;
{
"Authorization": "$getVar[api]",
"Content-Type": "application/json"
}]]
$clientTyping
$cooldown[2s;Please wait a bit.]
$onlyForChannels[channelid;]` //Channel where you will chat with Bot
}

Explanation

  • This section will try its best to explain how each code works above, things you should know.

API Usage

  • “GET” Request
    • $httpRequest[https://apiwebsite.com/information;GET;body? (content);property to return?;Error has occured;header? (not needed)] We use this function to retrieve Data from an API, it is an easiest way to retrieve Data and use it! Check video for an Example
  • “POST” Request
    • $httpRequest[https://apiwebsite.com/information;POST;{ "data": "This is a POST request!"};;Error has occured;{ "Accept": "application/json}", "Content-Type": "application/json"] We use this function to Send / Edit Data on API, Headers are required or else it won’t work, some require putting API Key to authorize.
  • “DELETE” Request
    • $httpRequest[https://apiwebsite.com/information;DELETE] We use this function to Delete Data on API, you can specify what to delete in “Body” or you can delete it all!

AI

  • There is not much to explain here but I will give some explanations

How does it work?

  1. We use $httpRequest (POST) to Send Data to AI which then returns back the message
  2. To Prevent whole object being sent, we use $createObject[response;$httpRequest] which creates an object and doesn’t send until you request it with another function
  3. Make output prettier, use $description etc, to request the AI’s response you can use $getObjectProperty[response;message.content]
  • Note: You can edit prompt to whatever you want! After all you need to train it, if you don’t know how to start, start with “Your creator is .. | You were made on 9.1.2025”, just make sure you are using third person!

End

  • Thanks to anyone who is still Following me on Youtube Channel and actually uses codes I make, appreciate that!
  • Hope you learned how to use API in Aoi.js and also how to make an AI Chatbot :D

Credits

JosipFX - Made Code & Video