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 🙏

© 2026 – Pkg Stats / Ryan Hefner

json-money

v0.0.2

Published

Un simple module pour réaliser un système d'argent fictif en JSON.

Readme

Installation

Comment installer / utiliser le module ?

const Database = require("json-money"); //Le module
const money = new Database("./money.json"); //Le fichier (money) JSON

Le fichier json se créer automatiquement, vous pouvez aussi le concevoir vous même.

Pour le créer à la main :

  • Tout d'abord il faut créer un fichier se termimant par l'extension .json.
  • Puis inclure {} à l'intérieur.

Exemples

  • Pour lire la money d'un utilisateur :
const Database = require("json-money"); //Le module
const money = new Database("./money.json"); //Le fichier (money) JSON

//Event message
client.on("message", async (message) => {

    //Si "!money" est tapé :
    if (message.content === "!money") {

        //Get la variable money
        var balance = money.get(message.author.id);

        //Si la money est "undefined" alors il affiche "0"
        if (balance === undefined) balance = 0;

        //Message
        message.channel.send(`Argent de, ${message.author}. Vous possédez ${balance} coins.`)

    }
    
})
  • Pour ajouter de la money à un utilisateur :
const Database = require("json-money"); //Le module
const money = new Database("./money.json"); //Le fichier (money) JSON

//Event message
client.on("message", async (message) => {

    //Si "!add" est tapé :
    if (message.content === "!add") {

        //Get la variable money
        var balance = money.get(message.author.id);

        //Si la money est "undefined" alors il affiche "0"
        if (balance === undefined) balance = 0;

        //Il ajoute 100
        money.add(message.author.id, 100)
        
        //Message
        message.channel.send(`Bravo, ${message.author}. Vous remportez 100 coins, vous possédez ${balance + 100} coins.`)

    }

})
  • Pour retirer de la money à un utilisateur :
const Database = require("json-money"); //Le module
const money = new Database("./money.json"); //Le fichier (money) JSON

//Event message
client.on("message", async (message) => {

    //Si "!remove" est tapé :
    if (message.content === "!remove") {

        //Get la variable money
        var balance = money.get(message.author.id);

        //Si la money est "undefined" alors il affiche "0"
        if (balance === undefined) balance = 0;
        
        //Si l'user n'a pas d'argent
        if (balance <= 0) return message.channel.send(`Ho non ${message.author}, vous n'avez pas de money à retirer.`)

        //Il retire 100
        money.subtract(message.author.id, 100)

        //Message
        message.channel.send(`Congratulations, ${message.author}. You just won 100 coins, you have ${balance - 100} coins.`)

    }

})
  • Pour supprimer de la money à un utilisateur :
const Database = require("json-money"); //Le module
const money = new Database("./money.json"); //Le fichier (money) JSON

//Event message
client.on("message", async (message) => {

    //Si "!delete" est tapé :
    if (message.content === "!delete") {

        //Get la variable money
        var balance = money.get(message.author.id);

        //Si la money est "undefined" alors il affiche "0"
        if (balance === undefined) balance = 0;
        
        //Si l'user n'a pas d'argent
        if (balance <= 0) return message.channel.send(`Ho non ${message.author}, vous n'avez pas de money à retirer.`)

        //Il supprime la money
        money.delete(message.author.id)
      
        //Message
        message.channel.send(`Bravo, ${message.author}. je viens de supprimer toute votre money.`)

    }

})
  • Un petit système d'XP avec une récompense (BETA) :
const Database = require("json-money"); //Le module
const points = new Database("./xp.json"); //Le fichier (xp) JSON
const money = new Database("./money.json"); //Le fichier (money) JSON

//Event message
client.on("message", async (message) => {
  
    //Pour ne pas que il enregistre les bots
    if (message.author.bot) return;

    //Get la variable XP
    var xp = points.get(message.author.id);

    //Si l'user n'a pas d'XP
    if (xp === undefined) xp = 0;

    //Il ajoute 1 d'XP
    points.add(message.author.id, 1)

    //Si "!xp" est tapé :
    if (message.content === "!xp") {

        //Si l'user à trop d'XP :
        if (xp >= 9) {

            //Il supprime les XP
            points.delete(message.author.id)

            //Il ajoute la money
            money.add(message.author.id, 10)

            //Message
            return message.channel.send(`Merci ${message.author}, de votre présence. Vous remportez 10 coins.`)

        //Sinon :
        } else {

            //Message
            return message.channel.send(`Vos XP ${message.author}, (${xp + 1} XP). Vous avez besoin de ${9 - xp} XP pour votre récompense.`)

        }

    }

    //Si l'user à trop d'XP :
    if (xp + 1 >= 9) {

        //Il supprime les XP
        points.delete(message.author.id)

        //Il ajoute la money
        money.add(message.author.id, 10)

        //Message
        return message.channel.send(`Merci ${message.author}, de votre présence. Vous remportez 10 coins.`)

    }

})