discord-global-economy
v2.2.0
Published
A discord.js currency package for MongoDB.
Downloads
10
Maintainers
Readme
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!)