Documentation and tiny information | ||
---|---|---|
Methods | Description | Use |
SET | To set a value to a referenced key | client.db.db.set('table', 'key', 'value') |
GET | To get the value of a table | client.db.db.get('table', 'key').then(a => a.value) |
ALL | Returns all values of the reference | client.db.db.all('table').then(a => a.map(b => b.key)) |
DELETE | To delete all the values made in the reference, be it the whole table, ora directory further down | client.db.db.delete('table', 'key') |
Others | Description | Use |
PING | Requesting the database latency | client.db.db.ping() |
ARGSCOUNT | Counting arguments to the value of the requested key | client.db.db.argsCount('table', 'key') |
ISSTRING | Checking if the key value is a string | client.db.db.isString('table', 'key') |
ISNUMBER | Checking if the key value is a number | client.db.db.isNumber('table', 'key') |
A Firebase database of wrapper using aoi.fb as API
Node.JS 16.0.0 or newer is required.
npm install aoi.fb@latest
This file is mandatory and necessary for aoi.fb to work in aoi.jsV5! -- Why? Please look at the end of the README
Create a file in the root folder of your project (in the same folder where your index is) with the name: att.sh
Then add the code below into the file:
rm ./node_modules/aoi.js/src/classes/*
cp ./node_modules/aoi.fb/src/adjust/* ./node_modules/aoi.js/src/classes/
Then, in your index file, configure aoi.fb:
const aoifb = require("aoi.fb")
const firebase = aoifb.Create({
apiKey: "",
authDomain: "",
databaseURL: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: "",
measurementId: ""
})
const aoijs = require("aoi.js")
const bot = new aoijs.Bot({
token: "TOKEN", // Discord Bot Token
prefix: "PREFIX",// Discord Bot Prefix
intents: ["GUILDS", "GUILD_MESSAGES"], //Discord Bot Intents
database: {
type: "aoi.fb",
db: firebase
} // Change database to aoi.fb
})
// LoadCommands
const loader = new aoijs.LoadCommands(bot);
loader.load(bot.cmd, './Commands/', false)
// Events
bot.onMessage();
bot.onMessageUpdate();
bot.onMessageDelete();
bot.onInteractionCreate();
// Command Example for Database Latency
bot.command({
name: "ping",
code: `Pong!
> Bot Latency: $pingms
> Database Latency: $djsEval[client.db.db.ping();yes]`
})
bot.readyCommand({
channel: "",
code: `$log[Ready on $userTag[$clientID]]`
})
(Table)
main--
money--
key: money
value: 1000
prefix--
key: prefix
value: fb.
client.db.db.set('main', 'money', '1000') // Setting the value '1000' in the 'money' key that is in the 'main' table
// return: bolean (true)
client.db.db.get('main', 'money').then(a => a.value) // Asking for the value of the 'money' key
// return: '1000'
client.db.db.all('main').then(a => a.map(b => b.key)) // Requesting all keys and values within each of your 'main' tables
// return: [ 'money', 'prefix' ]
client.db.db.all('main').then(a => a.map(b => b.data.value)) // Requesting all values from your 'main' table
/* return: {
money: '1000',
prefix: 'fb.'
} */
client.db.db.delete('table') // Deleting your entire (main) database table
// return: bolean (true)
client.db.db.delete('main', 'money') // Deleting the 'money' key and the value inside
// return: bolean (true)
client.db.db.ping() // Requesting the database latency
// return: RandomNumberFromLatencyms
client.db.db.argsCount('main', 'money')
// return: 4
client.db.db.isString('main', 'money') // Checking if 'money' is a string
// return: bolean (false)
client.db.db.isString('main', 'prefix') // Checking if 'prefix' is a string
// return: bolean (true)
client.db.db.isString('main', 'prefix') // Checking if 'prefix' is a number
// return: bolean (false)
client.db.db.isNumber('main', 'money') // Checking if 'money' is a number
// return: bolean (true)
Your package.json should have a start script starting the node . that will start and run not only your index, but also the file nn att.sh
{
"name": "YourBotName",
"main": "index.js",
"scripts": {
"start": "node ."
},
"engines": {
"node": "^16.6.0"
},
"devDependencies": {
"node": "^16.6.0"
},
"dependencies": {
"aoi.fb": "^5.2.8",
"aoi.js": "^5.0.8"
}
}
What is the att.sh file in Aoi.fb version 5 used for? The att.sh file is for when the project is started, and the database is created, the file is also started and executed, and inside the file, modifications are made to aoi.js so that Aoi.fb works in V5 of Aoi.js, and the adjustments are pulled from the "adjust" folder of the Aoi.fb source code. By creating this file and making use of aoi.fb you are aware that your version of aoi.jsV5 is being adapted or adjusted for the functionality of Aoi.fb .
aoi.fb, a Firebase database of wrapper using aoi.fb as API
Owned by GR GR#3012
Developer Luís Fernando Luís Fernando#1581
aoi.fb is a package and db made for developers using aoi.js. Also made by you! If you want to contribute just do a pull-request