npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mongo-glob-economy

v1.0.12

Published

A easy to use npm economy package

Downloads

43

Readme

What is 'mongo-glob-economy'

It is a global economy package that allows you to create, delete, edit data for the user and much more

Why mongo-glob-economy?

  • Easy to use
  • Uses mongo databases which are encrypted
  • Provides a global economy system
  • Has a bank system
  • Has a bank limit

Setting up

Here is the basic code to connect to your mongo database

const { setURL } = require("mongo-glob-economy"); //requireing the package

setURL("mongodb://localhost/quickmongo"); //The mongo database url

but instead of mongodb://localhost/quickmongo you would provide your actual mongo database url

Examples

Examples assume that you have setted up the module as presented in 'Setting Up' section. Following examples assume that your Discord.Client is called client.

Following examples assume that your client.on("message", message is called message.

Following example contains isolated code which you need to integrate in your own command handler.

Following example assumes that you are able to write asynchronous code (use await).

  • Increasing the value of bank limit by a bit each time the author sends a message
const { findUser, createProfile, incBankLimit } = require("mongo-glob-economy");

client.on("message", async (message) => {
  if (!message.guild) return;
  if (message.author.bot) return;

  const randomValue = Math.floor(Math.random() * 9) + 1; // Min 1, Max 10
  const user = await findUser(message.author.id);
  if (!user) return await createProfile(message.author.id); //using this function to create the profile if one dosnt have 1 alredy

  if (user) await incBankLimit(message.author.id, randomValue); //using the function to inc bank limit
});
  • Bal command
const {
  findUser,
  getCoinsInWallet,
  getCoinsInBank,
  getBankLimit,
} = require("mongo-glob-economy");
const Discord = require("discord.js");

//from here starts the actual code
const target = message.mentions.members.first() || message.member;
const user = await findUser(target.id);

if (!user) return message.channel.send("You dont have a profile");

const coins = await getCoinsInWallet(target.id);
const bankCoins = await getCoinsInBank(target.id);
const bankLimit = await getBankLimit(target.id);

const embed = new Discord.MessageEmbed().setTitle("Balance").addFields(
  {
    name: "wallet",
    value: coins,
  },
  {
    name: "bank",
    value: bankCoins + "/" + bankLimit,
  }
);

message.channel.send(embed);

Time for you to get creative

Functions

setURL

setURL(<dbUrl: string>);

This is used to connect to the database

findUser

findUser(<userID: string>);

This is used to find if there is an entry in the db for a certain user

createProfile

createProfile(<userID: string>);

This is used to create a profile if the user dosnt have one alredy

deleteProfile

deleteProfile(<userID: string>)

This is used to delete profile of the user if they have one

getCoinsInWallet

getCoinsInWallet(<userID: string>)

This is used to get the value of coins for the target

incCoinsInWallet

incCoinsInWallet(<userID: string>, <coins: Number>)

This is used to increase the value of coins for the target

decCoinsInWallet

decCoinsInWallet(<userID: string>, <coins: Number>)

This is used to decrease the value of coins for the target

getCoinsInBank

getCoinsInBank(<userID: string>)

This is used to get the value of bank for the target

incCoinsInBank

incCoinsInBank(<userID: string>, <coins: Number>)

This is used to increase the value of bank for the target

decCoinsInBank

decCoinsInBank(<userID: string>, <coins: Number>)

This is used to decrease the value of bank for the target

getBankLimit

getBankLimit(<userID: string>)

This is used to get the value of banklimit for the target

incBankLimit

incBankLimit(<userID: string>, <value: Number>)

This is used to increase the value of banklimit for the target

decBankLimit

decBankLimit(<userID: string>, <value: Number>)

This is used to decrease the value of banklimit for the target