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

economy-mongoose

v1.2.5

Published

A basic package that helps to perform easy economy commands especially to create bots.

Downloads

35

Readme

Now the package have typings from typescript!

Anything problem conctact here

How to use this package?

Required packages

npm i economy-mongoose
//Or the equivalent of
yarn add economy-mongoose
//Or others

How to connect MongoDB with the package?

Typescript:

import {Economy} from "economy-mongoose"
Economy.connect("MongoDB connection")

Javascript:

const {Economy} = require("economy-mongoose")
Economy.connect("MongoDB connection")

Methods:

Economy.createUser(UserID, GuildID) // Create a user in the database.
Economy.DeleteUser(UserID, GuildID) // Delete a user in the database.
Economy.getUser(UserID, GuildID) // Gets a user from the database.
Economy.addWallet(UserID, GuildID, Amount) // Add money to a user's wallet.
Economy.removeWallet(User, Guild, Amount) // Remove money from a user's wallet.
Economy.removeBank(User, Guild, Amount) // Remove money from a user's bank.
Economy.addBank(User, Guild, Amount) // Add money to a user's bank.
Economy.Withdraw(User, Guild, Amount) // Take money out of the bank to use it in the wallet.
Economy.transfer(FromUserID, ToUserID, Guild, Amount)//Transfer from one user to another user an amount of money 
Economy.Deposit(User, Guild, Amount) // Deposit money from the wallet to the bank.
Economy.setBank(User, Guild, Amount) //Set an amount in someone's bank.
Economy.setWallet(User, GuildID, Amount) //Set an amount in someone's wallet.

Returns, types and errors in code:

Parameter Amount
+ Amount is necessarily a Number
- If Amount is not a Number it returns false
- If Amount has an error it returns false, otherwise true

Parameter UserID, FromUserID and ToUserID
+ User is necessarily a String
- If User has an error it returns false, otherwise true

Parameter Guild
+ Guild is necessarily a String
- If Guild has an error it returns false, otherwise true

Error getUser
+ const user = await Economy.getUser( User, Guild ); //Return the true
- const user = Economy.getUser( User, Guild );//Return undefined in all

Every time we use the get or another that consists of variables, you must use await

In the case of deposit, withdraw or others are used like this
Economy.deposit()

Properties:

let user = await Economy.getUser(UserID, GuildID)

user.User // Access a user.
user.Bank//Access someone's bank.
user.Wallet // You access a user's wallet.
user.Guild // You access a server/guild.

Balance command example

let member = <message>.mentions.members.first() || <message>.member
let user = await Economy.getUser(member, message.Guild.id)

let embed = new MessageEmbed()
.addField('Money', user.Wallet)
.addField('Bank', user.Bank)
.addField('Money in total', user.bank+user.Wallet)

How to do a basic pay command

const {Economy} = require("economy-mongoose")//Require the package

let me = <message>.member//You
let member = <message>.mentions.members.first()//Member to pay
let Guild = <message>.guild.id//The GuildID (OPTIONAL)
Economy.transfer(me.id, member.id, Guild, 100)