Coder Social home page Coder Social logo

coins's Introduction

coins

This is a coins manager for SQL databases on discord.

Version

The version of discord can be any, but I recomand the latest.

Note

This code is only for a SQL database. Use this command to create the table

CREATE TABLE coins (
    user_id VARCHAR(255),
    coins VARCHAR(255),
    bank VARCHAR(255)
);

Init

In your file, you need to do this :

// Require coins manager
const Manager = require('./coinsManager.js');

// Put the manager on our client
client.CoinsManager = new Manager(client, {
  base_coins: 100,
   base_bank: 50
});

// This part is important, it tells manager to set data in cache.
client.CoinsManager.init();

Note on initialisation

Paramaters between {} are optionnal ; a default value is provided.

Use manager

Add coins

client.CoinsManager.addCoins('user id', 100);
// returns new amount of coins of user

Number can be any, but not decimal.

Remove coins

client.CoinsManager.removeCoins('user id', 50);

Returns not exist if user isn't in database. Returns false if number is invalid ( too small, too big or not a number )

Deposit

client.CoinsManager.deposit('user id', 100);

Put coins in bank account. Returns not exist if user isn't in database. Returns false if number is invalid ( too small, too big or not a number ) Returns new bank amount

Withdraw

client.CoinsManager.withdraw('user id', 50);

get coins from bank Returns not exist if user isn't in database. Returns false if number is invalid ( too small, too big or not a number ) Returns new bank amount

Stats

client.CoinsManager.stats('user id');

Returns not exist if user isn't in database. Returns { coins: Number(), bank: Number()}, wich are data of user.

Leaderboard

client.CoinsManager.leaderboard();

Returns an array with data of all users sorted by total.

Pay

client.CoinsManager.pay({
    donator: 'Donator ID',
    receiver: "Receiver ID",
    amount: "amount (as a number)"
});

Returns no donator if donator isn't in database. Returns no receiver if receiver isn't in database. Returns invalid amount if number is invalid ( too small, too big or not a number )

Error

If you encounter any error, please contact me on this discord server

Ended

You can now use the Greensky's CoinsManager !

coins's People

Contributors

greensky-gs avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.