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

coins-manager

v1.0.7

Published

Source code of [coins manager](https://www.npmjs.com/package/coins-manager)

Downloads

3

Readme

coins-manager

Source code of coins manager

This manager can be configured for a global usage or to split economy servers.

Important

This manager works with MySQL.

Documentation

Here is how to use the manager

First install the package (yarn add coins-manager, npm i coins-manager or pnpm add coins-manager)

Typescript initialisation

import { CoinsManager } from 'coins-manager';
import { createConnection } from 'mysql';

const database = createConnection({/* database informations */})

const manager = new CoinsManager<'global' | 'multiguild'>(database, {
    options: 'global' | 'multiguild'
});
manager.start();

Javascript initialisation

const { CoinsManager } = require('coins-manager');
const { createConnection } = require('mysql');

const database = createConnection({/* database informations */})

const manager = new CoinsManager<'global' | 'multiguild'>(database, {
    options: 'global' | 'multiguild'
});
manager.start();

Returns

The manager return this format :

{
    coins: number;
    bank: number;
    user_id: string;
}

And if it's set to a multiguild usage :

{
    guild_id: string;
    user_id: string;
    coins: number;
    bank: number;
}

Methods

Here are the documentation for the methods

Remember that if you set it on a multiguild usage, it will require a guild_id parameter

Add Coins

Add coins to an user

manager.addCoins({
    user_id: '1234',
    coins: 100
    // Optional guild_id: '4321' value is required for a multiguild usage
});

Remove Coins

Remove coins to an user

manager.removeCoins({
    user_id: '1234',
    coins: 100
    // Optional guild_id: '4321' value is required for a multiguild usage
});

Add bank

Add bank amount to an user

manager.addBank({
    user_id: '1234',
    bank: 100
    // Optional guild_id: '4321' value is required for a multiguild usage
});

Remove bank

Remove coins in bank from an user

manager.removeBank({
    user_id: '1234',
    bank: 100
    // Optional guild_id: '4321' value is required for a multiguild usage
});

Get leaderboard

This method returns the leaderboard of coins + bank

manager.getLeaderboard();

If you set it to a multiguild usage, you can add guild_id parameter to get the leaderboard of a specific server

manager.getLeaderboard('4321');

Get Data

Get the data of an user

manager.getData({
    user_id: '1324'
});

If you set it to a multiguild usage, you have to add the guild_id paramter :

manager.getData({
    user_id: '1324',
    guild_id: '4321'
});

Get Code

The manager's cache works with a code system, in a global usage it's just the user ID, but if you set it to a multiguild usage, you maybe want to get the code of the user, so use :

manager.getCode({
    user_id: '1234'
})

And for multiguild usage :

manager.getCode({
    user_id: '1324',
    guild_id: '4321'
});

Has Account

This method is used to know if a user is in the database

manager.hasAccount({
    user_id: '1324'
});
// Boolean

And on a multiguild usage :

manager.hasAccount({
    user_id: '1234',
    guild_id: '4321'
});
// Boolean

Propreties

Here are the proprety of the manager : array

This get method returns you an array with all the returns data