discord-global-economy

2.2.0 • Public • Published

NPM

Forked From https://github.com/birbified/discord-mongo-currency

discord-global-economy

A npm package for making economy bots with MongoDB.

Installation

npm i discord-global-economy

Starting

Start off by connecting discord-global-economy to MongoDB.

const mongoCurrency = require('discord-global-economy');

mongoCurrency.connect('some connection string');

All Methods

createUser(userId)

Adds a user to the database.

deleteUser(userId)

Deletes a user from the database.

giveCoins(userId, amount)

Gives coins to a user. Adds the user to the database if the user is saved to the database.

deductCoins(userId, amount)

Deducts coins from a user.

findUser(userId)

Finds the user in the database.

giveBankSpace(userId, amount)

Gives bank space to a user.

Command Examples

Balance Command
    const mongoCurrency = require('discord-global-economy');
    const { MessageEmbed } = require('discord.js');

    const member = message.mentions.members.first() || message.member;

    const user = await mongoCurrency.findUser(member.id, message.guild.id); // Get the user from the database.

    const embed = new MessageEmbed()
    .setTitle(`${member.user.username}'s Balance`)
    .setDescription(`Wallet: ${user.coinsInWallet}
    Bank: ${user.coinsInBank}/${user.bankSpace}
    Total: ${user.coinsInBank + user.coinsInWallet}`);
    
    message.channel.send({ embeds: [embed] });
Beg Command
    const mongoCurrency = require('discord-global-economy');

    const randomCoins = Math.floor(Math.random() * 99) + 1; // Random amount of coins.
    
    await mongoCurrency.giveCoins(message.member.id, message.guild.id, randomCoins);

More Commands Comming Soon!

(Want to see a preview? Join the Discord!)

Package Sidebar

Install

npm i discord-global-economy

Weekly Downloads

1

Version

2.2.0

License

MIT

Unpacked Size

10.9 kB

Total Files

4

Last publish

Collaborators

  • dqnte