-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**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
1 parent
ef120b3
commit 6600f4e
Showing
24 changed files
with
1,247 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import CurrencyManager from '../managers/CurrencyManager' | ||
|
||
import { CurrencyObject, CurrencyPropertyType } from '../interfaces/CurrencyObject' | ||
import CustomItemData from '../interfaces/CustomItemData' | ||
|
||
import EconomyConfiguration from '../interfaces/EconomyConfiguration' | ||
import DatabaseManager from '../managers/DatabaseManager' | ||
|
||
/** | ||
* Currency class. | ||
*/ | ||
declare class Currency<T extends object = any> { | ||
|
||
/** | ||
* @param {number} currencyID Currency ID. | ||
* @param {string} guildID Guild ID. | ||
* @param {EconomyConfiguration} ecoOptions Economy configuration object. | ||
* @param {CurrencyObject} currencyObject Currency object. | ||
* @param {DatabaseManager} database Database manager. | ||
*/ | ||
public constructor( | ||
currencyID: number, | ||
guildID: string, | ||
ecoOptions: EconomyConfiguration, | ||
currencyObject: CurrencyObject<T>, | ||
database: DatabaseManager | ||
) | ||
|
||
/** | ||
* Guild ID. | ||
* @type {string} | ||
*/ | ||
public guildID: string | ||
|
||
/** | ||
* Currency ID. | ||
* @type {number} | ||
*/ | ||
public id: number | ||
|
||
/** | ||
* Currency name. | ||
* @type {string} | ||
*/ | ||
public name: string | ||
|
||
/** | ||
* Currency symbol. | ||
* @type {string} | ||
*/ | ||
public symbol?: string | ||
|
||
/** | ||
* Currency balances object. | ||
* @type {object} | ||
*/ | ||
public balances: object | ||
|
||
/** | ||
* Custom currency data object. | ||
* @type {object} | ||
*/ | ||
public custom: CustomItemData<T> | ||
|
||
/** | ||
* Currency Manager. | ||
* @type {CurrencyManager} | ||
* @private | ||
*/ | ||
private _currencies: CurrencyManager | ||
|
||
/** | ||
* Creates a currency object in guild database. | ||
* @returns {Currency<T>} Currency object. | ||
*/ | ||
public create(): Currency<T> | ||
|
||
/** | ||
* Deletes the currency object from guild database. | ||
* @returns {Currency<T>} Currency object. | ||
*/ | ||
public delete(): Currency<T> | ||
|
||
/** | ||
* Edits the currency object. | ||
* @param {T} property Currency property to edit. | ||
* @param {K} value Any value to set. | ||
* @returns {Currency<T>} Edited currency object. | ||
*/ | ||
public edit< | ||
T extends keyof Omit<CurrencyObject, 'id' | 'balances'>, | ||
K extends CurrencyPropertyType<T> | ||
>( | ||
property: T, | ||
value: T extends 'custom' ? CustomItemData<K> : K, | ||
): Currency<K> | ||
|
||
/** | ||
* Edits the currency's custom data object. | ||
* @param {object} customObject Custom data object to set. | ||
* @returns {Currency<T>} Currency object with its updated custom property. | ||
*/ | ||
public setCustom(customObject: CurrencyObject<T>): Currency<T> | ||
|
||
/** | ||
* Sets the currency for specified member. | ||
* @param {number} amount Amount of money to set. | ||
* @param {string} memberID Member ID. | ||
* @param {string} [reason] The reason why the balance was set. | ||
* @returns {number} Amount of money that was set. | ||
*/ | ||
public setBalance(amount: number, memberID: string, reason: string): number | ||
|
||
/** | ||
* Sets the currency for specified member. | ||
* @param {string} memberID Member ID. | ||
* @returns {number} Member's balance. | ||
*/ | ||
public getBalance(memberID: string): number | ||
|
||
/** | ||
* Adds the currency for specified member. | ||
* @param {number} amount Amount of money to add. | ||
* @param {string} memberID Member ID. | ||
* @param {string} [reason] The reason why the balance was added. | ||
* @returns {number} Amount of money that was added. | ||
*/ | ||
public addBalance(amount: number, memberID: string, reason: string): number | ||
|
||
/** | ||
* Subtracts the currency for specified member. | ||
* @param {number} amount Amount of money to subtract. | ||
* @param {string} memberID Member ID. | ||
* @param {string} [reason] The reason why the balance was subtracted. | ||
* @returns {number} Amount of money that was subtracted. | ||
*/ | ||
public subtractBalance(amount: number, memberID: string, reason: string): number | ||
|
||
/** | ||
* Saves the currency object in database. | ||
* @returns {Currency} Currency instance. | ||
*/ | ||
public save(): Currency | ||
|
||
/** | ||
* Converts the currency object to string. | ||
* @returns {string} String representation of currency object. | ||
*/ | ||
public toString(): string | ||
} | ||
|
||
export = Currency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.