Skip to content

Commit

Permalink
Discord Economy Super v1.7.1
Browse files Browse the repository at this point in the history
**v1.7.1:**

- Major bug fixes!
- Major typings fixes!
- Major JSDoc fixes!
- Improved error handling and debugging.
- Update checker fixes.
- Fixed broken inventory cache issue on startup in MongoDB version!

- **Custom currencies system! 🔥**
- Added a new `customCurrencySet`, `customCurrencyAdd` and `customCurrencySubtract` events so the changes in any custom currencies could be tracked!
- Added a new optional `currency` argument in **all item buying methods** that takes eaither *currency ID*, *name* or its *symbol* so the currency balance will be subtracted instead of core balance. Requires the `subtractOnBuy` option to be enabled.

- Added a `stack()` method for **_inventory items_** that returns the **number of specific item (quantity)** and the **total price** of it in the inventory!
- Added a new `clearDaily`, `clearWork` and `clearWeekly` methods in `CooldownItem` and `Cooldowns` classes to clear the specific cooldowns.

- Added a `save()` method for `Shop-`, `Inventory-` and `History-` **items** that allows you to edit the item's object properties save the edited objext in database!
- Added a `.toString()` method for some classes.

- `Shop-`, `Inventory-` and `History-` **items'** `itemObject` property was changed to `rawObject` so it could make sense in the code 
- Now a warning will be displayed in console if using a dev version in both MongoDB and JSON versions (see the screenshot below).

- Added the missing `buy()` method in `ShopItem` class.
- Added the missing `clear()` method in `Items` class.
- Fixed return values in database operations methods.
  • Loading branch information
shadowplay1 authored Dec 31, 2022
1 parent 6600f4e commit d21cebb
Show file tree
Hide file tree
Showing 29 changed files with 1,237 additions and 56 deletions.
17 changes: 12 additions & 5 deletions mongodb/EconomyItems.d.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
export import AddItemOptions = require('./typings/interfaces/AddItemOptions')
export import BalanceData = require('./typings/interfaces/BalanceData')
export import BalanceOperations = require('./typings/interfaces/BalanceOperations')
export import BalanceOperation = require('./typings/interfaces/BalanceOperation')
export import BalanceOperations = require('./typings/interfaces/BalanceOperations')
export import CheckerConfiguration = require('./typings/interfaces/CheckerConfiguration')
export import CurrencyObject = require('./typings/interfaces/CurrencyObject')
export import CustomItemData = require('./typings/interfaces/CustomItemData')
export import DataIdentifier = require('./typings/interfaces/DataIdentifier')
export import EconomyConfiguration = require('./typings/interfaces/EconomyConfiguration')
export import EconomyConstructors = require('./typings/interfaces/EconomyConstructors')
export import EconomyDatabase = require('./typings/interfaces/EconomyDatabase')
export import EconomyErrorCodes = require('./typings/interfaces/EconomyErrorCodes')
export import EconomyEvents = require('./typings/interfaces/EconomyEvents')
export import EconomyConfiguration = require('./typings/interfaces/EconomyConfiguration')
export import EditedItemData = require('./typings/interfaces/EditedItemData')
export import ErrorHandlerConfiguration = require('./typings/interfaces/ErrorHandlerConfiguration')
export import HistoryData = require('./typings/interfaces/HistoryData')
export import If = require('./typings/interfaces/If')
export import DataIdentifier = require('./typings/interfaces/DataIdentifier')
export import InventoryData = require('./typings/interfaces/InventoryData')
export import ItemBuyData = require('./typings/interfaces/ItemBuyData')
export import ItemData = require('./typings/interfaces/ItemData')
export import ItemProperties = require('./typings/interfaces/ItemProperties')
export import ItemProperty = require('./typings/interfaces/ItemProperty')
export import ItemUseData = require('./typings/interfaces/ItemUseData')
export import LeaderboardData = require('./typings/interfaces/LeaderboardData')
export import RawEconomyUser = require('./typings/interfaces/RawEconomyUser')
export import RewardCooldownData = require('./typings/interfaces/RewardCooldownData')
export import RewardObject = require('./typings/interfaces/RewardObject')
export import RewardTypes = require('./typings/interfaces/RewardTypes')
export import EconomyErrorCodes = require('./typings/interfaces/EconomyErrorCodes')
export import SellingOperationInfo = require('./typings/interfaces/SellingOperationInfo')
export import SettingsTypes = require('./typings/interfaces/SettingsTypes')
export import SettingValueType = require('./typings/interfaces/SettingValueType')
export import SettingsTypes = require('./typings/interfaces/SettingsTypes')
export import ShopOperationInfo = require('./typings/interfaces/ShopOperationInfo')
export import TimeObject = require('./typings/interfaces/TimeObject')
export import TransferingOptions = require('./typings/interfaces/TransferingOptions')
Expand All @@ -50,6 +53,8 @@ export import RewardManager = require('./typings/managers/RewardManager')
export import CooldownManager = require('./typings/managers/CooldownManager')
export import HistoryManager = require('./typings/managers/HistoryManager')

export import CurrencyManager = require('./typings/managers/CurrencyManager')

export import UserManager = require('./typings/managers/UserManager')
export import GuildManager = require('./typings/managers/GuildManager')

Expand All @@ -76,6 +81,8 @@ export import ShopItem = require('./typings/classes/ShopItem')
export import InventoryItem = require('./typings/classes/InventoryItem')
export import HistoryItem = require('./typings/classes/HistoryItem')

export import Currency = require('./typings/classes/Currency')

export import Leaderboards = require('./typings/classes/guild/Leaderboards')
export import Settings = require('./typings/classes/guild/Settings')
export import Shop = require('./typings/classes/guild/Shop')
Expand Down
7 changes: 7 additions & 0 deletions mongodb/EconomyItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const RewardManager = require('./src/managers/RewardManager')
const CooldownManager = require('./src/managers/CooldownManager')
const HistoryManager = require('./src/managers/HistoryManager')

const CurrencyManager = require('./src/managers/CurrencyManager')

const UserManager = require('./src/managers/UserManager')
const GuildManager = require('./src/managers/GuildManager')

Expand All @@ -25,9 +27,12 @@ const CacheManager = require('./src/managers/CacheManager')
const EconomyGuild = require('./src/classes/EconomyGuild')
const EconomyUser = require('./src/classes/EconomyUser')


const EmptyEconomyGuild = require('./src/classes/EmptyEconomyGuild')
const EmptyEconomyUser = require('./src/classes/EmptyEconomyUser')

const Currency = require('./src/classes/Currency')

const ShopItem = require('./src/classes/ShopItem')
const InventoryItem = require('./src/classes/InventoryItem')
const HistoryItem = require('./src/classes/HistoryItem')
Expand Down Expand Up @@ -73,6 +78,7 @@ module.exports = {
InventoryManager,

HistoryManager,
CurrencyManager,

UserManager,
GuildManager,
Expand All @@ -86,6 +92,7 @@ module.exports = {
InventoryItem,
HistoryItem,

Currency,
CooldownItem,

BalanceItem,
Expand Down
4 changes: 2 additions & 2 deletions mongodb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discord-economy-super",
"version": "1.7.0-dev.94ff2f5.1668307576",
"version": "1.7.1",
"types": "./typings/Economy.d.ts",
"description": "Easy and customizable economy module for your Discord Bot.",
"main": "index.js",
Expand Down Expand Up @@ -44,7 +44,7 @@
"license": "MIT",
"dependencies": {
"node-fetch": "^2.6.7",
"quick-mongo-super": "^1.0.9"
"quick-mongo-super": "^1.0.10"
},
"engines": {
"node": ">=14.0.0"
Expand Down
23 changes: 19 additions & 4 deletions mongodb/typings/Economy.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import DatabaseManager from './managers/DatabaseManager'
import ShopManager from './managers/ShopManager'
import InventoryManager from './managers/InventoryManager'

import CurrencyManager from './managers/CurrencyManager'

import RewardManager from './managers/RewardManager'
import CooldownManager from './managers/CooldownManager'
import HistoryManager from './managers/HistoryManager'
Expand Down Expand Up @@ -106,13 +108,19 @@ declare class Economy<Ready extends boolean = boolean> extends Emitter {
public readonly history: If<Ready, HistoryManager>

/**
* Balance.
* Balance manager.
* @type {?BalanceManager}
*/
public readonly balance: If<Ready, BalanceManager>

/**
* Bank balance.
* Currency manager.
* @type {?CurrencyManager}
*/
public readonly currencies: If<Ready, CurrencyManager>

/**
* Bank balance manager.
* @type {?BankManager}
*/
public readonly bank: If<Ready, BankManager>
Expand All @@ -130,7 +138,7 @@ declare class Economy<Ready extends boolean = boolean> extends Emitter {
public readonly shop: If<Ready, ShopManager>

/**
* Balance.
* Reward manager.
* @type {?RewardManager}
*/
public readonly rewards: If<Ready, RewardManager>
Expand All @@ -154,7 +162,7 @@ declare class Economy<Ready extends boolean = boolean> extends Emitter {
public readonly guilds: If<Ready, GuildManager>

/**
* Economy guild settings.
* Settings manager.
* @type {?SettingsManager}
*/
public readonly settings: If<Ready, SettingsManager>
Expand All @@ -171,6 +179,13 @@ declare class Economy<Ready extends boolean = boolean> extends Emitter {
*/
public init(): Promise<boolean>

/**
* Connects the module to MongoDB database.
* @returns {Promise<void>}
* @private
*/
private _connect(): Promise<void>

/**
* Initializates the module.
* @returns {Promise<boolean>} If started successfully: true.
Expand Down
4 changes: 2 additions & 2 deletions mongodb/typings/cached/CachedItem.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ declare class CachedItem<

/**
* Removes a key from a cache in a cached item.
* @param {string} key Key to delete value from cache.
* @param {DataIdentifier<MemberIDRequired>} id Key to delete value from cache.
* @returns {void}
*/
public remove(id: DataIdentifier<MemberIDRequired>): void
Expand All @@ -108,4 +108,4 @@ declare class CachedItem<
public has(key: string): boolean
}

export = CachedItem
export = CachedItem
23 changes: 15 additions & 8 deletions mongodb/typings/cached/CachedItems.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import EmptyEconomyGuild from '../classes/EmptyEconomyGuild'
import EconomyUser from '../classes/EconomyUser'
import EmptyEconomyUser from '../classes/EmptyEconomyUser'


import CooldownItem from '../classes/CooldownItem'

import BalanceItem from '../classes/BalanceItem'
Expand All @@ -20,34 +21,40 @@ import ShopItem from '../classes/ShopItem'
import InventoryItem from '../classes/InventoryItem'
import HistoryItem from '../classes/HistoryItem'

import Currency from '../classes/Currency'

export class CachedGuilds extends CachedItem<EconomyGuild, EmptyEconomyGuild, false, false, false> {
public constructor(guildID: string, options: any[], database: DatabaseManager, cache: CacheManager)
public constructor(guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager)
}

export class CachedUsers extends CachedItem<EconomyUser, EmptyEconomyUser, true, false, false> {
public constructor(userID: string, guildID: string, options: any[], database: DatabaseManager, cache: CacheManager)
public constructor(userID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager)
}

export class CachedCooldowns extends CachedItem<CooldownItem, null, true, false, false> {
public constructor(userID: string, guildID: string, options: any[], database: DatabaseManager, cache: CacheManager)
public constructor(userID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager)
}

export class CachedBalance extends CachedItem<BalanceItem, null, true, false, false> {
public constructor(userID: string, guildID: string, options: any[], database: DatabaseManager, cache: CacheManager)
public constructor(userID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager)
}

export class CachedBank extends CachedItem<BankBalanceItem, null, true, false, false> {
public constructor(userID: string, guildID: string, options: any[], database: DatabaseManager, cache: CacheManager)
public constructor(userID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager)
}

export class CachedCurrency extends CachedItem<Currency, null, false, true, true> {
public constructor(currencyID: number, guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager)
}

export class CachedShop extends CachedItem<ShopItem, null, false, true, true> {
public constructor(guildID: string, options: any[], database: DatabaseManager, cache: CacheManager)
public constructor(guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager)
}

export class CachedInventory extends CachedItem<InventoryItem, null, true, true, true> {
public constructor(userID: string, guildID: string, options: any[], database: DatabaseManager, cache: CacheManager)
public constructor(userID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager)
}

export class CachedHistory extends CachedItem<HistoryItem, null, true, true, true> {
public constructor(userID: string, guildID: string, options: any[], database: DatabaseManager, cache: CacheManager)
public constructor(userID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager)
}
Loading

0 comments on commit d21cebb

Please sign in to comment.