/aoi.fb

aoi.fb - A Firebase Database wrapper using firebase with aoi.fb like API

Primary LanguageJavaScriptApache License 2.0Apache-2.0


aoi.fb

aoi.fb

A Firebase database of wrapper using aoi.fb as API

Table Of Contents

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')

About

A Firebase database of wrapper using aoi.fb as API NPM Version NPM Downloads

Installation

Node.JS 16.0.0 or newer is required.

npm install aoi.fb@latest

Setup

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]]`
})

Methods Examples

Database Illustration

(Table)
main--
    money--
          key: money
          value: 1000
    prefix--
          key: prefix
          value: fb.

SET

Example -

client.db.db.set('main', 'money', '1000') // Setting the value '1000' in the 'money' key that is in the 'main' table
// return: bolean (true)

GET

Example -

client.db.db.get('main', 'money').then(a => a.value) // Asking for the value of the 'money' key
// return: '1000' 

ALL

Example -

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.'
} */

DELETE

Example -

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)

Others

PING

Example -

client.db.db.ping() // Requesting the database latency
// return: RandomNumberFromLatencyms

ARGSCOUNT

Example -

client.db.db.argsCount('main', 'money')
// return: 4

ISSTRING

Example -

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)

ISNUMBER

Example -

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)

PackageJson

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.4",
   "aoi.js": "^5.0.8"
 }
}

AoiFB

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

Open Source

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