1.1.0 • Published 3 years ago

djs-economy.js v1.1.0

Weekly downloads
7
License
Apache-2.0 Licens...
Repository
github
Last release
3 years ago

djs-economy.js

A economy for discord

Contents

Installation

npm install djs-economy.js

Overview

djs-economy.js helps you to make a easy economy for your discord server, the only thing you need is a mongodb cluster, but don't worry I already did that for you

Usage

Constructor

Client()

new Client()

Methods

Client

MethodParameterTypeDescriptionDefaultNotes
mongoConnecturlstringConnect mongoDBn/a
deletePlayeridstringDelete a player from the DB using his IDn/a
addMoneyid/money/bankstring/number/booleanAddmoney to a user using his ID the money, and if it is for the bankn/aEmits the addmoney event
removeMoneyid/number/bankstring/number/booleanRemove money to a user using his ID the money, and if it is for the bankn/aEmits the removemoney event
searchPlayeridstringSearch a user using his IDn/aIt returns the class Player
payplayer1/player2/money/bankstring/string/number/booleanPays a user, and if it is the money to the bankn/a | n/a | n/a |false

Player

MethodParameterTypeDescriptionDefaultNotes
toDatan/an/aReturns the raw data of the usern/aIts a getter no function
addMoneymoney/banknumber/booleanAdds the money to the actual user, and if it is for the bankn/afalse
removeMoneymoney/banknumber/booleanRemoves the money to the actual user, and if it is for the bankn/afalse
deleten/an/aDeletes the actual usern/a
payid/money/bankstring/number/booleanPays a user, and if it is the money to the bankn/a | n/a |false

Events

addmoney

ParameterTypeDescription
idstringThe ID of the user
playerPlayerThe actual user in the class Player
bankbooleanIf the money is going to the bank is true
dateDateThe timestamp when the user got the money

removemoney

ParameterTypeDescription
idstringThe ID of the user
playerPlayerThe actual user in the class Player
bankbooleanIf the money is removing from the bank is true
dateDateThe timestamp when the user lost the money

Example

import { Client } from "djs-economy.js"

const Economy = new Client()
.mongoConnect(`mongodb+srv://<user>:<password>@<cluster>.<port>.mongodb.net/<dbname>?retryWrites=true&w=majority`)

if(command === 'work'){
    message.reply(`You won 100$`)

    Economy.addMoney(message.author.id, 100)
}

More examples are coming...

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago