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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@jcauman23/economy

v0.0.1-a

Published

Economy module for discord.js

Downloads

4

Readme

--IMPORTANT-- this module is in *0.0.1-a* state and is not yet ready for normal use.

Methods

Initialize

import Economy from "@jcauman23/economy";
import { Client } from "discord.js";
const client = new Client();
client.economy = new Economy(client, {
    perGuild: true,
    Enmap: {
        folderLocation: "./",
        defaultValues: {
            coins: 0,
            bankCoins: 0,
            bankLevel: 0,
            bankMax: 1000,
            //inventory: [] (Removed, use Inventory class instead)
        },
        oldValues: {
            coins: "nekos",
            bankCoins: "bank",
            bankLevel: "bankLevels",
            bankMaxs: "bankMax",
            //inventory: "inventory" (Removed, use Inventory class instead)
        }
    },
    Mongoose: {
        databaseURL: "mongodb://localhost:27017/economy",
        defaultValues: {
            coins: 0,
            bankCoins: 0,
            bankLevel: 0,
            bankMax: 1000,
            //inventory: [] (Removed, use Inventory class instead)
        },
        oldValues: {
            coins: "nekos",
            bankCoins: "bank",
            bankLevel: "bankLevels",
            bankMaxs: "bankMax",
            //inventory: "inventory" (Removed, use Inventory class instead)
        }
    },
    Postgres: {
        databaseURL: "postgres://user:password@localhost:5432/economy",
        defaultValues: {
            coins: 0,
            bankCoins: 0,
            bankLevel: 0,
            bankMax: 1000,
            //inventory: [] (Removed, use Inventory class instead)
        },
        oldValues: {
            coins: "nekos",
            bankCoins: "bank",
            bankLevel: "bankLevels",
            bankMaxs: "bankMax",
            //inventory: "inventory" (Removed, use Inventory class instead)
        }
        tableName: "eco_users"
    },
    SQLite: {
        filePath: "./economy.sqlite",
        defaultValues: {
            nekos: 0,
            bankCoins: 0,
            bankLevel: 0,
            bankMax: 1000,
            //inventory: [] (Removed, use Inventory class instead)
        },
        oldValues: {
            coins: "nekos",
            bankCoins: "bank",
            bankLevel: "bankLevels",
            bankMaxs: "bankMax",
            //inventory: "inventory" (Removed, use Inventory class instead)
        }
    }
    //can only use **ONE** Database per instance
    //oldValues use the 1st value as the key for the old data, and the 2nd value as the new key for the new data, it auto migrates the data from the old key to the new key
});

addUser

client.economy.addUser(userId, guildId);

remUser

await client.economy.remUser(userId, guildId);

findUser

//always use await when finding a user
const user = await client.economy.findUser(userId, guildId);
//all data is in the user.data object
console.log(user.data.coins);

getUsersByGuild

client.economy.getUsersByGuild(guildId);

Inventory

add

user.inventory.add(item, price, options);
//options can be extra values you want in the users item inventory, for example:
user.inventory.add("sword", 100, { type: "sword", damage: 10 });
//Which will return [true, { item: "sword", type: "sword", price: 100, damage: 10 }] when used inventory.find()

remove

user.inventory.remove(item);
//This will remove the item from the user's inventory

reset

user.inventory.reset();
//This will reset the user's inventory to an empty array

show

user.inventory.show();
//This will return the user's inventory

find

const [check, itemArgs] = user.inventory.find(item);
if(check) console.log(itemArgs);
//This will return [true, { item: "sword", type: "sword", price: 100, damage: 10 }] if the item is found in the user's inventory
//This will return [false] if the item is not found in the user's inventory

Databases

Enmap

This database is the most basic and is used for simple key-value storage. It is not recommended for large-scale applications. folderLocation MUST be set to the folder where the database file is located.

Mongoose

This database uses MongoDB for storage and is recommended for applications that require more complex data structures and relationships. databaseURL CAN be set to "localhost:port" and it will automatically use the provided port to connect to the localhost database at mongodb://localhost:port/economy. otherwise use mongodb://user:password@host:port/database instead

Postgres

This database uses PostgreSQL for storage and is recommended for applications that require more complex data structures and relationships.

SQLite

This database uses SQLite for storage and is recommended for applications that require more complex data structures and relationships. filePath MUST be set to the file path of the database file.

Example

import Economy from "@jcauman23/economy";
import { Client } from "discord.js";
const client = new Client();
client.economy = new Economy(client, {
    perGuild: false,
    Enmap: {
        folderLocation: "./",
        defaultValues: {
            coins: 0,
            bankCoins: 0,
            bankLevel: 0,
            bankMax: 1000,
            //inventory: [] (Removed, use Inventory class instead)
        }
    }
});
//if perGuild is false, only use userId
const user = awaitclient.economy.findUser(userId)