block.db
v1.1.1
Published
A simple database similar to quick.db by Plexi Development.
Downloads
13
Maintainers
Readme
Block.DB
NPM: NPM Link Installation: npm install block.db
Block.DB is inspired package from the npm package called: "Quick.db". This package has very similar features to Quick.db and here is an example of a Discord Economy Balance command!
// Discord Bot Balance Command.
const Discord = require('discord.js')
const db = require('block.db');
const client = new Discord.Client()
client.on('message', async message => {
if (message.content.startsWith(`!bal`)) {
const user = message.mentions.users.first() || message.author
// Global:
let bal = db.get(`<moneyvar>-${user.id}`);
if (bal == null) {
bal = 0;
db.set(`<moneyvar>-${user.id}`, 0);
}
// Guild:
let bal = db.get(`<moneyvar>-${message.guild.id}-${user.id}`);
if (bal == null) {
bal = 0;
db.set(`<moneyvar>-${message.guild.id}-${user.id}`, 0);
}
let embed = new Discord.MessageEmbed()
.setAuthor(user.username, user.displayAvatarURL)
.setDescription(`Balance: ${bal}`);
message.channel.send(embed)
}
});
Methods
const db = require('block.db');
// Set:
db.set(`variable`, [value]);
// Get:
db.get(`variable`);
or
db.retrieve(`variable`);
// Add:
db.add(`variable`, [value]);
// Sub:
db.sub(`variable`, [value]);
// All:
db.all(`variable`);
or
db.getAll(`variable`);