New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

coins-manager

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coins-manager

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

latest
Source
npmnpm
Version
1.0.7
Version published
Weekly downloads
10
900%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

manager

FAQs

Package last updated on 04 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts