0.0.10 • Published 7 years ago

discord-eco v0.0.10

Weekly downloads
273
License
ISC
Repository
-
Last release
7 years ago

Discord Economy

Note: This package is under development and will be updated frequently.

This package is meant to provide an easy way to access core economy features.

Installation

npm install discord-eco

Require Package

var economy = require('discord-eco');

Fetch Balance

No need to create a database, it does that automatically.

    economy.fetchBalance('userID').then((i) => {
    	console.log(i) // { userID: '144645791145918464', money: 998, lastDaily: 'Not Collected' }
        console.log(i.money) // 998
    });

Update Balance

Value must be an integer. If you want to subtract from the balance make it a negitave number.

    economy.updateBalance('userID', 'value').then((i) => {
    	console.log(i) // Returns the updated result.
        console.log(i) // Returns the updated result.
    });

Example Bot | View Output

// Call Packages
    const Discord = require('discord.js');
    const economy = require('discord-eco');

    // Define client for Discord
    const client = new Discord.Client();

    // This runs when a message is recieved...
    client.on('message', message => {

        // Prefix
        let prefix = '!';

        // There are multiple ways you can use discord-eco.

        // Example: Fetching Balance
        if (message.content.toUpperCase() === `${prefix}BALANCE`) {

            economy.fetchBalance(message.author.id).then((i) => { // economy.fetchBalance grabs the userID, finds it, and puts it into 'i'.
                message.channel.send(`**Balance:** ${i.money}`);
            })


        }

        // Example: Adding Money To A User
        if (message.content.toUpperCase() === `${prefix}PAYDAY`) {

            economy.updateBalance(message.author.id, 500).then((i) => { // economy.updateBalance grabs the (userID, value) value being how much you want to add, and puts it into 'i'.
                message.channel.send(`**You got $500!**\n**New Balance:** ${i.money}`);
            })

        }

        // Example: Removing Money From A User
        if (message.content.toUpperCase() === `${prefix}PAYFINE`) {

            economy.updateBalance(message.author.id, -500).then((i) => { // Since the 'value' is -500, it will 'add' -500, making the balance $500 lower.
                message.channel.send(`**You paid your fine of $500!**\n**New Balance:** ${i.money}`);
            })

        }


    });

        client.login('token')
0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago