New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

discord-eco

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-eco

Framework of a discord bot being used in a tutorial series.

  • 0.0.10
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
150
increased by219.15%
Maintainers
1
Weekly downloads
 
Created
Source

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')

Keywords

FAQs

Package last updated on 21 Oct 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc