1.4.1 • Published 2 years ago

discord-bot-eco v1.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

discord-bot-eco

Very customizable economy framework for your Discord Bot

How does it work?

Easy and fast. Data is saved to a MongoDB database. Economics is divided into wallet and bank balance, so you have more room to act!

Need Help?

Join our Discord Server.

Simple Economy System

discord-bot-eco supports activities such as buy, daily, deposit, get, getItems, giveItem, leaderboard, monthly, reset, rob, sell, take, takeItem, weekly, withdraw, and work!

Introduction

To start using discord-bot-eco, you will first need to initialise the configuration as shown below.

const economy = require('discord-bot-eco')
client.on('ready', async() => {
    economy.setConfig({
        mongoURL: "",
        currency: "$",
        allowBankruptcy: false,
        limits: {
            defaultBankLimit: 3000,
            enabled: true
        },
        shopEnabled: true,
        shop: [
            /*
                Item properties can be modified but the following below must be kept as they are used in the module!
                The entire item is returned when using it with functions, go crazy!
            */
            {
                itemName: "Example Item",
                itemBuyPrice: 1000,
                itemSellPrice: 900,
                itemBuyable: true,
                itemSellable: false
            }
        ]
    });
});

Wallet & Bank Functions

FunctionWalletBank
giveeconomy.give(userID, amount, "wallet")economy.give(userID, amount, "bank")
takeeconomy.take(userID, amount, "wallet")economy.take(userID, amount, "bank")
seteconomy.set(userID, amount, "wallet")economy.set(userID, amount, "bank")
reseteconomy.reset(userID, "wallet")economy.reset(userID, "bank")
geteconomy.get(userID, "wallet")economy.get(userID, "bank")
leaderboardeconomy.leaderboard("wallet")economy.leaderboard("bank")

Shop Functions

FunctionUsage
getShopeconomy.getShop(optionalGuildID)
setShopeconomy.setShop(guildID, newShop)
buyeconomy.buy(userID, itemName)
selleconomy.sell(userID, itemName)
giveItemeconomy.giveItem(userID, itemName)
takeItemeconomy.takeItem(userID, itemName)
hasItemeconomy.hasItem(userID, itemName)
getItemseconomy.getItems(userID)

Other Functions

FunctionUsage
withdraweconomy.withdraw(userID, amount)
depositeconomy.deposit(userID, amount)
workeconomy.work(userID, minEarn, maxEarn)
robeconomy.rob(userID, robUserID, minEarn, maxEarn, failChance)
dailyeconomy.daily(userID, amount)
weeklyeconomy.weekly(userID, amount)
monthlyeconomy.monthly(userID, amount)
formateconomy.format(amount)
getTimeouteconomy.getTimeout(userID, timeout)
getBankLimiteconomy.getBankLimit(userID)
setBankLimiteconomy.setBankLimit(userID, amount)
getRandomeconomy.getRandom(from, to)
getStreakeconomy.getStreak(userID, type)

Handling

All error handling is built into the package! User tries buying a package and it's not real? It'll return an error! User cannot afford an item? That will also return an error, more details and examples below!

  • All functions that save data can return false if it failed to save.

Buy

await economy.buy(userID, itemName);
  • not_real: The item the user is attempting to buy is not real.
  • not_for_sale: The item the user is attempting to buy is not for sale.
  • cannot_afford: The user does not have enough money in their wallet to afford the item.
  • The balance will be returned upon success.

Sell

await economy.sell(userID, itemName);
  • not_real: The item the user is attempting to sell is not real.
  • not_sellable: The item the user is attempting to sell is not sellable.
  • not_owned: The user does not own the item.
  • The balance will be returned upon success.

Daily, Weekly and Monthly

await economy.daily(userID, amount);
await economy.weekly(userID, amount);
await economy.monthly(userID, amount);
  • false: The timeout has not yet expired.
  • The balance and the users streak will be returned upon success.

Deposit

await economy.deposit(userID, amount);
  • false: The user does not have enough money.
  • bank_limit: The users bank limit will exceed.
  • The balance will be returned upon success.

Withdraw

await economy.withdraw(userID, amount);
  • false: The user does not have enough money in the bank.
  • The balance will be returned upon success.

Leaderboard

await economy.leaderboard(type);
  • Type can be: wallet, bank or both.
  • false: The leaderboard is empty.
  • The leaderboard sorted from highest to lowest will be returned upon success.

Rob

await economy.rob(userID, robUserID, minEarn, maxEarn, failChance);
  • failChance is the percentage of the rob failing (10%=10)
  • false: The rob failed from failChance.
  • The amount earned and your current balance will be returned upon success.

Give

await economy.give(userID, amount, type);
  • Type can be: wallet, bank or both.
  • bank_limit: The users bank limit will be exceeded if money is given.
  • The balance will be returned upon success.

Take

await economy.take(userID, amount, type);
  • Type can be: wallet, bank or both.
  • false: The user will go bankrupt if money is taken.
  • The balance will be returned upon success.

Get

await economy.get(userID, type);
  • If type is not provided, both balances will be returned.

GetBankLimit

await economy.getBankLimit(userID);
  • false: Bank limit is not enabled
  • The limit will be returned upon success.

SetBankLimit

await economy.setBankLimit(userID, amount);
  • false: Bank limit is not enabled
  • The bank limit will be returned upon success.

GetTimeout

await economy.getTimeout(userID, timeout);
  • Timeout can be: daily, weekly or monthly.
  • Returns the milliseconds until the next reward is ready.

GetStreak

await economy.getStreak(userID, type);
  • Type can be: daily, weekly or monthly.
  • Returns the streak for the type.
1.4.1

2 years ago

1.4.0

2 years ago

1.3.91

2 years ago

1.3.9

2 years ago

1.3.83

2 years ago

1.3.82

2 years ago

1.3.81

2 years ago

1.3.8

2 years ago

1.3.7

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago