├── .eslintignore ├── .gitattributes ├── typings ├── interfaces │ ├── IsNull.d.ts │ ├── CustomItemData.d.ts │ ├── Maybe.d.ts │ ├── If.d.ts │ ├── TimeObject.d.ts │ ├── ItemProperty.d.ts │ ├── BalanceOperation.d.ts │ ├── SettingValueType.d.ts │ ├── RewardTypes.d.ts │ ├── BalanceOperations.d.ts │ ├── StackedInventoryItemObject.d.ts │ ├── EconomyDatabase.d.ts │ ├── SellingOperationInfo.d.ts │ ├── LeaderboardData.d.ts │ ├── CooldownData.d.ts │ ├── UserCooldownData.d.ts │ ├── UpdaterOptions.d.ts │ ├── ItemProperties.d.ts │ ├── VersionData.d.ts │ ├── RewardCooldownData.d.ts │ ├── EconomyConstructors.d.ts │ ├── ItemUseData.d.ts │ ├── EconomyErrorCodes.d.ts │ ├── ErrorHandlerConfiguration.d.ts │ ├── ErrorHandlerOptions.d.ts │ ├── ItemBuyData.d.ts │ ├── EditedItemData.d.ts │ ├── DailyObject.d.ts │ ├── WeeklyObject.d.ts │ ├── WorkObject.d.ts │ ├── UserFunction.d.ts │ ├── CurrencyObject.d.ts │ ├── CurrencyTransactionInfo.d.ts │ ├── TransferingOptions.d.ts │ ├── TransferringOptions.d.ts │ ├── ShopOperationInfo.d.ts │ ├── PayingOptions.d.ts │ ├── BalanceData.d.ts │ ├── RewardObject.d.ts │ ├── AddItemOptions.d.ts │ ├── RawEconomyUser.d.ts │ ├── InventoryData.d.ts │ ├── TransferingResult.d.ts │ ├── ItemData.d.ts │ ├── CheckerConfiguration.d.ts │ ├── TransferringResult.d.ts │ ├── CheckerOptions.d.ts │ ├── HistoryData.d.ts │ ├── CurrencyFactory.d.ts │ ├── SettingsTypes.d.ts │ └── EconomyEvents.d.ts ├── classes │ ├── EconomyError.d.ts │ ├── util │ │ ├── EconomyError.d.ts │ │ └── Emitter.d.ts │ ├── EmptyEconomyGuild.d.ts │ ├── EmptyEconomyUser.d.ts │ ├── guild │ │ ├── Leaderboards.d.ts │ │ └── Settings.d.ts │ ├── user │ │ ├── Bank.d.ts │ │ ├── Rewards.d.ts │ │ ├── Inventory.d.ts │ │ ├── History.d.ts │ │ └── Cooldowns.d.ts │ └── EconomyGuild.d.ts └── managers │ ├── GuildManager.d.ts │ ├── UserManager.d.ts │ ├── FetchManager.d.ts │ ├── UtilsManager.d.ts │ ├── BankManager.d.ts │ ├── SettingsManager.d.ts │ ├── RewardManager.d.ts │ └── HistoryManager.d.ts ├── mongodb ├── typings │ ├── interfaces │ │ ├── IsNull.d.ts │ │ ├── Maybe.d.ts │ │ ├── CustomItemData.d.ts │ │ ├── If.d.ts │ │ ├── TimeObject.d.ts │ │ ├── ItemProperty.d.ts │ │ ├── BalanceOperation.d.ts │ │ ├── SettingValueType.d.ts │ │ ├── RewardTypes.d.ts │ │ ├── DataIdentifier.d.ts │ │ ├── BalanceOperations.d.ts │ │ ├── StackedInventoryItemObject.d.ts │ │ ├── EconomyDatabase.d.ts │ │ ├── SellingOperationInfo.d.ts │ │ ├── LeaderboardData.d.ts │ │ ├── UserCooldownData.d.ts │ │ ├── UpdaterOptions.d.ts │ │ ├── ItemProperties.d.ts │ │ ├── VersionData.d.ts │ │ ├── RewardCooldownData.d.ts │ │ ├── ItemUseData.d.ts │ │ ├── ErrorHandlerConfiguration.d.ts │ │ ├── ErrorHandlerOptions.d.ts │ │ ├── ItemBuyData.d.ts │ │ ├── EconomyErrorCodes.d.ts │ │ ├── EditedItemData.d.ts │ │ ├── CurrencyObject.d.ts │ │ ├── CurrencyTransactionInfo.d.ts │ │ ├── EconomyConstructors.d.ts │ │ ├── UserFunction.d.ts │ │ ├── TransferingOptions.d.ts │ │ ├── TransferringOptions.d.ts │ │ ├── ShopOperationInfo.d.ts │ │ ├── BalanceData.d.ts │ │ ├── RewardObject.d.ts │ │ ├── AddItemOptions.d.ts │ │ ├── RawEconomyUser.d.ts │ │ ├── InventoryData.d.ts │ │ ├── TransferingResult.d.ts │ │ ├── ItemData.d.ts │ │ ├── TransferringResult.d.ts │ │ ├── CheckerConfiguration.d.ts │ │ ├── CheckerOptions.d.ts │ │ ├── HistoryData.d.ts │ │ ├── CurrencyFactory.d.ts │ │ ├── SettingsTypes.d.ts │ │ ├── EconomyEvents.d.ts │ │ └── EconomyConfiguration.d.ts │ ├── classes │ │ ├── util │ │ │ ├── EconomyError.d.ts │ │ │ └── Emitter.d.ts │ │ ├── EmptyEconomyGuild.d.ts │ │ ├── EmptyEconomyUser.d.ts │ │ ├── guild │ │ │ ├── Leaderboards.d.ts │ │ │ └── Settings.d.ts │ │ ├── BankBalanceItem.d.ts │ │ ├── BalanceItem.d.ts │ │ ├── CooldownItem.d.ts │ │ ├── user │ │ │ ├── Bank.d.ts │ │ │ ├── Rewards.d.ts │ │ │ ├── Inventory.d.ts │ │ │ ├── History.d.ts │ │ │ └── Cooldowns.d.ts │ │ └── EconomyGuild.d.ts │ ├── managers │ │ ├── GuildManager.d.ts │ │ ├── UserManager.d.ts │ │ ├── UtilsManager.d.ts │ │ ├── BankManager.d.ts │ │ └── SettingsManager.d.ts │ └── cached │ │ └── CachedItems.d.ts ├── src │ ├── structures │ │ ├── DefaultCurrencyObject.js │ │ ├── DefaultUserSchema.js │ │ ├── typeOf.js │ │ ├── timeParser.js │ │ └── DefaultConfiguration.js │ └── classes │ │ ├── EmptyEconomyGuild.js │ │ ├── EmptyEconomyUser.js │ │ ├── BankBalanceItem.js │ │ ├── BalanceItem.js │ │ └── util │ │ └── Emitter.js ├── LICENSE ├── index.js ├── .eslintrc.js ├── package.json └── EconomyItems.js ├── .gitignore ├── src ├── structures │ ├── DefaultCurrencyObject.js │ ├── DefaultUserSchema.js │ ├── typeOf.js │ ├── timeParser.js │ └── DefaultConfiguration.js └── classes │ ├── EmptyEconomyGuild.js │ ├── EmptyEconomyUser.js │ └── util │ ├── Emitter.js │ └── EconomyError.js ├── .github └── workflows │ └── build.yml ├── LICENSE ├── postinstall.js ├── index.js ├── package.json ├── .eslintrc.js ├── EconomyItems.js └── README.md /.eslintignore: -------------------------------------------------------------------------------- 1 | postinstall.js 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /typings/interfaces/IsNull.d.ts: -------------------------------------------------------------------------------- 1 | type IsNull = T extends null ? true : false 2 | 3 | export = IsNull 4 | -------------------------------------------------------------------------------- /typings/interfaces/CustomItemData.d.ts: -------------------------------------------------------------------------------- 1 | type CustomItemData = T 2 | 3 | export = CustomItemData -------------------------------------------------------------------------------- /typings/interfaces/Maybe.d.ts: -------------------------------------------------------------------------------- 1 | declare type Maybe = Exclude 2 | 3 | export = Maybe 4 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/IsNull.d.ts: -------------------------------------------------------------------------------- 1 | type IsNull = T extends null ? true : false 2 | 3 | export = IsNull 4 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/Maybe.d.ts: -------------------------------------------------------------------------------- 1 | declare type Maybe = Exclude 2 | 3 | export = Maybe 4 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/CustomItemData.d.ts: -------------------------------------------------------------------------------- 1 | type CustomItemData = T 2 | 3 | export = CustomItemData -------------------------------------------------------------------------------- /typings/interfaces/If.d.ts: -------------------------------------------------------------------------------- 1 | type If = T extends true ? IfTrue : IfFalse 5 | 6 | export = If -------------------------------------------------------------------------------- /mongodb/typings/interfaces/If.d.ts: -------------------------------------------------------------------------------- 1 | type If = T extends true ? IfTrue : IfFalse 5 | 6 | export = If -------------------------------------------------------------------------------- /typings/interfaces/TimeObject.d.ts: -------------------------------------------------------------------------------- 1 | declare type TimeObject = Record<'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds', number> 2 | 3 | export = TimeObject -------------------------------------------------------------------------------- /mongodb/typings/interfaces/TimeObject.d.ts: -------------------------------------------------------------------------------- 1 | declare type TimeObject = Record<'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds', number> 2 | 3 | export = TimeObject -------------------------------------------------------------------------------- /typings/interfaces/ItemProperty.d.ts: -------------------------------------------------------------------------------- 1 | declare type ItemProperty = 'description' | 'price' | 'name' | 'message' | 'maxAmount' | 'role' | 'custom' 2 | 3 | export = ItemProperty -------------------------------------------------------------------------------- /mongodb/typings/interfaces/ItemProperty.d.ts: -------------------------------------------------------------------------------- 1 | declare type ItemProperty = 'description' | 'price' | 'name' | 'message' | 'maxAmount' | 'role' | 'custom' 2 | 3 | export = ItemProperty -------------------------------------------------------------------------------- /typings/interfaces/BalanceOperation.d.ts: -------------------------------------------------------------------------------- 1 | import BalanceOperations from './BalanceOperations' 2 | 3 | type BalanceOperation = T 4 | 5 | export = BalanceOperation -------------------------------------------------------------------------------- /mongodb/typings/interfaces/BalanceOperation.d.ts: -------------------------------------------------------------------------------- 1 | import BalanceOperations from './BalanceOperations' 2 | 3 | type BalanceOperation = T 4 | 5 | export = BalanceOperation -------------------------------------------------------------------------------- /typings/interfaces/SettingValueType.d.ts: -------------------------------------------------------------------------------- 1 | import SettingsTypes from './SettingsTypes' 2 | 3 | type SettingValueType = SettingsTypes[T] 4 | 5 | export = SettingValueType -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | mongodb/economy-test/ 2 | 3 | des/ 4 | des-bak/ 5 | 6 | src/src/ 7 | mongodb/mongodb/ 8 | typings/typings/ 9 | examples/examples/ 10 | 11 | .husky/ 12 | 13 | *.bak 14 | *.sw[nop] 15 | -------------------------------------------------------------------------------- /mongodb/src/structures/DefaultCurrencyObject.js: -------------------------------------------------------------------------------- 1 | const defaultCurrencyObject = { 2 | id: 0, 3 | name: '', 4 | symbol: null, 5 | balances: {} 6 | } 7 | 8 | module.exports = defaultCurrencyObject 9 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/SettingValueType.d.ts: -------------------------------------------------------------------------------- 1 | import SettingsTypes from './SettingsTypes' 2 | 3 | type SettingValueType = SettingsTypes[T] 4 | 5 | export = SettingValueType -------------------------------------------------------------------------------- /src/structures/DefaultCurrencyObject.js: -------------------------------------------------------------------------------- 1 | const defaultCurrencyObject = { 2 | id: 0, 3 | name: '', 4 | symbol: null, 5 | balances: {} 6 | } 7 | 8 | module.exports = defaultCurrencyObject 9 | -------------------------------------------------------------------------------- /typings/interfaces/RewardTypes.d.ts: -------------------------------------------------------------------------------- 1 | export enum RewardType { 2 | DAILY = 0, 3 | WORK = 1, 4 | WEEKLY = 2, 5 | MONTHLY = 3, 6 | HOURLY = 4 7 | } 8 | 9 | export type Reward = T -------------------------------------------------------------------------------- /mongodb/typings/interfaces/RewardTypes.d.ts: -------------------------------------------------------------------------------- 1 | export enum RewardType { 2 | DAILY = 0, 3 | WORK = 1, 4 | WEEKLY = 2, 5 | MONTHLY = 3, 6 | HOURLY = 4 7 | } 8 | 9 | export type Reward = T -------------------------------------------------------------------------------- /mongodb/typings/interfaces/DataIdentifier.d.ts: -------------------------------------------------------------------------------- 1 | import If from './If' 2 | 3 | type DataIdentifier = If< 4 | MemberIDRequired, 5 | { guildID: string, memberID: string }, 6 | { guildID: string } 7 | > 8 | 9 | export = DataIdentifier -------------------------------------------------------------------------------- /typings/interfaces/BalanceOperations.d.ts: -------------------------------------------------------------------------------- 1 | type BalanceOperations = 2 | 'balanceAdd' | 'balanceSubtract' | 'balanceSet' | 3 | 'bankAdd' | 'bankSubtract' | 'bankSet' | 4 | 'customCurrencyAdd' | 'customCurrencySubtract' | 'customCurrencySet' 5 | 6 | export = BalanceOperations -------------------------------------------------------------------------------- /mongodb/typings/interfaces/BalanceOperations.d.ts: -------------------------------------------------------------------------------- 1 | type BalanceOperations = 2 | 'balanceAdd' | 'balanceSubtract' | 'balanceSet' | 3 | 'bankAdd' | 'bankSubtract' | 'bankSet' | 4 | 'customCurrencyAdd' | 'customCurrencySubtract' | 'customCurrencySet' 5 | 6 | export = BalanceOperations -------------------------------------------------------------------------------- /typings/interfaces/StackedInventoryItemObject.d.ts: -------------------------------------------------------------------------------- 1 | import InventoryItem from '../classes/InventoryItem' 2 | 3 | interface StackedInventoryItemObject { 4 | quantity: number 5 | totalPrice: number 6 | item: InventoryItem 7 | } 8 | 9 | export = StackedInventoryItemObject -------------------------------------------------------------------------------- /mongodb/typings/interfaces/StackedInventoryItemObject.d.ts: -------------------------------------------------------------------------------- 1 | import InventoryItem from '../classes/InventoryItem' 2 | 3 | interface StackedInventoryItemObject { 4 | quantity: number 5 | totalPrice: number 6 | item: InventoryItem 7 | } 8 | 9 | export = StackedInventoryItemObject -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | release: 5 | types: [created] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - uses: actions/setup-node@v3 13 | with: 14 | node-version: 16 15 | - run: echo ok 16 | -------------------------------------------------------------------------------- /typings/interfaces/EconomyDatabase.d.ts: -------------------------------------------------------------------------------- 1 | import RawEconomyUser from './RawEconomyUser' 2 | import HistoryData from './HistoryData' 3 | import ItemData from './ItemData' 4 | 5 | interface EconomyDatabase { 6 | [guildID: string]: { 7 | [memberID: string]: RawEconomyUser 8 | } 9 | } 10 | 11 | export = EconomyDatabase 12 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/EconomyDatabase.d.ts: -------------------------------------------------------------------------------- 1 | import RawEconomyUser from './RawEconomyUser' 2 | import HistoryData from './HistoryData' 3 | import ItemData from './ItemData' 4 | 5 | interface EconomyDatabase { 6 | [guildID: string]: { 7 | [memberID: string]: RawEconomyUser 8 | } 9 | } 10 | 11 | export = EconomyDatabase 12 | -------------------------------------------------------------------------------- /src/structures/DefaultUserSchema.js: -------------------------------------------------------------------------------- 1 | const defaultUserSchema = { 2 | dailyCooldown: null, 3 | workCooldown: null, 4 | weeklyCooldown: null, 5 | monthlyCooldown: null, 6 | hourlyCooldown: null, 7 | money: 0, 8 | bank: 0, 9 | inventory: [], 10 | history: [] 11 | } 12 | 13 | module.exports = defaultUserSchema 14 | -------------------------------------------------------------------------------- /mongodb/src/structures/DefaultUserSchema.js: -------------------------------------------------------------------------------- 1 | const defaultUserSchema = { 2 | dailyCooldown: null, 3 | workCooldown: null, 4 | weeklyCooldown: null, 5 | monthlyCooldown: null, 6 | hourlyCooldown: null, 7 | money: 0, 8 | bank: 0, 9 | inventory: [], 10 | history: [] 11 | } 12 | 13 | module.exports = defaultUserSchema 14 | -------------------------------------------------------------------------------- /typings/interfaces/SellingOperationInfo.d.ts: -------------------------------------------------------------------------------- 1 | import InventoryItem from '../classes/InventoryItem' 2 | import ShopOperationInfo from './ShopOperationInfo' 3 | 4 | type SellingOperationInfo = Exclude, 'item'> & { 5 | 6 | /** 7 | * Inventory item object. 8 | */ 9 | item: InventoryItem 10 | } 11 | 12 | export = SellingOperationInfo -------------------------------------------------------------------------------- /mongodb/typings/interfaces/SellingOperationInfo.d.ts: -------------------------------------------------------------------------------- 1 | import InventoryItem from '../classes/InventoryItem' 2 | import ShopOperationInfo from './ShopOperationInfo' 3 | 4 | type SellingOperationInfo = Exclude, 'item'> & { 5 | 6 | /** 7 | * Inventory item object. 8 | */ 9 | item: InventoryItem 10 | } 11 | 12 | export = SellingOperationInfo -------------------------------------------------------------------------------- /typings/interfaces/LeaderboardData.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Leaderboard data object. 3 | */ 4 | declare interface LeaderboardData { 5 | 6 | /** 7 | * User ID. 8 | */ 9 | userID: string 10 | 11 | /** 12 | * Amount of money. 13 | */ 14 | money: number 15 | 16 | /** 17 | * The position of the user in leaderboard. 18 | */ 19 | index: number 20 | } 21 | 22 | 23 | export = LeaderboardData -------------------------------------------------------------------------------- /mongodb/typings/interfaces/LeaderboardData.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Leaderboard data object. 3 | */ 4 | declare interface LeaderboardData { 5 | 6 | /** 7 | * User ID. 8 | */ 9 | userID: string 10 | 11 | /** 12 | * Amount of money. 13 | */ 14 | money: number 15 | 16 | /** 17 | * The position of the user in leaderboard. 18 | */ 19 | index: number 20 | } 21 | 22 | 23 | export = LeaderboardData -------------------------------------------------------------------------------- /typings/classes/EconomyError.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * EconomyError class. 3 | */ 4 | declare class EconomyError extends Error { 5 | /** 6 | * Name of the error 7 | */ 8 | public name: 'EconomyError' 9 | 10 | /** 11 | * Creates an 'EconomyError' error instance. 12 | * @param {string | Error} message Error message. 13 | */ 14 | constructor(message: string | Error) 15 | } 16 | 17 | export = EconomyError -------------------------------------------------------------------------------- /typings/interfaces/CooldownData.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Cooldown data object. 3 | */ 4 | declare class CooldownData { 5 | /** 6 | * User's daily cooldown. 7 | */ 8 | dailyCooldown: number 9 | 10 | /** 11 | * User's work cooldown. 12 | */ 13 | workCooldown: number 14 | 15 | /** 16 | * User's weekly cooldown. 17 | */ 18 | weeklyCooldown: number 19 | } 20 | 21 | export = CooldownData -------------------------------------------------------------------------------- /typings/interfaces/UserCooldownData.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Cooldown data object. 3 | */ 4 | declare interface UserCooldownData { 5 | 6 | /** 7 | * User's daily cooldown. 8 | */ 9 | dailyCooldown: number 10 | 11 | /** 12 | * User's work cooldown. 13 | */ 14 | workCooldown: number 15 | 16 | /** 17 | * User's weekly cooldown. 18 | */ 19 | weeklyCooldown: number 20 | } 21 | 22 | export = UserCooldownData -------------------------------------------------------------------------------- /mongodb/typings/interfaces/UserCooldownData.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Cooldown data object. 3 | */ 4 | declare interface UserCooldownData { 5 | 6 | /** 7 | * User's daily cooldown. 8 | */ 9 | dailyCooldown: number 10 | 11 | /** 12 | * User's work cooldown. 13 | */ 14 | workCooldown: number 15 | 16 | /** 17 | * User's weekly cooldown. 18 | */ 19 | weeklyCooldown: number 20 | } 21 | 22 | export = UserCooldownData -------------------------------------------------------------------------------- /typings/interfaces/UpdaterOptions.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Update checker configuration. 3 | */ 4 | declare interface UpdaterOptions { 5 | 6 | /** 7 | * Sends the update state message in console on start. Default: true. 8 | */ 9 | checkUpdates?: boolean 10 | 11 | /** 12 | * Sends the message in console on start if module is up to date. Default: true. 13 | */ 14 | upToDateMessage?: boolean 15 | } 16 | 17 | export = UpdaterOptions 18 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/UpdaterOptions.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Update checker configuration. 3 | */ 4 | declare interface UpdaterOptions { 5 | 6 | /** 7 | * Sends the update state message in console on start. Default: true. 8 | */ 9 | checkUpdates?: boolean 10 | 11 | /** 12 | * Sends the message in console on start if module is up to date. Default: true. 13 | */ 14 | upToDateMessage?: boolean 15 | } 16 | 17 | export = UpdaterOptions 18 | -------------------------------------------------------------------------------- /typings/interfaces/ItemProperties.d.ts: -------------------------------------------------------------------------------- 1 | import CustomItemData from '../interfaces/CustomItemData' 2 | 3 | export interface ItemProperties { 4 | id: number 5 | name: string 6 | description: string 7 | price: number 8 | message: string 9 | maxAmount: number 10 | role: string 11 | date: string 12 | custom: CustomItemData 13 | } 14 | 15 | export type ItemPropertyType = T extends 'custom' ? object : ItemProperties[T] -------------------------------------------------------------------------------- /typings/interfaces/VersionData.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Object of 'UtilsManager.checkUpdates()' method. 3 | */ 4 | declare interface VersionData { 5 | 6 | /** 7 | * Checks for if module is up to date. 8 | */ 9 | updated: boolean 10 | 11 | /** 12 | * Shows an installed version of the module 13 | */ 14 | installedVersion: string 15 | 16 | /** 17 | * Shows the latest version of the module 18 | */ 19 | packageVersion: string 20 | } 21 | 22 | export = VersionData -------------------------------------------------------------------------------- /mongodb/typings/interfaces/ItemProperties.d.ts: -------------------------------------------------------------------------------- 1 | import CustomItemData from '../interfaces/CustomItemData' 2 | 3 | export interface ItemProperties { 4 | id: number 5 | name: string 6 | description: string 7 | price: number 8 | message: string 9 | maxAmount: number 10 | role: string 11 | date: string 12 | custom: CustomItemData 13 | } 14 | 15 | export type ItemPropertyType = T extends 'custom' ? object : ItemProperties[T] -------------------------------------------------------------------------------- /mongodb/typings/interfaces/VersionData.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Object of 'UtilsManager.checkUpdates()' method. 3 | */ 4 | declare interface VersionData { 5 | 6 | /** 7 | * Checks for if module is up to date. 8 | */ 9 | updated: boolean 10 | 11 | /** 12 | * Shows an installed version of the module 13 | */ 14 | installedVersion: string 15 | 16 | /** 17 | * Shows the latest version of the module 18 | */ 19 | packageVersion: string 20 | } 21 | 22 | export = VersionData -------------------------------------------------------------------------------- /typings/interfaces/RewardCooldownData.d.ts: -------------------------------------------------------------------------------- 1 | import TimeObject from './TimeObject' 2 | 3 | declare interface RewardCooldownData { 4 | 5 | /** 6 | * A time object with the remaining time until the cooldown ends. 7 | */ 8 | time: TimeObject 9 | 10 | /** 11 | * A formatted string with the remaining time until the cooldown ends. 12 | */ 13 | pretty: string 14 | 15 | /** 16 | * Cooldown end timestamp. 17 | */ 18 | endTimestamp: number 19 | } 20 | 21 | export = RewardCooldownData 22 | -------------------------------------------------------------------------------- /typings/interfaces/EconomyConstructors.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyGuild from '../classes/EconomyGuild' 2 | import EconomyUser from '../classes/EconomyUser' 3 | 4 | import ShopItem from '../classes/ShopItem' 5 | import InventoryItem from '../classes/InventoryItem' 6 | import HistoryItem from '../classes/HistoryItem' 7 | 8 | import Currency from '../classes/Currency' 9 | 10 | 11 | type EconomyConstructors = 12 | EconomyGuild | EconomyUser | ShopItem | Currency | InventoryItem | HistoryItem 13 | 14 | export = EconomyConstructors -------------------------------------------------------------------------------- /mongodb/typings/interfaces/RewardCooldownData.d.ts: -------------------------------------------------------------------------------- 1 | import TimeObject from './TimeObject' 2 | 3 | declare interface RewardCooldownData { 4 | 5 | /** 6 | * A time object with the remaining time until the cooldown ends. 7 | */ 8 | time: TimeObject 9 | 10 | /** 11 | * A formatted string with the remaining time until the cooldown ends. 12 | */ 13 | pretty: string 14 | 15 | /** 16 | * Cooldown end timestamp. 17 | */ 18 | endTimestamp: number 19 | } 20 | 21 | export = RewardCooldownData 22 | -------------------------------------------------------------------------------- /typings/interfaces/ItemUseData.d.ts: -------------------------------------------------------------------------------- 1 | import InventoryItem from '../classes/InventoryItem' 2 | 3 | 4 | declare interface ItemUseData { 5 | 6 | /** 7 | * Guild ID. 8 | */ 9 | guildID: string 10 | 11 | /** 12 | * The user ID that used the item. 13 | */ 14 | usedBy: string 15 | 16 | /** 17 | * The item that was used. 18 | */ 19 | item: InventoryItem 20 | 21 | /** 22 | * The message that the user received after using the item. 23 | */ 24 | receivedMessage: string 25 | } 26 | 27 | export = ItemUseData -------------------------------------------------------------------------------- /mongodb/typings/interfaces/ItemUseData.d.ts: -------------------------------------------------------------------------------- 1 | import InventoryItem from '../classes/InventoryItem' 2 | 3 | 4 | declare interface ItemUseData { 5 | 6 | /** 7 | * Guild ID. 8 | */ 9 | guildID: string 10 | 11 | /** 12 | * The user ID that used the item. 13 | */ 14 | usedBy: string 15 | 16 | /** 17 | * The item that was used. 18 | */ 19 | item: InventoryItem 20 | 21 | /** 22 | * The message that the user received after using the item. 23 | */ 24 | receivedMessage: string 25 | } 26 | 27 | export = ItemUseData -------------------------------------------------------------------------------- /typings/interfaces/EconomyErrorCodes.d.ts: -------------------------------------------------------------------------------- 1 | declare type EconomyErrorCodes = 2 | 'INVALID_TYPE' | 3 | 'UNKNOWN_ERROR' | 4 | 'PARAMETER_NOT_SPECIFIED' | 5 | 'OLD_NODE_VERSION' | 6 | 'ITEM_PROPERTY_INVALID' | 7 | 'INVALID_INPUT' | 8 | 'NO_DISCORD_CLIENT' | 9 | 'ROLE_NOT_FOUND' | 10 | 'PURCHASES_HISTORY_DISABLED' | 11 | 'SETTINGS_KEY_INVALID' | 12 | 'READONLY_PROPERTY' | 13 | 'INVALID_PROPERTY' | 14 | 'CURRENCY_NOT_FOUND' | 15 | 'INVALID_ERROR_CODE' | 16 | 'MODULE_NOT_READY' | 17 | 'STORAGE_FILE_ERROR' 18 | 19 | export = EconomyErrorCodes -------------------------------------------------------------------------------- /typings/interfaces/ErrorHandlerConfiguration.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Error handler configuration. 3 | */ 4 | declare interface ErrorHandlerConfiguration { 5 | 6 | /** 7 | * Handles all errors on startup. Default: true. 8 | */ 9 | handleErrors?: boolean 10 | 11 | /** 12 | * Amount of attempts to load the module. Use 0 for infinity attempts. Default: 5. 13 | */ 14 | attempts?: number 15 | 16 | /** 17 | * Time between every attempt to start the module (in ms). Default: 3000. 18 | */ 19 | time?: number 20 | } 21 | 22 | export = ErrorHandlerConfiguration 23 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/ErrorHandlerConfiguration.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Error handler configuration. 3 | */ 4 | declare interface ErrorHandlerConfiguration { 5 | 6 | /** 7 | * Handles all errors on startup. Default: true. 8 | */ 9 | handleErrors?: boolean 10 | 11 | /** 12 | * Amount of attempts to load the module. Use 0 for infinity attempts. Default: 5. 13 | */ 14 | attempts?: number 15 | 16 | /** 17 | * Time between every attempt to start the module (in ms). Default: 3000. 18 | */ 19 | time?: number 20 | } 21 | 22 | export = ErrorHandlerConfiguration 23 | -------------------------------------------------------------------------------- /typings/interfaces/ErrorHandlerOptions.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Error handler configuration. 3 | */ 4 | declare interface ErrorHandlerOptions { 5 | 6 | /** 7 | * Handles all errors on startup. Default: true. 8 | */ 9 | handleErrors?: boolean 10 | 11 | /** 12 | * Amount of attempts to load the module. Use 0 for infinity attempts. Default: 5. 13 | */ 14 | attempts?: number 15 | 16 | /** 17 | * Time between every attempt to start the module (in ms). Default: 3000. 18 | */ 19 | time?: number 20 | } 21 | 22 | export = ErrorHandlerOptions 23 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/ErrorHandlerOptions.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Error handler configuration. 3 | */ 4 | declare interface ErrorHandlerOptions { 5 | 6 | /** 7 | * Handles all errors on startup. Default: true. 8 | */ 9 | handleErrors?: boolean 10 | 11 | /** 12 | * Amount of attempts to load the module. Use 0 for infinity attempts. Default: 5. 13 | */ 14 | attempts?: number 15 | 16 | /** 17 | * Time between every attempt to start the module (in ms). Default: 3000. 18 | */ 19 | time?: number 20 | } 21 | 22 | export = ErrorHandlerOptions 23 | -------------------------------------------------------------------------------- /src/structures/typeOf.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable use-isnan */ 2 | 3 | /** 4 | * Returns the exact type of the specified input. Utilility function. 5 | * @param {any} input The input to check. 6 | * @returns {string} Input exact type. 7 | */ 8 | const typeOf = input => { 9 | if ((typeof input == 'object' || typeof input == 'function') && input?.prototype) { 10 | return input.name 11 | } 12 | 13 | if (input == null || input == undefined || (typeof input == 'number' && isNaN(input))) { 14 | return `${input}` 15 | } 16 | 17 | return input.constructor.name 18 | } 19 | 20 | module.exports = typeOf 21 | -------------------------------------------------------------------------------- /mongodb/src/structures/typeOf.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable use-isnan */ 2 | 3 | /** 4 | * Returns the exact type of the specified input. Utilility function. 5 | * @param {any} input The input to check. 6 | * @returns {string} Input exact type. 7 | */ 8 | const typeOf = input => { 9 | if ((typeof input == 'object' || typeof input == 'function') && input?.prototype) { 10 | return input.name 11 | } 12 | 13 | if (input == null || input == undefined || (typeof input == 'number' && isNaN(input))) { 14 | return `${input}` 15 | } 16 | 17 | return input.constructor.name 18 | } 19 | 20 | module.exports = typeOf 21 | -------------------------------------------------------------------------------- /typings/classes/util/EconomyError.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyErrorCodes from '../../interfaces/EconomyErrorCodes' 2 | 3 | /** 4 | * EconomyError class. 5 | */ 6 | declare class EconomyError extends Error { 7 | 8 | /** 9 | * Creates an 'EconomyError' error instance. 10 | * @param {string | Error} message Error message. 11 | */ 12 | public constructor(message: string | Error, code?: EconomyErrorCodes) 13 | 14 | /** 15 | * Name of the error 16 | */ 17 | public name: 'EconomyError' 18 | 19 | /** 20 | * Error code. 21 | */ 22 | public code: EconomyErrorCodes 23 | } 24 | 25 | export = EconomyError -------------------------------------------------------------------------------- /typings/interfaces/ItemBuyData.d.ts: -------------------------------------------------------------------------------- 1 | import ShopItem from '../classes/ShopItem' 2 | import Currency from '../classes/Currency' 3 | 4 | import Maybe from './Maybe' 5 | 6 | 7 | declare interface ItemBuyData { 8 | 9 | /** 10 | * Guild ID. 11 | */ 12 | guildID: string 13 | 14 | /** 15 | * The user ID that bought the item. 16 | */ 17 | boughtBy: string 18 | 19 | /** 20 | * The item that was bought. 21 | */ 22 | item: ShopItem 23 | 24 | /** 25 | * The currency that was used for the purchase. 26 | */ 27 | currencyUsed: Maybe 28 | } 29 | 30 | export = ItemBuyData -------------------------------------------------------------------------------- /mongodb/typings/classes/util/EconomyError.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyErrorCodes from '../../interfaces/EconomyErrorCodes' 2 | 3 | /** 4 | * EconomyError class. 5 | */ 6 | declare class EconomyError extends Error { 7 | 8 | /** 9 | * Creates an 'EconomyError' error instance. 10 | * @param {string | Error} message Error message. 11 | */ 12 | public constructor(message: string | Error, code?: EconomyErrorCodes) 13 | 14 | /** 15 | * Name of the error 16 | */ 17 | public name: 'EconomyError' 18 | 19 | /** 20 | * Error code. 21 | */ 22 | public code: EconomyErrorCodes 23 | } 24 | 25 | export = EconomyError -------------------------------------------------------------------------------- /mongodb/typings/interfaces/ItemBuyData.d.ts: -------------------------------------------------------------------------------- 1 | import ShopItem from '../classes/ShopItem' 2 | import Currency from '../classes/Currency' 3 | 4 | import Maybe from './Maybe' 5 | 6 | 7 | declare interface ItemBuyData { 8 | 9 | /** 10 | * Guild ID. 11 | */ 12 | guildID: string 13 | 14 | /** 15 | * The user ID that bought the item. 16 | */ 17 | boughtBy: string 18 | 19 | /** 20 | * The item that was bought. 21 | */ 22 | item: ShopItem 23 | 24 | /** 25 | * The currency that was used for the purchase. 26 | */ 27 | currencyUsed: Maybe 28 | } 29 | 30 | export = ItemBuyData -------------------------------------------------------------------------------- /mongodb/typings/interfaces/EconomyErrorCodes.d.ts: -------------------------------------------------------------------------------- 1 | declare type EconomyErrorCodes = 2 | 'INVALID_TYPE' | 3 | 'INVALID_CACHING_IDENTIFIERS' | 4 | 'INVALID_CACHE_ITEM_NAME' | 5 | 'UNKNOWN_ERROR' | 6 | 'ITEM_PROPERTY_INVALID' | 7 | 'INVALID_INPUT' | 8 | 'PARAMETER_NOT_SPECIFIED' | 9 | 'OLD_NODE_VERSION' | 10 | 'NO_DISCORD_CLIENT' | 11 | 'ROLE_NOT_FOUND' | 12 | 'PURCHASES_HISTORY_DISABLED' | 13 | 'SETTINGS_KEY_INVALID' | 14 | 'READONLY_PROPERTY' | 15 | 'INVALID_PROPERTY' | 16 | 'CURRENCY_NOT_FOUND' | 17 | 'INVALID_ERROR_CODE' | 18 | 'MODULE_NOT_READY' | 19 | 'NO_CONNECTION_DATA' 20 | 21 | export = EconomyErrorCodes -------------------------------------------------------------------------------- /typings/interfaces/EditedItemData.d.ts: -------------------------------------------------------------------------------- 1 | import ShopItem from '../classes/ShopItem' 2 | 3 | 4 | /** 5 | * Item info object for 'shopItemEdit' event. 6 | */ 7 | declare interface EditedItemData { 8 | 9 | /** 10 | * Item that was edited. 11 | */ 12 | item: ShopItem 13 | 14 | /** 15 | * Guild ID. 16 | */ 17 | guildID: string 18 | 19 | /** 20 | * The item property that was changed. 21 | */ 22 | changedProperty: string 23 | 24 | /** 25 | * Value before edit. 26 | */ 27 | oldValue: string 28 | 29 | /** 30 | * Value after edit. 31 | */ 32 | newValue: string 33 | } 34 | 35 | export = EditedItemData 36 | -------------------------------------------------------------------------------- /typings/interfaces/DailyObject.d.ts: -------------------------------------------------------------------------------- 1 | import TimeObject from './TimeObject' 2 | 3 | /** 4 | * Object that returns on 'Economy.daily()' method. 5 | */ 6 | declare class DailyObject { 7 | /** 8 | * The status of receiving money. 9 | */ 10 | status: boolean 11 | 12 | /** 13 | * If reward is already claimed: time object; else: daily reward. 14 | */ 15 | value: TimeObject 16 | 17 | /** 18 | * If reward is already claimed: formatted time in string; else: daily reward. 19 | */ 20 | pretty: string | number 21 | 22 | /** 23 | * Daily reward. 24 | */ 25 | reward: number 26 | } 27 | 28 | export = DailyObject -------------------------------------------------------------------------------- /typings/interfaces/WeeklyObject.d.ts: -------------------------------------------------------------------------------- 1 | import TimeObject from './TimeObject' 2 | 3 | /** 4 | * Object that returns on 'Economy.weekly()' method. 5 | */ 6 | declare class WeeklyObject { 7 | /** 8 | * The status of receiving money. 9 | */ 10 | status: boolean 11 | 12 | /** 13 | * If reward is already claimed: time object; else: weekly reward. 14 | */ 15 | value: TimeObject 16 | 17 | /** 18 | * If reward is already claimed: formatted time in string; else: weekly reward. 19 | */ 20 | pretty: string | number 21 | 22 | /** 23 | * Weekly reward. 24 | */ 25 | reward: number 26 | } 27 | 28 | export = WeeklyObject -------------------------------------------------------------------------------- /typings/interfaces/WorkObject.d.ts: -------------------------------------------------------------------------------- 1 | import TimeObject from './TimeObject' 2 | 3 | /** 4 | * Object that returns on 'Economy.work()' method. 5 | */ 6 | declare class WorkObject { 7 | /** 8 | * The status of receiving money. 9 | */ 10 | status: boolean 11 | 12 | /** 13 | * If reward is already claimed: time object; else: work reward. 14 | */ 15 | value: TimeObject 16 | 17 | /** 18 | * If reward is already claimed: formatted time in string; else: work reward. 19 | */ 20 | pretty: string | number 21 | 22 | /** 23 | * Work reward. 24 | */ 25 | reward: number | Number[] 26 | } 27 | 28 | export = WorkObject -------------------------------------------------------------------------------- /mongodb/typings/interfaces/EditedItemData.d.ts: -------------------------------------------------------------------------------- 1 | import ShopItem from '../classes/ShopItem' 2 | 3 | 4 | /** 5 | * Item info object for 'shopItemEdit' event. 6 | */ 7 | declare interface EditedItemData { 8 | 9 | /** 10 | * Item that was edited. 11 | */ 12 | item: ShopItem 13 | 14 | /** 15 | * Guild ID. 16 | */ 17 | guildID: string 18 | 19 | /** 20 | * The item property that was changed. 21 | */ 22 | changedProperty: string 23 | 24 | /** 25 | * Value before edit. 26 | */ 27 | oldValue: string 28 | 29 | /** 30 | * Value after edit. 31 | */ 32 | newValue: string 33 | } 34 | 35 | export = EditedItemData 36 | -------------------------------------------------------------------------------- /typings/interfaces/UserFunction.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyUser from '../classes/EconomyUser' 2 | import EmptyEconomyUser from '../classes/EmptyEconomyUser' 3 | 4 | import If from './If' 5 | import IsNull from './IsNull' 6 | 7 | type UserFunction< 8 | MemberIDRequired extends boolean, 9 | ReturnType = EconomyUser, 10 | EmptyReturnType = EmptyEconomyUser 11 | > = 12 | If< 13 | MemberIDRequired, 14 | (memberID: string, guildID: string) => 15 | If, ReturnType, ReturnType | EmptyReturnType>, 16 | (userID: string) => 17 | If, ReturnType, ReturnType | EmptyReturnType> 18 | > 19 | 20 | export = UserFunction 21 | -------------------------------------------------------------------------------- /typings/interfaces/CurrencyObject.d.ts: -------------------------------------------------------------------------------- 1 | import CustomItemData from './CustomItemData' 2 | 3 | export interface CurrencyObject { 4 | 5 | /** 6 | * Currency ID. 7 | */ 8 | id: number 9 | 10 | /** 11 | * Currency name. 12 | */ 13 | name: string 14 | 15 | /** 16 | * Currency symbol. 17 | */ 18 | symbol: string 19 | 20 | /** 21 | * Currency balances object. 22 | */ 23 | balances: object 24 | 25 | /** 26 | * Custom currency data object. 27 | */ 28 | custom: CustomItemData 29 | } 30 | 31 | export type CurrencyPropertyType = T extends 'custom' ? object : CurrencyObject[T] -------------------------------------------------------------------------------- /mongodb/typings/interfaces/CurrencyObject.d.ts: -------------------------------------------------------------------------------- 1 | import CustomItemData from './CustomItemData' 2 | 3 | export interface CurrencyObject { 4 | 5 | /** 6 | * Currency ID. 7 | */ 8 | id: number 9 | 10 | /** 11 | * Currency name. 12 | */ 13 | name: string 14 | 15 | /** 16 | * Currency symbol. 17 | */ 18 | symbol: string 19 | 20 | /** 21 | * Currency balances object. 22 | */ 23 | balances: object 24 | 25 | /** 26 | * Custom currency data object. 27 | */ 28 | custom: CustomItemData 29 | } 30 | 31 | export type CurrencyPropertyType = T extends 'custom' ? object : CurrencyObject[T] -------------------------------------------------------------------------------- /typings/interfaces/CurrencyTransactionInfo.d.ts: -------------------------------------------------------------------------------- 1 | import Currency from '../classes/Currency' 2 | 3 | declare interface CurrencyTransactionInfo { 4 | 5 | /** 6 | * Status of the transaction. 7 | */ 8 | status: boolean 9 | 10 | /** 11 | * Amount of currency used in the transaction. 12 | */ 13 | amount: number 14 | 15 | /** 16 | * Currency balance before completing the transaction. 17 | */ 18 | oldBalance: number 19 | 20 | /** 21 | * Currency balance after completing the transaction. 22 | */ 23 | newBalance: number 24 | 25 | /** 26 | * The currency that was used in the transaction. 27 | */ 28 | currency: Currency 29 | } 30 | 31 | export = CurrencyTransactionInfo 32 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/CurrencyTransactionInfo.d.ts: -------------------------------------------------------------------------------- 1 | import Currency from '../classes/Currency' 2 | 3 | declare interface CurrencyTransactionInfo { 4 | 5 | /** 6 | * Status of the transaction. 7 | */ 8 | status: boolean 9 | 10 | /** 11 | * Amount of currency used in the transaction. 12 | */ 13 | amount: number 14 | 15 | /** 16 | * Currency balance before completing the transaction. 17 | */ 18 | oldBalance: number 19 | 20 | /** 21 | * Currency balance after completing the transaction. 22 | */ 23 | newBalance: number 24 | 25 | /** 26 | * The currency that was used in the transaction. 27 | */ 28 | currency: Currency 29 | } 30 | 31 | export = CurrencyTransactionInfo 32 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/EconomyConstructors.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyGuild from '../classes/EconomyGuild' 2 | import EconomyUser from '../classes/EconomyUser' 3 | 4 | import BalanceItem from '../classes/BalanceItem' 5 | import BankBalanceItem from '../classes/BankBalanceItem' 6 | 7 | import CooldownItem from '../classes/CooldownItem' 8 | 9 | import ShopItem from '../classes/ShopItem' 10 | import InventoryItem from '../classes/InventoryItem' 11 | import HistoryItem from '../classes/HistoryItem' 12 | 13 | import Currency from '../classes/Currency' 14 | 15 | 16 | type EconomyConstructors = 17 | EconomyGuild | EconomyUser | BalanceItem | BankBalanceItem | Currency | CooldownItem | ShopItem | InventoryItem | HistoryItem 18 | 19 | export = EconomyConstructors 20 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/UserFunction.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyUser from '../classes/EconomyUser' 2 | import EmptyEconomyUser from '../classes/EmptyEconomyUser' 3 | 4 | import If from './If' 5 | import IsNull from './IsNull' 6 | 7 | type UserFunction< 8 | MemberIDRequired extends boolean, 9 | ReturnType = EconomyUser, 10 | EmptyReturnType = EmptyEconomyUser 11 | > = 12 | If< 13 | MemberIDRequired, 14 | (memberID: string, guildID: string) => Promise< 15 | If, ReturnType, ReturnType | EmptyReturnType> 16 | >, 17 | (userID: string) => Promise< 18 | If, ReturnType, ReturnType | EmptyReturnType> 19 | > 20 | > 21 | 22 | export = UserFunction 23 | -------------------------------------------------------------------------------- /typings/classes/EmptyEconomyGuild.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 2 | 3 | import EconomyGuild from './EconomyGuild' 4 | import DatabaseManager from '../managers/DatabaseManager' 5 | 6 | 7 | 8 | /** 9 | * Empty economy guild class. 10 | */ 11 | declare class EmptyEconomyGuild extends EconomyGuild { 12 | 13 | /** 14 | * Economy guild class. 15 | * @param {string} guildID Guild ID. 16 | * @param {EconomyConfiguration} options Economy configuration. 17 | * @param {DatabaseManager} database Database manager. 18 | */ 19 | public constructor( 20 | guildID: string, 21 | options: EconomyConfiguration, 22 | database: DatabaseManager 23 | ) 24 | } 25 | 26 | export = EmptyEconomyGuild -------------------------------------------------------------------------------- /typings/interfaces/TransferingOptions.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Transfering options. 3 | */ 4 | interface TransferingOptions { 5 | 6 | /** 7 | * Amount of money to send. 8 | */ 9 | amount: number 10 | 11 | /** 12 | * A member ID who will send the money. 13 | */ 14 | senderMemberID: string 15 | 16 | /** 17 | * A member ID who will receive the money. 18 | */ 19 | receiverMemberID: string 20 | 21 | 22 | /** 23 | * The reason of subtracting the money from sender. (example: "sending money to {user}") 24 | */ 25 | sendingReason?: string 26 | 27 | /** 28 | * The reason of subtracting the money from sender. (example: "receiving money from {user}") 29 | */ 30 | receivingReason?: string 31 | } 32 | 33 | export = TransferingOptions -------------------------------------------------------------------------------- /mongodb/typings/interfaces/TransferingOptions.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Transfering options. 3 | */ 4 | interface TransferingOptions { 5 | 6 | /** 7 | * Amount of money to send. 8 | */ 9 | amount: number 10 | 11 | /** 12 | * A member ID who will send the money. 13 | */ 14 | senderMemberID: string 15 | 16 | /** 17 | * A member ID who will receive the money. 18 | */ 19 | receiverMemberID: string 20 | 21 | 22 | /** 23 | * The reason of subtracting the money from sender. (example: "sending money to {user}") 24 | */ 25 | sendingReason?: string 26 | 27 | /** 28 | * The reason of subtracting the money from sender. (example: "receiving money from {user}") 29 | */ 30 | receivingReason?: string 31 | } 32 | 33 | export = TransferingOptions -------------------------------------------------------------------------------- /typings/classes/EmptyEconomyUser.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 2 | 3 | import EconomyUser from './EconomyUser' 4 | import DatabaseManager from '../managers/DatabaseManager' 5 | 6 | 7 | /** 8 | * Empty economy user class. 9 | */ 10 | declare class EmptyEconomyUser extends EconomyUser { 11 | 12 | /** 13 | * Economy user class. 14 | * @param {string} userID User ID. 15 | * @param {string} guildID Guild ID. 16 | * @param {EconomyConfiguration} options Economy configuration. 17 | * @param {DatabaseManager} database Database Manager. 18 | */ 19 | public constructor( 20 | userID: string, 21 | guildID: string, 22 | options: EconomyConfiguration, 23 | database: DatabaseManager 24 | ) 25 | } 26 | 27 | export = EmptyEconomyUser -------------------------------------------------------------------------------- /typings/interfaces/TransferringOptions.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Transferring options. 3 | */ 4 | interface TransferringOptions { 5 | 6 | /** 7 | * Amount of money to send. 8 | */ 9 | amount: number 10 | 11 | /** 12 | * A member ID who will send the money. 13 | */ 14 | senderMemberID: string 15 | 16 | /** 17 | * A member ID who will receive the money. 18 | */ 19 | receiverMemberID: string 20 | 21 | 22 | /** 23 | * The reason of subtracting the money from sender. (example: "sending money to {user}") 24 | */ 25 | sendingReason?: string 26 | 27 | /** 28 | * The reason of subtracting the money from sender. (example: "receiving money from {user}") 29 | */ 30 | receivingReason?: string 31 | } 32 | 33 | export = TransferringOptions -------------------------------------------------------------------------------- /mongodb/typings/interfaces/TransferringOptions.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Transferring options. 3 | */ 4 | interface TransferringOptions { 5 | 6 | /** 7 | * Amount of money to send. 8 | */ 9 | amount: number 10 | 11 | /** 12 | * A member ID who will send the money. 13 | */ 14 | senderMemberID: string 15 | 16 | /** 17 | * A member ID who will receive the money. 18 | */ 19 | receiverMemberID: string 20 | 21 | 22 | /** 23 | * The reason of subtracting the money from sender. (example: "sending money to {user}") 24 | */ 25 | sendingReason?: string 26 | 27 | /** 28 | * The reason of subtracting the money from sender. (example: "receiving money from {user}") 29 | */ 30 | receivingReason?: string 31 | } 32 | 33 | export = TransferringOptions -------------------------------------------------------------------------------- /typings/interfaces/ShopOperationInfo.d.ts: -------------------------------------------------------------------------------- 1 | import Currency from '../classes/Currency' 2 | import ShopItem from '../classes/ShopItem' 3 | 4 | import Maybe from './Maybe' 5 | 6 | 7 | interface ShopOperationInfo { 8 | 9 | /** 10 | * Operation status. 11 | */ 12 | status: boolean 13 | 14 | /** 15 | * Operation message. 16 | */ 17 | message: string 18 | 19 | /** 20 | * Item object. 21 | */ 22 | item: ShopItem 23 | 24 | /** 25 | * Item quantity. 26 | */ 27 | quantity?: number 28 | 29 | /** 30 | * Total price of the items. 31 | */ 32 | totalPrice: number 33 | 34 | /** 35 | * The object of the currency that was used in this operation. 36 | */ 37 | currencyUsed: Maybe 38 | } 39 | 40 | export = ShopOperationInfo 41 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/ShopOperationInfo.d.ts: -------------------------------------------------------------------------------- 1 | import Currency from '../classes/Currency' 2 | import ShopItem from '../classes/ShopItem' 3 | 4 | import Maybe from './Maybe' 5 | 6 | 7 | interface ShopOperationInfo { 8 | 9 | /** 10 | * Operation status. 11 | */ 12 | status: boolean 13 | 14 | /** 15 | * Operation message. 16 | */ 17 | message: string 18 | 19 | /** 20 | * Item object. 21 | */ 22 | item: ShopItem 23 | 24 | /** 25 | * Item quantity. 26 | */ 27 | quantity?: number 28 | 29 | /** 30 | * Total price of the items. 31 | */ 32 | totalPrice: number 33 | 34 | /** 35 | * The object of the currency that was used in this operation. 36 | */ 37 | currencyUsed: Maybe 38 | } 39 | 40 | export = ShopOperationInfo 41 | -------------------------------------------------------------------------------- /typings/interfaces/PayingOptions.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Paying options. 3 | */ 4 | interface PayingOptions { 5 | /** 6 | * Amount of money to send. 7 | */ 8 | amount: number 9 | 10 | /** 11 | * A member ID who will send the money. 12 | */ 13 | senderMemberID: string 14 | 15 | /** 16 | * A member ID who will receive the money. 17 | */ 18 | recipientMemberID: string 19 | 20 | 21 | /** 22 | * The reason of subtracting the money from sender. (example: "sending money to {'user}") 23 | */ 24 | sendingReason?: string | 'sending money to user' 25 | 26 | /** 27 | * The reason of subtracting the money from sender. (example: "receiving money from {user}") 28 | */ 29 | receivingReason?: string | 'receiving money from user' 30 | } 31 | 32 | export = PayingOptions -------------------------------------------------------------------------------- /src/classes/EmptyEconomyGuild.js: -------------------------------------------------------------------------------- 1 | const EconomyGuild = require('./EconomyGuild') 2 | 3 | /** 4 | * Empty economy guild class. 5 | * @extends {EconomyGuild} 6 | */ 7 | class EmptyEconomyGuild extends EconomyGuild { 8 | 9 | /** 10 | * Economy guild class. 11 | * @param {string} guildID Guild ID. 12 | * @param {EconomyConfiguration} options Economy configuration. 13 | * @param {DatabaseManager} database Database manager. 14 | */ 15 | constructor(guildID, options, database) { 16 | super(guildID, options, {}, database) 17 | 18 | /** 19 | * Determine if the guild exists in the database. 20 | * @type {boolean} 21 | */ 22 | this.exists = false 23 | } 24 | } 25 | 26 | /** 27 | * Empty economy guild class. 28 | * @type {EmptyEconomyGuild} 29 | */ 30 | module.exports = EmptyEconomyGuild 31 | -------------------------------------------------------------------------------- /typings/interfaces/BalanceData.d.ts: -------------------------------------------------------------------------------- 1 | import BalanceOperation from './BalanceOperation' 2 | import BalanceOperations from './BalanceOperations' 3 | 4 | /** 5 | * Balance info object for balance events. 6 | */ 7 | declare interface BalanceData { 8 | 9 | /** 10 | * Type of operation. 11 | */ 12 | type: BalanceOperation; 13 | 14 | /** 15 | * Guild ID. 16 | */ 17 | guildID: string; 18 | 19 | /** 20 | * User ID. 21 | */ 22 | memberID: string; 23 | 24 | /** 25 | * Amount of money. 26 | */ 27 | amount: number; 28 | 29 | /** 30 | * User's balance after the operation was completed successfully. 31 | */ 32 | balance: number; 33 | 34 | /** 35 | * The reason why the operation was completed. 36 | */ 37 | reason: string; 38 | } 39 | 40 | export = BalanceData -------------------------------------------------------------------------------- /mongodb/typings/interfaces/BalanceData.d.ts: -------------------------------------------------------------------------------- 1 | import BalanceOperation from './BalanceOperation' 2 | import BalanceOperations from './BalanceOperations' 3 | 4 | /** 5 | * Balance info object for balance events. 6 | */ 7 | declare interface BalanceData { 8 | 9 | /** 10 | * Type of operation. 11 | */ 12 | type: BalanceOperation; 13 | 14 | /** 15 | * Guild ID. 16 | */ 17 | guildID: string; 18 | 19 | /** 20 | * User ID. 21 | */ 22 | memberID: string; 23 | 24 | /** 25 | * Amount of money. 26 | */ 27 | amount: number; 28 | 29 | /** 30 | * User's balance after the operation was completed successfully. 31 | */ 32 | balance: number; 33 | 34 | /** 35 | * The reason why the operation was completed. 36 | */ 37 | reason: string; 38 | } 39 | 40 | export = BalanceData -------------------------------------------------------------------------------- /typings/classes/guild/Leaderboards.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../../interfaces/EconomyConfiguration' 2 | import LeaderboardData from '../../interfaces/LeaderboardData' 3 | 4 | 5 | declare class Leaderboards { 6 | 7 | /** 8 | * Guild leaderboards class. 9 | * @param {string} guildID Guild ID. 10 | * @param {EconomyConfiguration} options Economy configuration. 11 | */ 12 | public constructor(guildID: string, options: EconomyConfiguration) 13 | 14 | /** 15 | * Gets a money leaderboard for the guild. 16 | * @returns {LeaderboardData[]} Balance leaderboard array. 17 | */ 18 | public money(): LeaderboardData[] 19 | 20 | /** 21 | * Gets a bank balance leaderboard for the guild. 22 | * @returns {LeaderboardData[]} Bank balance leaderboard array. 23 | */ 24 | public bank(): LeaderboardData[] 25 | } 26 | 27 | export = Leaderboards -------------------------------------------------------------------------------- /mongodb/typings/classes/EmptyEconomyGuild.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 2 | 3 | import DatabaseManager from '../managers/DatabaseManager' 4 | import CacheManager from '../managers/CacheManager' 5 | 6 | import EconomyGuild from './EconomyGuild' 7 | 8 | 9 | /** 10 | * Empty economy guild class. 11 | */ 12 | declare class EmptyEconomyGuild extends EconomyGuild { 13 | 14 | /** 15 | * Economy guild class. 16 | * @param {string} guildID Guild ID. 17 | * @param {EconomyConfiguration} options Economy configuration. 18 | * @param {DatabaseManager} database Database manager. 19 | * @param {CacheManager} cache Cache manager. 20 | */ 21 | public constructor( 22 | guildID: string, 23 | options: EconomyConfiguration, 24 | database: DatabaseManager, 25 | cache: CacheManager 26 | ) 27 | } 28 | 29 | export = EmptyEconomyGuild -------------------------------------------------------------------------------- /mongodb/src/classes/EmptyEconomyGuild.js: -------------------------------------------------------------------------------- 1 | const EconomyGuild = require('./EconomyGuild') 2 | 3 | /** 4 | * Empty economy guild class. 5 | * @extends {EconomyGuild} 6 | */ 7 | class EmptyEconomyGuild extends EconomyGuild { 8 | 9 | /** 10 | * Economy guild class. 11 | * @param {string} guildID Guild ID. 12 | * @param {EconomyConfiguration} options Economy configuration. 13 | * @param {DatabaseManager} database Database manager. 14 | * @param {CacheManager} cache Cache manager. 15 | */ 16 | constructor(guildID, options, database, cache) { 17 | super(guildID, options, {}, database, cache) 18 | 19 | /** 20 | * Determine if the guild exists in the database. 21 | * @type {boolean} 22 | */ 23 | this.exists = false 24 | } 25 | } 26 | 27 | /** 28 | * Empty economy guild class. 29 | * @type {EmptyEconomyGuild} 30 | */ 31 | module.exports = EmptyEconomyGuild 32 | -------------------------------------------------------------------------------- /typings/interfaces/RewardObject.d.ts: -------------------------------------------------------------------------------- 1 | import If from './If' 2 | 3 | import RewardCooldownData from './RewardCooldownData' 4 | import { Reward, RewardType } from '../interfaces/RewardTypes' 5 | 6 | 7 | /** 8 | * Reward object. 9 | */ 10 | declare interface RewardObject { 11 | 12 | /** 13 | * Type of the reward. 14 | */ 15 | type: Reward 16 | 17 | /** 18 | * Whether the reward was claimed. 19 | */ 20 | claimed: boolean 21 | 22 | /** 23 | * Cooldown object. 24 | */ 25 | cooldown: RewardCooldownData 26 | 27 | /** 28 | * Amount of money that the user received. 29 | */ 30 | reward: number 31 | 32 | /** 33 | * Reward that was specified in a module configuration. 34 | */ 35 | defaultReward: If 36 | } 37 | 38 | export = RewardObject 39 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/RewardObject.d.ts: -------------------------------------------------------------------------------- 1 | import If from './If' 2 | 3 | import RewardCooldownData from './RewardCooldownData' 4 | import { Reward, RewardType } from '../interfaces/RewardTypes' 5 | 6 | 7 | /** 8 | * Reward object. 9 | */ 10 | declare interface RewardObject { 11 | 12 | /** 13 | * Type of the reward. 14 | */ 15 | type: Reward 16 | 17 | /** 18 | * Whether the reward was claimed. 19 | */ 20 | claimed: boolean 21 | 22 | /** 23 | * Cooldown object. 24 | */ 25 | cooldown: RewardCooldownData 26 | 27 | /** 28 | * Amount of money that the user received. 29 | */ 30 | reward: number 31 | 32 | /** 33 | * Reward that was specified in a module configuration. 34 | */ 35 | defaultReward: If 36 | } 37 | 38 | export = RewardObject 39 | -------------------------------------------------------------------------------- /src/structures/timeParser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Parses the millisecond number and returns the time object with days, hours, minutes, seconds and milliseconds. 3 | * @param {number} ms The milliseconds number. 4 | * @returns {TimeData} Time object. 5 | */ 6 | const parse = ms => ({ 7 | days: Math.floor(ms / 86400000), 8 | hours: Math.floor(ms / 3600000 % 24), 9 | minutes: Math.floor(ms / 60000 % 60), 10 | seconds: Math.floor(ms / 1000 % 60), 11 | milliseconds: Math.floor(ms % 1000) 12 | }) 13 | 14 | module.exports = parse 15 | 16 | 17 | /** 18 | * @typedef {object} TimeData 19 | * @property {number} days Amount of days until the cooldown ends. 20 | * @property {number} hours Amount of hours until the cooldown ends. 21 | * @property {number} minutes Amount of minutes until the cooldown ends. 22 | * @property {number} seconds Amount of seconds until the cooldown ends. 23 | * @property {number} milliseconds Amount of milliseconds until the cooldown ends. 24 | */ 25 | -------------------------------------------------------------------------------- /typings/classes/util/Emitter.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyEvents from '../../interfaces/EconomyEvents' 2 | 3 | /** 4 | * Economy event emitter with only important emitter methods. 5 | */ 6 | declare class Emitter { 7 | 8 | /** 9 | * Listens to the event. 10 | * @param event Event name 11 | * @param listener Callback function 12 | */ 13 | on(event: T, listener: (...args: EconomyEvents[T][]) => any): Emitter 14 | 15 | /** 16 | * Listens to the event only once. 17 | * @param event Event name 18 | * @param listener Callback function 19 | */ 20 | once(event: T, listener: (...args: EconomyEvents[T][]) => any): Emitter 21 | 22 | /** 23 | * Emits the event. 24 | * @param event Event name 25 | * @param args Args to send in the event. 26 | */ 27 | emit(event: T, ...args: EconomyEvents[T][]): boolean 28 | } 29 | 30 | export = Emitter -------------------------------------------------------------------------------- /mongodb/typings/classes/EmptyEconomyUser.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 2 | 3 | import DatabaseManager from '../managers/DatabaseManager' 4 | import CacheManager from '../managers/CacheManager' 5 | 6 | import EconomyUser from './EconomyUser' 7 | 8 | 9 | /** 10 | * Empty economy user class. 11 | */ 12 | declare class EmptyEconomyUser extends EconomyUser { 13 | 14 | /** 15 | * Economy user class. 16 | * @param {string} userID User ID. 17 | * @param {string} guildID Guild ID. 18 | * @param {EconomyConfiguration} options Economy configuration. 19 | * @param {DatabaseManager} database Database Manager. 20 | * @param {CacheManager} cache Cache manager. 21 | */ 22 | public constructor( 23 | userID: string, 24 | guildID: string, 25 | options: EconomyConfiguration, 26 | database: DatabaseManager, 27 | cache: CacheManager 28 | ) 29 | } 30 | 31 | export = EmptyEconomyUser -------------------------------------------------------------------------------- /mongodb/typings/classes/util/Emitter.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyEvents from '../../interfaces/EconomyEvents' 2 | 3 | /** 4 | * Economy event emitter with only important emitter methods. 5 | */ 6 | declare class Emitter { 7 | 8 | /** 9 | * Listens to the event. 10 | * @param event Event name 11 | * @param listener Callback function 12 | */ 13 | on(event: T, listener: (...args: EconomyEvents[T][]) => any): Emitter 14 | 15 | /** 16 | * Listens to the event only once. 17 | * @param event Event name 18 | * @param listener Callback function 19 | */ 20 | once(event: T, listener: (...args: EconomyEvents[T][]) => any): Emitter 21 | 22 | /** 23 | * Emits the event. 24 | * @param event Event name 25 | * @param args Args to send in the event. 26 | */ 27 | emit(event: T, ...args: EconomyEvents[T][]): boolean 28 | } 29 | 30 | export = Emitter -------------------------------------------------------------------------------- /mongodb/src/structures/timeParser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Parses the millisecond number and returns the time object with days, hours, minutes, seconds and milliseconds. 3 | * @param {number} ms Milliseconds number to convert. 4 | * @returns {TimeData} Time object. 5 | */ 6 | const parse = ms => ({ 7 | days: Math.floor(ms / 86400000), 8 | hours: Math.floor(ms / 3600000 % 24), 9 | minutes: Math.floor(ms / 60000 % 60), 10 | seconds: Math.floor(ms / 1000 % 60), 11 | milliseconds: Math.floor(ms % 1000) 12 | }) 13 | 14 | module.exports = parse 15 | 16 | 17 | /** 18 | * @typedef {object} TimeData 19 | * @property {number} days Amount of days until the cooldown ends. 20 | * @property {number} hours Amount of hours until the cooldown ends. 21 | * @property {number} minutes Amount of minutes until the cooldown ends. 22 | * @property {number} seconds Amount of seconds until the cooldown ends. 23 | * @property {number} milliseconds Amount of milliseconds until the cooldown ends. 24 | */ 25 | -------------------------------------------------------------------------------- /src/classes/EmptyEconomyUser.js: -------------------------------------------------------------------------------- 1 | const defaultUserSchema = require('../structures/DefaultUserSchema') 2 | const EconomyUser = require('./EconomyUser') 3 | 4 | /** 5 | * Empty economy user class. 6 | * @extends {EconomyUser} 7 | */ 8 | class EmptyEconomyUser extends EconomyUser { 9 | 10 | /** 11 | * Economy user class. 12 | * @param {string} userID User ID. 13 | * @param {string} guildID Guild ID. 14 | * @param {EconomyConfiguration} options Economy configuration. 15 | * @param {DatabaseManager} database Database Manager. 16 | */ 17 | constructor(userID, guildID, options, database) { 18 | super(userID, guildID, options, defaultUserSchema, database) 19 | 20 | /** 21 | * Determine if the user exists in the database. 22 | * @type {boolean} 23 | */ 24 | this.exists = false 25 | } 26 | } 27 | 28 | /** 29 | * Empty economy user class. 30 | * @type {EmptyEconomyUser} 31 | */ 32 | module.exports = EmptyEconomyUser 33 | -------------------------------------------------------------------------------- /mongodb/typings/classes/guild/Leaderboards.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../../interfaces/EconomyConfiguration' 2 | import LeaderboardData from '../../interfaces/LeaderboardData' 3 | import DatabaseManager from '../../managers/DatabaseManager' 4 | 5 | 6 | declare class Leaderboards { 7 | 8 | /** 9 | * Guild leaderboards class. 10 | * @param {string} guildID Guild ID. 11 | * @param {EconomyConfiguration} options Economy configuration. 12 | */ 13 | public constructor(guildID: string, options: EconomyConfiguration, database: DatabaseManager) 14 | 15 | /** 16 | * Gets a money leaderboard for the guild. 17 | * @returns {LeaderboardData[]} Balance leaderboard array. 18 | */ 19 | public money(): Promise 20 | 21 | /** 22 | * Gets a bank balance leaderboard for the guild. 23 | * @returns {LeaderboardData[]} Bank balance leaderboard array. 24 | */ 25 | public bank(): Promise 26 | } 27 | 28 | export = Leaderboards -------------------------------------------------------------------------------- /typings/interfaces/AddItemOptions.d.ts: -------------------------------------------------------------------------------- 1 | import CustomItemData from "./CustomItemData" 2 | 3 | /** 4 | * Options of 'ShopManager.addItem()' method. 5 | */ 6 | declare interface AddItemOptions { 7 | 8 | /** 9 | * Item name. 10 | */ 11 | name: string 12 | 13 | /** 14 | * Item price. 15 | */ 16 | price: number 17 | 18 | /** 19 | * The message that will be returned on item use. 20 | */ 21 | message?: string 22 | 23 | /** 24 | * Item description. 25 | */ 26 | description?: string 27 | 28 | /** 29 | * Max amount of the item that user can hold in their inventory. 30 | */ 31 | maxAmount?: string 32 | 33 | /** 34 | * Discord Role ID from your server that will be given to user. 35 | * Requires to specify your bot client in 'Economy.shop.useItem' method. 36 | */ 37 | role?: string 38 | 39 | /** 40 | * Custom item data object. 41 | */ 42 | custom?: CustomItemData 43 | } 44 | 45 | export = AddItemOptions -------------------------------------------------------------------------------- /mongodb/typings/interfaces/AddItemOptions.d.ts: -------------------------------------------------------------------------------- 1 | import CustomItemData from "./CustomItemData" 2 | 3 | /** 4 | * Options of 'ShopManager.addItem()' method. 5 | */ 6 | declare interface AddItemOptions { 7 | 8 | /** 9 | * Item name. 10 | */ 11 | name: string 12 | 13 | /** 14 | * Item price. 15 | */ 16 | price: number 17 | 18 | /** 19 | * The message that will be returned on item use. 20 | */ 21 | message?: string 22 | 23 | /** 24 | * Item description. 25 | */ 26 | description?: string 27 | 28 | /** 29 | * Max amount of the item that user can hold in their inventory. 30 | */ 31 | maxAmount?: string 32 | 33 | /** 34 | * Discord Role ID from your server that will be given to user. 35 | * Requires to specify your bot client in 'Economy.shop.useItem' method. 36 | */ 37 | role?: string 38 | 39 | /** 40 | * Custom item data object. 41 | */ 42 | custom?: CustomItemData 43 | } 44 | 45 | export = AddItemOptions -------------------------------------------------------------------------------- /typings/interfaces/RawEconomyUser.d.ts: -------------------------------------------------------------------------------- 1 | import HistoryData from './HistoryData' 2 | import InventoryData from './InventoryData' 3 | 4 | declare interface RawEconomyUser { 5 | 6 | /** 7 | * User's daily cooldown. 8 | */ 9 | dailyCooldown: number 10 | 11 | /** 12 | * User's work cooldown. 13 | */ 14 | workCooldown: number 15 | 16 | /** 17 | * User's weekly cooldown. 18 | */ 19 | weeklyCooldown: number 20 | 21 | /** 22 | * User's monthly cooldown. 23 | */ 24 | monthlyCooldown: number 25 | 26 | /** 27 | * User's hourly cooldown. 28 | */ 29 | hourlyCooldown: number 30 | 31 | /** 32 | * User's balance. 33 | */ 34 | money: number 35 | 36 | /** 37 | * User's bank balance. 38 | */ 39 | bank: number 40 | 41 | /** 42 | * User's inventory. 43 | */ 44 | inventory: InventoryData[] 45 | 46 | /** 47 | * User's purchases history. 48 | */ 49 | history: HistoryData[] 50 | } 51 | 52 | export = RawEconomyUser 53 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/RawEconomyUser.d.ts: -------------------------------------------------------------------------------- 1 | import HistoryData from './HistoryData' 2 | import InventoryData from './InventoryData' 3 | 4 | declare interface RawEconomyUser { 5 | 6 | /** 7 | * User's daily cooldown. 8 | */ 9 | dailyCooldown: number 10 | 11 | /** 12 | * User's work cooldown. 13 | */ 14 | workCooldown: number 15 | 16 | /** 17 | * User's weekly cooldown. 18 | */ 19 | weeklyCooldown: number 20 | 21 | /** 22 | * User's monthly cooldown. 23 | */ 24 | monthlyCooldown: number 25 | 26 | /** 27 | * User's hourly cooldown. 28 | */ 29 | hourlyCooldown: number 30 | 31 | /** 32 | * User's balance. 33 | */ 34 | money: number 35 | 36 | /** 37 | * User's bank balance. 38 | */ 39 | bank: number 40 | 41 | /** 42 | * User's inventory. 43 | */ 44 | inventory: InventoryData[] 45 | 46 | /** 47 | * User's purchases history. 48 | */ 49 | history: HistoryData[] 50 | } 51 | 52 | export = RawEconomyUser 53 | -------------------------------------------------------------------------------- /mongodb/src/classes/EmptyEconomyUser.js: -------------------------------------------------------------------------------- 1 | const defaultUserSchema = require('../structures/DefaultUserSchema') 2 | const EconomyUser = require('./EconomyUser') 3 | 4 | /** 5 | * Empty economy user class. 6 | * @extends {EconomyUser} 7 | */ 8 | class EmptyEconomyUser extends EconomyUser { 9 | 10 | /** 11 | * Economy user class. 12 | * @param {string} userID User ID. 13 | * @param {string} guildID Guild ID. 14 | * @param {EconomyConfiguration} options Economy configuration. 15 | * @param {DatabaseManager} database Database Manager. 16 | * @param {CacheManager} cache Cache manager. 17 | */ 18 | constructor(userID, guildID, options, database, cache) { 19 | super(userID, guildID, options, defaultUserSchema, database, cache) 20 | 21 | /** 22 | * Determine if the user exists in the database. 23 | * @type {boolean} 24 | */ 25 | this.exists = false 26 | } 27 | } 28 | 29 | /** 30 | * Empty economy user class. 31 | * @type {EmptyEconomyUser} 32 | */ 33 | module.exports = EmptyEconomyUser 34 | -------------------------------------------------------------------------------- /typings/interfaces/InventoryData.d.ts: -------------------------------------------------------------------------------- 1 | import CustomItemData from './CustomItemData' 2 | 3 | /** 4 | * Inventory object. 5 | */ 6 | declare interface InventoryData { 7 | 8 | /** 9 | * Item ID. 10 | */ 11 | id: number 12 | 13 | /** 14 | * Item name. 15 | */ 16 | name: string 17 | 18 | /** 19 | * Item price. 20 | */ 21 | price: number 22 | 23 | /** 24 | * The message that will be returned on item use. 25 | */ 26 | message?: string 27 | 28 | /** 29 | * Max amount of the item that user can hold in their inventory. 30 | */ 31 | maxAmount?: number 32 | 33 | /** 34 | * Role ID from your Discord server that will be given to user on item use. Requires to specify your bot client in all `use` and `useItem` methods. 35 | */ 36 | role?: string 37 | 38 | /** 39 | * Date and time when the user bought the item. 40 | */ 41 | date: string 42 | 43 | /** 44 | * Custom item data object. 45 | */ 46 | custom?: CustomItemData 47 | } 48 | 49 | export = InventoryData -------------------------------------------------------------------------------- /mongodb/typings/interfaces/InventoryData.d.ts: -------------------------------------------------------------------------------- 1 | import CustomItemData from './CustomItemData' 2 | 3 | /** 4 | * Inventory object. 5 | */ 6 | declare interface InventoryData { 7 | 8 | /** 9 | * Item ID. 10 | */ 11 | id: number 12 | 13 | /** 14 | * Item name. 15 | */ 16 | name: string 17 | 18 | /** 19 | * Item price. 20 | */ 21 | price: number 22 | 23 | /** 24 | * The message that will be returned on item use. 25 | */ 26 | message?: string 27 | 28 | /** 29 | * Max amount of the item that user can hold in their inventory. 30 | */ 31 | maxAmount?: number 32 | 33 | /** 34 | * Role ID from your Discord server that will be given to user on item use. Requires to specify your bot client in all `use` and `useItem` methods. 35 | */ 36 | role?: string 37 | 38 | /** 39 | * Date and time when the user bought the item. 40 | */ 41 | date: string 42 | 43 | /** 44 | * Custom item data object. 45 | */ 46 | custom?: CustomItemData 47 | } 48 | 49 | export = InventoryData -------------------------------------------------------------------------------- /typings/interfaces/TransferingResult.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Transfering options. 3 | */ 4 | interface TransferingResult { 5 | 6 | /** 7 | * Operation status. 8 | */ 9 | success: boolean, 10 | 11 | /** 12 | * Guild ID. 13 | */ 14 | guildID: string, 15 | 16 | /** 17 | * New sender balance. 18 | */ 19 | senderBalance: number, 20 | 21 | /** 22 | * New receiver balance. 23 | */ 24 | receiverBalance: number, 25 | 26 | /** 27 | * Amount of money that was sent. 28 | */ 29 | amount: number, 30 | 31 | /** 32 | * Sender member ID. 33 | */ 34 | senderMemberID: string, 35 | 36 | /** 37 | * Receiver member ID. 38 | */ 39 | receiverMemberID: string, 40 | 41 | /** 42 | * The reason of subtracting the money from sender. (example: "sending money to {user}") 43 | */ 44 | sendingReason: string, 45 | 46 | /** 47 | * The reason of adding the money to receiver. (example: "receiving money from {user}") 48 | */ 49 | receivingReason: string, 50 | } 51 | 52 | export = TransferingResult -------------------------------------------------------------------------------- /mongodb/typings/interfaces/TransferingResult.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Transfering options. 3 | */ 4 | interface TransferingResult { 5 | 6 | /** 7 | * Operation status. 8 | */ 9 | success: boolean, 10 | 11 | /** 12 | * Guild ID. 13 | */ 14 | guildID: string, 15 | 16 | /** 17 | * New sender balance. 18 | */ 19 | senderBalance: number, 20 | 21 | /** 22 | * New receiver balance. 23 | */ 24 | receiverBalance: number, 25 | 26 | /** 27 | * Amount of money that was sent. 28 | */ 29 | amount: number, 30 | 31 | /** 32 | * Sender member ID. 33 | */ 34 | senderMemberID: string, 35 | 36 | /** 37 | * Receiver member ID. 38 | */ 39 | receiverMemberID: string, 40 | 41 | /** 42 | * The reason of subtracting the money from sender. (example: "sending money to {user}") 43 | */ 44 | sendingReason: string, 45 | 46 | /** 47 | * The reason of adding the money to receiver. (example: "receiving money from {user}") 48 | */ 49 | receivingReason: string, 50 | } 51 | 52 | export = TransferingResult -------------------------------------------------------------------------------- /mongodb/src/classes/BankBalanceItem.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Bank balance item class. 3 | */ 4 | class BankBalanceItem { 5 | 6 | /** 7 | * User bank balance class. 8 | * @param {string} memberID Member ID. 9 | * @param {string} guildID Guild ID. 10 | * @param {EconomyConfiguration} ecoOptions Economy configuration. 11 | * @param {BankBalanceObject} bankBalanceObject User bank balance object. 12 | */ 13 | constructor(guildID, memberID, ecoOptions, bankBalanceObject) { 14 | 15 | /** 16 | * Member ID. 17 | * @type {string} 18 | */ 19 | this.memberID = memberID 20 | 21 | /** 22 | * Guild ID. 23 | * @type {string} 24 | */ 25 | this.guildID = guildID 26 | 27 | /** 28 | * User bank balance object. 29 | * @type {number} 30 | */ 31 | this.balance = bankBalanceObject.balance || 0 32 | } 33 | } 34 | 35 | 36 | /** 37 | * Bank balance object. 38 | * @typedef {object} BankBalanceObject 39 | * @property {number} balance User's bank balance. 40 | */ 41 | 42 | module.exports = BankBalanceItem 43 | -------------------------------------------------------------------------------- /typings/interfaces/ItemData.d.ts: -------------------------------------------------------------------------------- 1 | import CustomItemData from './CustomItemData' 2 | 3 | /** 4 | * Item info object for item events. 5 | */ 6 | declare interface ItemData { 7 | 8 | /** 9 | * Item ID. 10 | */ 11 | id: number 12 | 13 | /** 14 | * Item name. 15 | */ 16 | name: string 17 | 18 | /** 19 | * Item price. 20 | */ 21 | price: number 22 | 23 | /** 24 | * Item message that will be returned on item use. 25 | */ 26 | message: string 27 | 28 | /** 29 | * Item description. 30 | */ 31 | description: string 32 | 33 | /** 34 | * Max amount of the item that user can hold in their inventory. 35 | */ 36 | maxAmount: number 37 | 38 | /** 39 | * Role **ID** from your Discord server that will be adding to the member on item use. 40 | */ 41 | role: string 42 | 43 | /** 44 | * Formatted date when the item was added to the shop. 45 | */ 46 | date: string 47 | 48 | /** 49 | * Custom item data object. 50 | */ 51 | custom: CustomItemData 52 | } 53 | 54 | export = ItemData -------------------------------------------------------------------------------- /mongodb/typings/interfaces/ItemData.d.ts: -------------------------------------------------------------------------------- 1 | import CustomItemData from './CustomItemData' 2 | 3 | /** 4 | * Item info object for item events. 5 | */ 6 | declare interface ItemData { 7 | 8 | /** 9 | * Item ID. 10 | */ 11 | id: number 12 | 13 | /** 14 | * Item name. 15 | */ 16 | name: string 17 | 18 | /** 19 | * Item price. 20 | */ 21 | price: number 22 | 23 | /** 24 | * Item message that will be returned on item use. 25 | */ 26 | message: string 27 | 28 | /** 29 | * Item description. 30 | */ 31 | description: string 32 | 33 | /** 34 | * Max amount of the item that user can hold in their inventory. 35 | */ 36 | maxAmount: number 37 | 38 | /** 39 | * Role **ID** from your Discord server that will be adding to the member on item use. 40 | */ 41 | role: string 42 | 43 | /** 44 | * Formatted date when the item was added to the shop. 45 | */ 46 | date: string 47 | 48 | /** 49 | * Custom item data object. 50 | */ 51 | custom: CustomItemData 52 | } 53 | 54 | export = ItemData -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 ShadowPlay 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /typings/interfaces/CheckerConfiguration.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Configuration for an 'Economy.utils.checkConfiguration' method. 3 | */ 4 | declare interface CheckerConfiguration { 5 | 6 | /** 7 | * Allows the method to ignore the options with invalid types. Default: false. 8 | */ 9 | ignoreInvalidTypes?: boolean 10 | 11 | /** 12 | * Allows the method to ignore the unspecified options. Default: true. 13 | */ 14 | ignoreUnspecifiedOptions?: boolean 15 | 16 | /** 17 | * Allows the method to ignore the unexisting options. Default: false. 18 | */ 19 | ignoreInvalidOptions?: boolean 20 | 21 | /** 22 | * Allows the method to show all the problems in the console. Default: true. 23 | */ 24 | showProblems?: boolean 25 | 26 | /** 27 | * Allows the method to send the result in the console. 28 | * Requires the 'showProblems' or 'sendLog' options to set. Default: true. 29 | */ 30 | sendLog?: boolean 31 | 32 | /** 33 | * Allows the method to send the result if no problems were found. Default: false 34 | */ 35 | sendSuccessLog?: boolean 36 | } 37 | 38 | export = CheckerConfiguration 39 | -------------------------------------------------------------------------------- /typings/interfaces/TransferringResult.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Transferring options. 3 | */ 4 | interface TransferringResult { 5 | 6 | /** 7 | * Operation status. 8 | */ 9 | success: boolean, 10 | 11 | /** 12 | * Guild ID. 13 | */ 14 | guildID: string, 15 | 16 | /** 17 | * New sender balance. 18 | */ 19 | senderBalance: number, 20 | 21 | /** 22 | * New receiver balance. 23 | */ 24 | receiverBalance: number, 25 | 26 | /** 27 | * Amount of money that was sent. 28 | */ 29 | amount: number, 30 | 31 | /** 32 | * Sender member ID. 33 | */ 34 | senderMemberID: string, 35 | 36 | /** 37 | * Receiver member ID. 38 | */ 39 | receiverMemberID: string, 40 | 41 | /** 42 | * The reason of subtracting the money from sender. (example: "sending money to {user}") 43 | */ 44 | sendingReason: string, 45 | 46 | /** 47 | * The reason of adding the money to receiver. (example: "receiving money from {user}") 48 | */ 49 | receivingReason: string, 50 | } 51 | 52 | export = TransferringResult -------------------------------------------------------------------------------- /mongodb/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 ShadowPlay 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/TransferringResult.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Transferring options. 3 | */ 4 | interface TransferringResult { 5 | 6 | /** 7 | * Operation status. 8 | */ 9 | success: boolean, 10 | 11 | /** 12 | * Guild ID. 13 | */ 14 | guildID: string, 15 | 16 | /** 17 | * New sender balance. 18 | */ 19 | senderBalance: number, 20 | 21 | /** 22 | * New receiver balance. 23 | */ 24 | receiverBalance: number, 25 | 26 | /** 27 | * Amount of money that was sent. 28 | */ 29 | amount: number, 30 | 31 | /** 32 | * Sender member ID. 33 | */ 34 | senderMemberID: string, 35 | 36 | /** 37 | * Receiver member ID. 38 | */ 39 | receiverMemberID: string, 40 | 41 | /** 42 | * The reason of subtracting the money from sender. (example: "sending money to {user}") 43 | */ 44 | sendingReason: string, 45 | 46 | /** 47 | * The reason of adding the money to receiver. (example: "receiving money from {user}") 48 | */ 49 | receivingReason: string, 50 | } 51 | 52 | export = TransferringResult -------------------------------------------------------------------------------- /mongodb/typings/interfaces/CheckerConfiguration.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Configuration for an 'Economy.utils.checkConfiguration' method. 3 | */ 4 | declare interface CheckerConfiguration { 5 | 6 | /** 7 | * Allows the method to ignore the options with invalid types. Default: false. 8 | */ 9 | ignoreInvalidTypes?: boolean 10 | 11 | /** 12 | * Allows the method to ignore the unspecified options. Default: true. 13 | */ 14 | ignoreUnspecifiedOptions?: boolean 15 | 16 | /** 17 | * Allows the method to ignore the unexisting options. Default: false. 18 | */ 19 | ignoreInvalidOptions?: boolean 20 | 21 | /** 22 | * Allows the method to show all the problems in the console. Default: true. 23 | */ 24 | showProblems?: boolean 25 | 26 | /** 27 | * Allows the method to send the result in the console. 28 | * Requires the 'showProblems' or 'sendLog' options to set. Default: true. 29 | */ 30 | sendLog?: boolean 31 | 32 | /** 33 | * Allows the method to send the result if no problems were found. Default: false 34 | */ 35 | sendSuccessLog?: boolean 36 | } 37 | 38 | export = CheckerConfiguration 39 | -------------------------------------------------------------------------------- /typings/interfaces/CheckerOptions.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Configuration for an 'Economy.utils.checkOptions' method. 3 | */ 4 | declare interface CheckerOptions { 5 | 6 | /** 7 | * Allows the method to ignore the options with invalid types. Default: false. 8 | */ 9 | ignoreInvalidTypes?: boolean 10 | 11 | /** 12 | * Allows the method to ignore the unspecified options. Default: true. 13 | */ 14 | ignoreUnspecifiedOptions?: boolean 15 | 16 | /** 17 | * Allows the method to ignore the unexisting options. Default: false. 18 | */ 19 | ignoreInvalidOptions?: boolean 20 | 21 | /** 22 | * Allows the method to show all the problems in the console. Default: true. 23 | */ 24 | showProblems?: boolean 25 | 26 | /** 27 | * Allows the method to send the result in the console. 28 | * Requires the 'showProblems' or 'sendLog' options to set. Default: true. 29 | */ 30 | sendLog?: boolean 31 | 32 | /** 33 | * Allows the method to send the result if no problems were found. Default: false 34 | */ 35 | sendSuccessLog?: boolean 36 | } 37 | 38 | export = CheckerOptions 39 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/CheckerOptions.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Configuration for an 'Economy.utils.checkOptions' method. 3 | */ 4 | declare interface CheckerOptions { 5 | 6 | /** 7 | * Allows the method to ignore the options with invalid types. Default: false. 8 | */ 9 | ignoreInvalidTypes?: boolean 10 | 11 | /** 12 | * Allows the method to ignore the unspecified options. Default: true. 13 | */ 14 | ignoreUnspecifiedOptions?: boolean 15 | 16 | /** 17 | * Allows the method to ignore the unexisting options. Default: false. 18 | */ 19 | ignoreInvalidOptions?: boolean 20 | 21 | /** 22 | * Allows the method to show all the problems in the console. Default: true. 23 | */ 24 | showProblems?: boolean 25 | 26 | /** 27 | * Allows the method to send the result in the console. 28 | * Requires the 'showProblems' or 'sendLog' options to set. Default: true. 29 | */ 30 | sendLog?: boolean 31 | 32 | /** 33 | * Allows the method to send the result if no problems were found. Default: false 34 | */ 35 | sendSuccessLog?: boolean 36 | } 37 | 38 | export = CheckerOptions 39 | -------------------------------------------------------------------------------- /postinstall.js: -------------------------------------------------------------------------------- 1 | try { 2 | const projectPackage = require('../../package.json') 3 | 4 | if (projectPackage['discord-economy-super']?.postinstall !== false) { 5 | console.log() 6 | console.log('\x1b[32m╔══════════════════════════════════════════════════════════════════╗') 7 | console.log('\x1b[32m║ @ discord-economy-super - [] X ║') 8 | console.log('\x1b[32m║══════════════════════════════════════════════════════════════════║') 9 | console.log('\x1b[32m║ \x1b[36mThank you for installing Discord Economy Super! \x1b[32m║') 10 | console.log('\x1b[32m║══════════════════════════════════════════════════════════════════║') 11 | console.log('\x1b[32m║ If you have any questions or need help, join our Support Server: \x1b[32m║') 12 | console.log('\x1b[32m║ \x1b[34mhttps://discord.gg/4pWKq8vUnb \x1b[32m║') 13 | console.log('\x1b[32m╚══════════════════════════════════════════════════════════════════╝\x1b[37m') 14 | console.log() 15 | } 16 | } catch { 17 | // console.log('\x1b[91mFailed to open the project\'s `package.json` file.') 18 | } 19 | -------------------------------------------------------------------------------- /mongodb/src/classes/BalanceItem.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Balance item class. 3 | */ 4 | class BalanceItem { 5 | 6 | /** 7 | * User balance class. 8 | * @param {string} memberID Member ID. 9 | * @param {string} guildID Guild ID. 10 | * @param {EconomyConfiguration} ecoOptions Economy configuration. 11 | * @param {BalanceObject} balanceObject User balance object. 12 | */ 13 | constructor(guildID, memberID, ecoOptions, balanceObject) { 14 | 15 | /** 16 | * Member ID. 17 | * @type {string} 18 | */ 19 | this.memberID = memberID 20 | 21 | /** 22 | * Guild ID. 23 | * @type {string} 24 | */ 25 | this.guildID = guildID 26 | 27 | /** 28 | * User's balance. 29 | * @type {number} 30 | */ 31 | this.money = balanceObject.money || 0 32 | 33 | /** 34 | * User balance object. 35 | * @type {number} 36 | */ 37 | this.bank = balanceObject.bank || 0 38 | } 39 | } 40 | 41 | 42 | /** 43 | * Balance object. 44 | * @typedef {object} BalanceObject 45 | * @property {number} money User's money amount. 46 | * @property {number} bank User's bank balance. 47 | */ 48 | 49 | module.exports = BalanceItem 50 | -------------------------------------------------------------------------------- /mongodb/typings/classes/BankBalanceItem.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 2 | import DatabaseManager from '../managers/DatabaseManager' 3 | 4 | 5 | /** 6 | * User bank balance item class. 7 | */ 8 | declare class BankBalanceItem { 9 | 10 | /** 11 | * User bank balance item class. 12 | * @param {string} memberID Member ID. 13 | * @param {string} guildID Guild ID. 14 | * @param {EconomyConfiguration} ecoOptions Economy configuration. 15 | * @param {BalanceObject} balanceObject User bank balance object. 16 | * @param {DatabaseManager} database Database manager. 17 | */ 18 | public constructor( 19 | guildID: string, 20 | memberID: string, 21 | ecoOptions: EconomyConfiguration, 22 | balanceObject: { 23 | balance: number 24 | }, 25 | database: DatabaseManager 26 | ) 27 | 28 | /** 29 | * Member ID. 30 | * @type {string} 31 | */ 32 | public memberID: string 33 | 34 | /** 35 | * Guild ID. 36 | * @type {string} 37 | */ 38 | public guildID: string 39 | 40 | /** 41 | * User's bank balance. 42 | * @type {number} 43 | */ 44 | public balance: number 45 | } 46 | 47 | export = BankBalanceItem 48 | -------------------------------------------------------------------------------- /src/structures/DefaultConfiguration.js: -------------------------------------------------------------------------------- 1 | const economyConfig = { 2 | storagePath: './storage.json', 3 | 4 | checkStorage: true, 5 | updateCountdown: 1000, 6 | 7 | hourlyAmount: 20, 8 | hourlyCooldown: 3600000, 9 | 10 | dailyAmount: 100, 11 | dailyCooldown: 86400000, 12 | 13 | workAmount: [10, 50], 14 | workCooldown: 3600000, 15 | 16 | weeklyAmount: 1000, 17 | weeklyCooldown: 604800000, 18 | 19 | monthlyAmount: 10000, 20 | monthlyCooldown: 2629746000, 21 | 22 | sellingItemPercent: 75, 23 | 24 | savePurchasesHistory: true, 25 | deprecationWarnings: true, 26 | 27 | dateLocale: 'en', 28 | subtractOnBuy: true, 29 | 30 | updater: { 31 | checkUpdates: true, 32 | upToDateMessage: false 33 | }, 34 | 35 | errorHandler: { 36 | handleErrors: true, 37 | attempts: 5, 38 | time: 5000 39 | }, 40 | 41 | optionsChecker: { 42 | ignoreInvalidTypes: false, 43 | ignoreUnspecifiedOptions: true, 44 | ignoreInvalidOptions: false, 45 | showProblems: true, 46 | sendLog: true, 47 | sendSuccessLog: false 48 | }, 49 | 50 | debug: false 51 | } 52 | 53 | /** 54 | * Default Economy configuration. 55 | * @type {economyConfig} 56 | */ 57 | module.exports = economyConfig 58 | -------------------------------------------------------------------------------- /mongodb/src/structures/DefaultConfiguration.js: -------------------------------------------------------------------------------- 1 | const economyConfig = { 2 | connection: { 3 | connectionURI: '', 4 | collectionName: 'database', 5 | dbName: 'db', 6 | mongoClientProperties: {} 7 | }, 8 | 9 | hourlyAmount: 20, 10 | hourlyCooldown: 3600000, 11 | 12 | dailyAmount: 100, 13 | dailyCooldown: 86400000, 14 | 15 | workAmount: [10, 50], 16 | workCooldown: 3600000, 17 | 18 | weeklyAmount: 1000, 19 | weeklyCooldown: 604800000, 20 | 21 | monthlyAmount: 10000, 22 | monthlyCooldown: 2629746000, 23 | 24 | sellingItemPercent: 75, 25 | savePurchasesHistory: true, 26 | deprecationWarnings: true, 27 | 28 | dateLocale: 'en', 29 | subtractOnBuy: true, 30 | 31 | updater: { 32 | checkUpdates: true, 33 | upToDateMessage: false 34 | }, 35 | 36 | errorHandler: { 37 | handleErrors: true, 38 | attempts: 5, 39 | time: 5000 40 | }, 41 | 42 | optionsChecker: { 43 | ignoreInvalidTypes: false, 44 | ignoreUnspecifiedOptions: true, 45 | ignoreInvalidOptions: false, 46 | showProblems: true, 47 | sendLog: true, 48 | sendSuccessLog: false 49 | }, 50 | 51 | debug: false 52 | } 53 | 54 | /** 55 | * Default Economy configuration. 56 | * @type {economyConfig} 57 | */ 58 | module.exports = economyConfig 59 | -------------------------------------------------------------------------------- /mongodb/typings/classes/BalanceItem.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 2 | import DatabaseManager from '../managers/DatabaseManager' 3 | 4 | 5 | /** 6 | * User balance item class. 7 | */ 8 | declare class BalanceItem { 9 | 10 | /** 11 | * User balance item class. 12 | * @param {string} memberID Member ID. 13 | * @param {string} guildID Guild ID. 14 | * @param {EconomyConfiguration} ecoOptions Economy configuration. 15 | * @param {BalanceObject} balanceObject User balance object. 16 | * @param {DatabaseManager} database Database manager. 17 | */ 18 | public constructor( 19 | guildID: string, 20 | memberID: string, 21 | ecoOptions: EconomyConfiguration, 22 | balanceObject: { 23 | money: number 24 | bank: number 25 | }, 26 | database: DatabaseManager 27 | ) 28 | 29 | /** 30 | * Member ID. 31 | * @type {string} 32 | */ 33 | public memberID: string 34 | 35 | /** 36 | * Guild ID. 37 | * @type {string} 38 | */ 39 | public guildID: string 40 | 41 | 42 | /** 43 | * User's balance. 44 | * @type {number} 45 | */ 46 | public money: number 47 | 48 | /** 49 | * User's bank balance. 50 | * @type {number} 51 | */ 52 | public bank: number 53 | } 54 | 55 | export = BalanceItem 56 | -------------------------------------------------------------------------------- /typings/managers/GuildManager.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 2 | 3 | import BaseManager from './BaseManager' 4 | 5 | import EconomyGuild from '../classes/EconomyGuild' 6 | import EmptyEconomyGuild from '../classes/EmptyEconomyGuild' 7 | 8 | 9 | /** 10 | * Guild Manager. 11 | */ 12 | declare class GuildManager extends BaseManager { 13 | 14 | /** 15 | * Guild Manager. 16 | * @param {EconomyConfiguration} options Economy configuration. 17 | */ 18 | public constructor(options: EconomyConfiguration) 19 | 20 | /** 21 | * Gets the guild by it's ID. 22 | * @param {string} guildID Guild ID. 23 | * @returns {EconomyGuild} User object. 24 | */ 25 | public get(guildID: string): EconomyGuild | EmptyEconomyGuild 26 | 27 | /** 28 | * Creates an economy guild object in database. 29 | * @param {string} guildID The guild ID to set. 30 | * @returns {EconomyGuild} New guild instance. 31 | */ 32 | public create(guildID: string): EconomyGuild 33 | 34 | /** 35 | * Resets the guild in database. 36 | * @param {string} guildID Guild ID. 37 | * @returns {EconomyGuild} New guild instance. 38 | */ 39 | public reset(guildID: string): EconomyGuild 40 | 41 | /** 42 | * Gets the array of ALL guilds in database. 43 | * @returns {EconomyGuild[]} 44 | */ 45 | public all(): EconomyGuild[] 46 | } 47 | 48 | export = GuildManager 49 | -------------------------------------------------------------------------------- /mongodb/typings/classes/CooldownItem.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 2 | import DatabaseManager from '../managers/DatabaseManager' 3 | 4 | 5 | /** 6 | * Cooldown item class. 7 | */ 8 | declare class CooldownItem { 9 | 10 | /** 11 | * User cooldowns class. 12 | * @param {string} memberID Member ID. 13 | * @param {string} guildID Guild ID. 14 | * @param {EconomyConfiguration} ecoOptions Economy configuration. 15 | * @param {CooldownsObject} cooldownsObject User cooldowns object. 16 | * @param {DatabaseManager} database Database manager. 17 | */ 18 | public constructor( 19 | guildID: string, 20 | memberID: string, 21 | ecoOptions: EconomyConfiguration, 22 | cooldownsObject: { 23 | daily: number 24 | work: number 25 | weekly: number 26 | }, 27 | database: DatabaseManager 28 | ) 29 | 30 | /** 31 | * Member ID. 32 | * @type {string} 33 | */ 34 | public memberID: string 35 | 36 | /** 37 | * Guild ID. 38 | * @type {string} 39 | */ 40 | public guildID: string 41 | 42 | 43 | /** 44 | * Daily cooldown. 45 | * @type {number} 46 | */ 47 | public daily: number 48 | 49 | /** 50 | * Work cooldown. 51 | * @type {number} 52 | */ 53 | public work: number 54 | 55 | /** 56 | * Weekly cooldown. 57 | * @type {number} 58 | */ 59 | public weekly: number 60 | } 61 | 62 | export = CooldownItem 63 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/HistoryData.d.ts: -------------------------------------------------------------------------------- 1 | import { CurrencyObject } from './CurrencyObject' 2 | import CustomItemData from './CustomItemData' 3 | import Maybe from './Maybe' 4 | 5 | /** 6 | * Purchases history object. 7 | */ 8 | declare interface HistoryData { 9 | 10 | /** 11 | * Item ID. 12 | */ 13 | id: number 14 | 15 | /** 16 | * Member ID. 17 | */ 18 | memberID: string 19 | 20 | /** 21 | * Guild ID. 22 | */ 23 | guildID: string 24 | 25 | /** 26 | * Item name. 27 | */ 28 | name: string 29 | 30 | /** 31 | * Item price. 32 | */ 33 | price: number 34 | 35 | /** 36 | * Items total price. 37 | */ 38 | totalPrice: number 39 | 40 | /** 41 | * Quantity of the items. 42 | */ 43 | quantity: number 44 | 45 | /** 46 | * The message that will be returned on item use. 47 | */ 48 | message?: string 49 | 50 | /** 51 | * Role ID from your Discord server that will be given to user on item use. Requires to specify your bot client in all `use` and `useItem` methods. 52 | */ 53 | role?: string 54 | 55 | /** 56 | * Date and time when the user bought the item. 57 | */ 58 | date: string 59 | 60 | /** 61 | * Custom item data object. 62 | */ 63 | custom?: CustomItemData 64 | 65 | /** 66 | * The object of the currency that was used for the purchase. 67 | */ 68 | currencyUsed: Maybe 69 | } 70 | 71 | export = HistoryData -------------------------------------------------------------------------------- /typings/interfaces/HistoryData.d.ts: -------------------------------------------------------------------------------- 1 | import { CurrencyObject } from './CurrencyObject' 2 | import CustomItemData from './CustomItemData' 3 | 4 | import Maybe from './Maybe' 5 | 6 | /** 7 | * Purchases history object. 8 | */ 9 | declare interface HistoryData { 10 | 11 | /** 12 | * Item ID. 13 | */ 14 | id: number 15 | 16 | /** 17 | * Member ID. 18 | */ 19 | memberID: string 20 | 21 | /** 22 | * Guild ID. 23 | */ 24 | guildID: string 25 | 26 | /** 27 | * Item name. 28 | */ 29 | name: string 30 | 31 | /** 32 | * Item price. 33 | */ 34 | price: number 35 | 36 | /** 37 | * Items total price. 38 | */ 39 | totalPrice: number 40 | 41 | /** 42 | * Quantity of the items. 43 | */ 44 | quantity: number 45 | 46 | /** 47 | * The message that will be returned on item use. 48 | */ 49 | message?: string 50 | 51 | /** 52 | * Role ID from your Discord server that will be given to user on item use. Requires to specify your bot client in all `use` and `useItem` methods. 53 | */ 54 | role?: string 55 | 56 | /** 57 | * Date and time when the user bought the item. 58 | */ 59 | date: string 60 | 61 | /** 62 | * Custom item data object. 63 | */ 64 | custom?: CustomItemData 65 | 66 | /** 67 | * The object of the currency that was used for the purchase. 68 | */ 69 | currencyUsed: Maybe 70 | } 71 | 72 | export = HistoryData 73 | -------------------------------------------------------------------------------- /typings/interfaces/CurrencyFactory.d.ts: -------------------------------------------------------------------------------- 1 | import Currency from '../classes/Currency' 2 | import CurrencyTransactionInfo from './CurrencyTransactionInfo' 3 | 4 | declare interface CurrencyFactory { 5 | 6 | /** 7 | * Gets the currency balance. 8 | * @returns {number} Currency balance. 9 | */ 10 | get(): number 11 | 12 | /** 13 | * Gets the currency object. 14 | * @returns {Currency} Currency object. 15 | */ 16 | getCurrency(): Currency 17 | 18 | /** 19 | * Sets the currency balance. 20 | * @param {number} amount Amount of money to set. 21 | * @param {string} [reason] The reason why the money was set. 22 | * @returns {CurrencyTransactionInfo} Currency transaction info object. 23 | */ 24 | set(amount: number, reason?: string): CurrencyTransactionInfo 25 | 26 | /** 27 | * Adds the money on the currency balance. 28 | * @param {number} amount Amount of money to add. 29 | * @param {string} [reason] The reason why the money was added. 30 | * @returns {CurrencyTransactionInfo} Currency transaction info object. 31 | */ 32 | add(amount: number, reason?: string): CurrencyTransactionInfo 33 | 34 | /** 35 | * Subtracts the money from the currency balance. 36 | * @param {number} amount Amount of money to subtract. 37 | * @param {string} [reason] The reason why the money was subtracted. 38 | * @returns {CurrencyTransactionInfo} Currency transaction info object. 39 | */ 40 | subtract(amount: number, reason?: string): CurrencyTransactionInfo 41 | } 42 | 43 | export = CurrencyFactory 44 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const { readdirSync } = require('fs') 2 | 3 | const EconomyError = require('./src/classes/util/EconomyError') 4 | const errors = require('./src/structures/errors') 5 | 6 | const colors = { 7 | red: '\x1b[31m', 8 | cyan: '\x1b[36m', 9 | reset: '\x1b[0m' 10 | } 11 | 12 | if (parseInt(process.version.split('.')[0].slice(1)) < 14) { 13 | const err = new EconomyError(errors.oldNodeVersion + process.version, 'OLD_NODE_VERSION') 14 | 15 | console.log(`${colors.red}Failed to start the module:${colors.cyan}`) 16 | console.log(err, colors.reset) 17 | 18 | process.exit(1) 19 | } 20 | 21 | 22 | const Economy = require('./src/index') 23 | const Emitter = require('./src/classes/util/Emitter') 24 | 25 | const EconomyProperties = { 26 | version: require('./package.json').version, 27 | docs: 'https://des-docs.js.org', 28 | 29 | EconomyError, 30 | Emitter, 31 | } 32 | 33 | 34 | const userClassFiles = readdirSync(__dirname + '/src/classes/user') 35 | const guildClassFiles = readdirSync(__dirname + '/src/classes/guild') 36 | const managerFiles = readdirSync(__dirname + '/src/managers') 37 | 38 | for (const userClassFile of userClassFiles) { 39 | EconomyProperties[userClassFile.slice(0, -3)] = require(`./src/classes/user/${userClassFile}`) 40 | } 41 | 42 | for (const guildClassFile of guildClassFiles) { 43 | EconomyProperties[guildClassFile.slice(0, -3)] = require(`./src/classes/guild/${guildClassFile}`) 44 | } 45 | 46 | for (const managerFile of managerFiles) { 47 | EconomyProperties[managerFile.slice(0, -3)] = require(`./src/managers/${managerFile}`) 48 | } 49 | 50 | module.exports = Object.assign(Economy, EconomyProperties) 51 | -------------------------------------------------------------------------------- /mongodb/index.js: -------------------------------------------------------------------------------- 1 | const { readdirSync } = require('fs') 2 | 3 | const EconomyError = require('./src/classes/util/EconomyError') 4 | const errors = require('./src/structures/errors') 5 | 6 | const colors = { 7 | red: '\x1b[31m', 8 | cyan: '\x1b[36m', 9 | reset: '\x1b[0m' 10 | } 11 | 12 | 13 | if (parseInt(process.version.split('.')[0].slice(1)) < 14) { 14 | const err = new EconomyError(errors.oldNodeVersion + process.version, 'OLD_NODE_VERSION') 15 | 16 | console.log(`${colors.red}Failed to start the module:${colors.cyan}`) 17 | console.log(err, colors.reset) 18 | 19 | process.exit(1) 20 | } 21 | 22 | 23 | const Economy = require('./src/index') 24 | const Emitter = require('./src/classes/util/Emitter') 25 | 26 | const EconomyProperties = { 27 | version: require('./package.json').version, 28 | docs: 'https://des-docs.js.org', 29 | 30 | EconomyError, 31 | Emitter, 32 | } 33 | 34 | 35 | const userClassFiles = readdirSync(__dirname + '/src/classes/user') 36 | const guildClassFiles = readdirSync(__dirname + '/src/classes/guild') 37 | const managerFiles = readdirSync(__dirname + '/src/managers') 38 | 39 | for (const userClassFile of userClassFiles) { 40 | EconomyProperties[userClassFile.slice(0, -3)] = require(`./src/classes/user/${userClassFile}`) 41 | } 42 | 43 | for (const guildClassFile of guildClassFiles) { 44 | EconomyProperties[guildClassFile.slice(0, -3)] = require(`./src/classes/guild/${guildClassFile}`) 45 | } 46 | 47 | for (const managerFile of managerFiles) { 48 | EconomyProperties[managerFile.slice(0, -3)] = require(`./src/managers/${managerFile}`) 49 | } 50 | 51 | module.exports = Object.assign(Economy, EconomyProperties) 52 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/CurrencyFactory.d.ts: -------------------------------------------------------------------------------- 1 | import Currency from '../classes/Currency' 2 | import CurrencyTransactionInfo from './CurrencyTransactionInfo' 3 | 4 | declare interface CurrencyFactory { 5 | 6 | /** 7 | * Gets the currency balance. 8 | * @returns {Promise} Currency balance. 9 | */ 10 | get(): Promise 11 | 12 | /** 13 | * Gets the currency object. 14 | * @returns {Promise} Currency object. 15 | */ 16 | getCurrency(): Promise 17 | 18 | /** 19 | * Sets the currency balance. 20 | * @param {number} amount Amount of money to set. 21 | * @param {string} [reason] The reason why the money was set. 22 | * @returns {Promise} Currency transaction info object. 23 | */ 24 | set(amount: number, reason?: string): Promise 25 | 26 | /** 27 | * Adds the money on the currency balance. 28 | * @param {number} amount Amount of money to add. 29 | * @param {string} [reason] The reason why the money was added. 30 | * @returns {Promise} Currency transaction info object. 31 | */ 32 | add(amount: number, reason?: string): Promise 33 | 34 | /** 35 | * Subtracts the money from the currency balance. 36 | * @param {number} amount Amount of money to subtract. 37 | * @param {string} [reason] The reason why the money was subtracted. 38 | * @returns {Promise} Currency transaction info object. 39 | */ 40 | subtract(amount: number, reason?: string): Promise 41 | } 42 | 43 | export = CurrencyFactory 44 | -------------------------------------------------------------------------------- /mongodb/typings/managers/GuildManager.d.ts: -------------------------------------------------------------------------------- 1 | import DatabaseManager from './DatabaseManager' 2 | import CacheManager from './CacheManager' 3 | 4 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 5 | 6 | import BaseManager from './BaseManager' 7 | 8 | import EconomyGuild from '../classes/EconomyGuild' 9 | import EmptyEconomyGuild from '../classes/EmptyEconomyGuild' 10 | 11 | 12 | /** 13 | * Guild Manager. 14 | */ 15 | declare class GuildManager extends BaseManager { 16 | 17 | /** 18 | * Guild Manager. 19 | * @param {EconomyConfiguration} options Economy configuration. 20 | */ 21 | public constructor(options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager) 22 | 23 | /** 24 | * Gets the guild by it's ID. 25 | * @param {string} guildID Guild ID. 26 | * @returns {Promise} User object. 27 | */ 28 | public get(guildID: string): Promise 29 | 30 | /** 31 | * Creates an economy guild object in database. 32 | * @param {string} guildID The guild ID to set. 33 | * @returns {Promise} New guild instance. 34 | */ 35 | public create(guildID: string): Promise 36 | 37 | /** 38 | * Resets the guild in database. 39 | * @param {string} guildID Guild ID. 40 | * @returns {Promise} New guild instance. 41 | */ 42 | public reset(guildID: string): Promise 43 | 44 | /** 45 | * Gets the array of all guilds in database. 46 | * @returns {Promise} 47 | */ 48 | public all(): Promise 49 | } 50 | 51 | export = GuildManager 52 | -------------------------------------------------------------------------------- /typings/managers/UserManager.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 2 | import BaseManager from './BaseManager' 3 | 4 | import EconomyUser from '../classes/EconomyUser' 5 | import EmptyEconomyUser from '../classes/EmptyEconomyUser' 6 | 7 | import UserFunction from '../interfaces/UserFunction' 8 | 9 | /** 10 | * User Manager. 11 | */ 12 | declare class UserManager extends BaseManager { 13 | 14 | /** 15 | * User Manager. 16 | * @param {EconomyConfiguration} options Economy configuration. 17 | */ 18 | public constructor(options: EconomyConfiguration, guildID: string) 19 | 20 | /** 21 | * Gets the array of ALL users in database. 22 | * @returns {EconomyUser[]} 23 | */ 24 | public all: UserFunction 25 | 26 | /** 27 | * Gets the user by it's ID and guild ID. 28 | * @param {string} memberID Member ID. 29 | * @param {string} guildID Guild ID. 30 | * @returns {EconomyUser} User object. 31 | */ 32 | public get: UserFunction 33 | 34 | /** 35 | * Creates an economy user object in database. 36 | * @param {string} memberID The user ID to set. 37 | * @param {string} guildID Guild ID. 38 | * @returns {EconomyUser} Economy user object. 39 | */ 40 | public create: UserFunction 41 | 42 | /** 43 | * Sets the default user object for a specified member. 44 | * @param {string} userID User ID. 45 | * @returns {boolean} If reset successfully: true; else: false. 46 | */ 47 | public reset: UserFunction 48 | } 49 | 50 | export = UserManager 51 | -------------------------------------------------------------------------------- /src/classes/util/Emitter.js: -------------------------------------------------------------------------------- 1 | const { EventEmitter } = require('events') 2 | 3 | const emitter = new EventEmitter({ 4 | captureRejections: true 5 | }) 6 | 7 | 8 | /** 9 | * Economy event emitter with only important emitter methods. 10 | * @private 11 | */ 12 | class Emitter { 13 | 14 | /** 15 | * Economy event emitter with only important emitter methods. 16 | * @private 17 | */ 18 | constructor() { } 19 | 20 | /** 21 | * Listens to the event. 22 | * @param {EconomyEvents} event Event name. 23 | * @param {Function} listener Callback function. 24 | * @returns {Emitter} Economy Emitter. 25 | */ 26 | on(event, listener) { 27 | emitter.on(event, listener) 28 | return this 29 | } 30 | 31 | /** 32 | * Listens to the event only for once. 33 | * @param {EconomyEvents} event Event name. 34 | * @param {Function} listener Callback function. 35 | * @returns {Emitter} Economy Emitter. 36 | */ 37 | once(event, listener) { 38 | emitter.once(event, listener) 39 | return this 40 | } 41 | 42 | /** 43 | * Emits the event. 44 | * @param {EconomyEvents} event Event name. 45 | * @param {any} data Any data to send. 46 | * @returns {boolean} If emitted: true; else: false. 47 | */ 48 | emit(event, data) { 49 | return emitter.emit(event, data) 50 | } 51 | } 52 | 53 | /** 54 | * Emitter class. 55 | * @type {Emitter} 56 | */ 57 | module.exports = Emitter 58 | 59 | /** 60 | * @typedef {'balanceSet' | 'balanceAdd' | 'balanceSubtract' | 61 | * 'bankSet' | 'bankAdd' | 'bankSubtract' | 62 | * 'customCurrencySet' | 'customCurrencyAdd' | 'customCurrencySubtract' | 63 | * 'shopItemAdd' | 'shopItemEdit' | 'shopItemBuy' | 64 | * 'shopItemUse' | 'shopClear' | 65 | * 'ready' | 'destroy'} EconomyEvents Economy events. 66 | */ 67 | -------------------------------------------------------------------------------- /mongodb/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | 4 | parserOptions: { 5 | ecmaVersion: 2020, 6 | sourceType: 'module', 7 | }, 8 | 9 | extends: [ 10 | 'eslint:recommended' 11 | ], 12 | 13 | env: { 14 | es6: true, 15 | node: true, 16 | browser: true, 17 | amd: true 18 | }, 19 | 20 | globals: { 21 | $: true, 22 | require: true, 23 | process: true 24 | }, 25 | 26 | rules: { 27 | 'no-plusplus': 'off', 28 | 29 | 'implicit-arrow-linebreak': 'off', 30 | 'operator-linebreak': 'off', 31 | 'no-param-reassign': 'off', 32 | 'arrow-body-style': 'off', 33 | 34 | 'consistent-return': 'off', 35 | 'function-paren-newline': 'off', 36 | 'max-classes-per-file': 'off', 37 | 38 | 'semi': [ 39 | 'warn', 40 | 'never' 41 | ], 42 | 43 | indent: [ 44 | 'warn', 45 | 4 46 | ], 47 | 48 | 'max-len': [ 49 | 'warn', { 50 | 'code': 120 51 | } 52 | ], 53 | 54 | 'prefer-const': 'warn', 55 | 'camelcase': 'warn', 56 | 'eol-last': 'warn', 57 | 58 | 'dot-notation': 'warn', 59 | 'no-continue': 'warn', 60 | 'no-redeclare': 'warn', 61 | 62 | 'block-spacing': [ 63 | 'error', 64 | 'never' 65 | ], 66 | 67 | 'no-unneeded-ternary': 'error', 68 | 'no-spaced-func': 'error', 69 | 70 | 'object-curly-spacing': [ 71 | 'error', 72 | 'always' 73 | ], 74 | 75 | 'no-trailing-spaces': [ 76 | 'error', { 77 | 'ignoreComments': true, 78 | } 79 | ], 80 | 81 | 'quotes': [ 82 | 'error', 83 | 'single' 84 | ], 85 | 86 | 'no-return-await': [ 87 | 'error' 88 | ], 89 | }, 90 | } 91 | -------------------------------------------------------------------------------- /mongodb/src/classes/util/Emitter.js: -------------------------------------------------------------------------------- 1 | const { EventEmitter } = require('events') 2 | 3 | const emitter = new EventEmitter({ 4 | captureRejections: true 5 | }) 6 | 7 | 8 | /** 9 | * Economy event emitter with only important emitter methods. 10 | * @private 11 | */ 12 | class Emitter { 13 | 14 | /** 15 | * Economy event emitter with only important emitter methods. 16 | * @private 17 | */ 18 | constructor() { } 19 | 20 | /** 21 | * Listens to the event. 22 | * @param {EconomyEvents} event Event name. 23 | * @param {Function} listener Callback function. 24 | * @returns {Emitter} Economy Emitter. 25 | */ 26 | on(event, listener) { 27 | emitter.on(event, listener) 28 | return this 29 | } 30 | 31 | /** 32 | * Listens to the event only for once. 33 | * @param {EconomyEvents} event Event name. 34 | * @param {Function} listener Callback function. 35 | * @returns {Emitter} Economy Emitter. 36 | */ 37 | once(event, listener) { 38 | emitter.once(event, listener) 39 | return this 40 | } 41 | 42 | /** 43 | * Emits the event. 44 | * @param {EconomyEvents} event Event name. 45 | * @param {any} data Any data to send. 46 | * @returns {boolean} If emitted: true; else: false. 47 | */ 48 | emit(event, data) { 49 | return emitter.emit(event, data) 50 | } 51 | } 52 | 53 | /** 54 | * Emitter class. 55 | * @type {Emitter} 56 | */ 57 | module.exports = Emitter 58 | 59 | /** 60 | * @typedef {'balanceSet' | 'balanceAdd' | 'balanceSubtract' | 61 | * 'bankSet' | 'bankAdd' | 'bankSubtract' | 62 | * 'customCurrencySet' | 'customCurrencyAdd' | 'customCurrencySubtract' | 63 | * 'shopItemAdd' | 'shopItemEdit' | 'shopItemBuy' | 64 | * 'shopItemUse' | 'shopClear' | 65 | * 'ready' | 'destroy'} EconomyEvents Economy events. 66 | */ 67 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "discord-economy-super", 3 | "version": "1.7.7", 4 | "types": "./typings/Economy.d.ts", 5 | "description": "Easy and customizable economy module for your Discord Bot.", 6 | "main": "index.js", 7 | "scripts": { 8 | "test": "node ./tests/test.js", 9 | "postinstall": "node postinstall.js", 10 | "precommit": "bash ./.husky/scripts/commit-to-public.sh", 11 | "docs:deploy": "bash ./.husky/scripts/deploy-docs.sh", 12 | "deploy": "bash ./.husky/scripts/commit-and-deploy.sh", 13 | "upload": "bash ./publish.sh && bash ./.husky/scripts/deploy-docs.sh", 14 | "lint": "eslint ./", 15 | "lint:fix": "eslint ./ --fix" 16 | }, 17 | "keywords": [ 18 | "discord", 19 | "bot", 20 | "discord.js", 21 | "economy", 22 | "fast", 23 | "easy", 24 | "easy-eco", 25 | "easy-economy", 26 | "discord economy", 27 | "discord-economy", 28 | "discord-economy-super", 29 | "discord-js", 30 | "discord.eco", 31 | "discord-eco", 32 | "discord-bot", 33 | "json", 34 | "quick", 35 | "lightweight", 36 | "eco", 37 | "simple", 38 | "quick.eco", 39 | "economy.js", 40 | "mongo", 41 | "mongodb", 42 | "database", 43 | "economy.json", 44 | "economy.mongo", 45 | "economy.mongodb", 46 | "framework", 47 | "shadowplay" 48 | ], 49 | "author": "shadowplay", 50 | "license": "MIT", 51 | "dependencies": { 52 | "quick-mongo-super": "^1.0.19" 53 | }, 54 | "quick-mongo-super": { 55 | "postinstall": false 56 | }, 57 | "engines": { 58 | "node": ">=14.0.0" 59 | }, 60 | "directories": { 61 | "lib": "./src" 62 | }, 63 | "repository": { 64 | "type": "git", 65 | "url": "git+https://github.com/shadowplay1/discord-economy-super.git" 66 | }, 67 | "bugs": { 68 | "url": "https://github.com/shadowplay1/discord-economy-super/issues" 69 | }, 70 | "homepage": "https://des-docs.js.org", 71 | "devDependencies": { 72 | "@types/node-fetch": "^2.6.1" 73 | } 74 | } -------------------------------------------------------------------------------- /mongodb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "discord-economy-super", 3 | "version": "1.7.7", 4 | "types": "./typings/Economy.d.ts", 5 | "description": "Easy and customizable economy module for your Discord Bot.", 6 | "main": "index.js", 7 | "scripts": { 8 | "test": "node ./tests/test.js", 9 | "postinstall": "node postinstall.js", 10 | "precommit": "bash ./.husky/scripts/commit-to-public.sh", 11 | "docs:deploy": "bash ./.husky/scripts/deploy-docs.sh", 12 | "deploy": "bash ./.husky/scripts/commit-and-deploy.sh", 13 | "upload": "bash ./publish.sh && bash ./.husky/scripts/deploy-docs.sh", 14 | "lint": "eslint ./", 15 | "lint:fix": "eslint ./ --fix" 16 | }, 17 | "keywords": [ 18 | "discord", 19 | "bot", 20 | "discord.js", 21 | "economy", 22 | "fast", 23 | "easy", 24 | "easy-eco", 25 | "easy-economy", 26 | "discord economy", 27 | "discord-economy", 28 | "discord-economy-super", 29 | "discord-js", 30 | "discord.eco", 31 | "discord-eco", 32 | "discord-bot", 33 | "json", 34 | "quick", 35 | "lightweight", 36 | "eco", 37 | "simple", 38 | "quick.eco", 39 | "economy.js", 40 | "mongo", 41 | "mongodb", 42 | "database", 43 | "economy.json", 44 | "economy.mongo", 45 | "economy.mongodb", 46 | "framework", 47 | "shadowplay" 48 | ], 49 | "author": "shadowplay", 50 | "license": "MIT", 51 | "dependencies": { 52 | "quick-mongo-super": "^1.0.19" 53 | }, 54 | "quick-mongo-super": { 55 | "postinstall": false 56 | }, 57 | "engines": { 58 | "node": ">=14.0.0" 59 | }, 60 | "directories": { 61 | "lib": "./src" 62 | }, 63 | "repository": { 64 | "type": "git", 65 | "url": "git+https://github.com/shadowplay1/discord-economy-super.git" 66 | }, 67 | "bugs": { 68 | "url": "https://github.com/shadowplay1/discord-economy-super/issues" 69 | }, 70 | "homepage": "https://des-docs.js.org", 71 | "devDependencies": { 72 | "@types/node-fetch": "^2.6.1" 73 | } 74 | } -------------------------------------------------------------------------------- /mongodb/typings/managers/UserManager.d.ts: -------------------------------------------------------------------------------- 1 | import DatabaseManager from './DatabaseManager' 2 | import CacheManager from './CacheManager' 3 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 4 | 5 | import BaseManager from './BaseManager' 6 | 7 | import EconomyUser from '../classes/EconomyUser' 8 | import EmptyEconomyUser from '../classes/EmptyEconomyUser' 9 | 10 | import UserFunction from '../interfaces/UserFunction' 11 | 12 | 13 | /** 14 | * User Manager. 15 | */ 16 | declare class UserManager extends BaseManager { 17 | 18 | /** 19 | * User Manager. 20 | * @param {EconomyConfiguration} options Economy configuration. 21 | */ 22 | public constructor( 23 | options: EconomyConfiguration, 24 | database: DatabaseManager, 25 | guildID: string, 26 | cache: CacheManager 27 | ) 28 | 29 | /** 30 | * Gets the array of ALL users in database. 31 | * @returns {EconomyUser[]} 32 | */ 33 | public all: UserFunction 34 | 35 | /** 36 | * Gets the user by it's ID and guild ID. 37 | * @param {string} memberID Member ID. 38 | * @param {string} guildID Guild ID. 39 | * @returns {EconomyUser} User object. 40 | */ 41 | public get: UserFunction 42 | 43 | /** 44 | * Creates an economy user object in database. 45 | * @param {string} memberID The user ID to set. 46 | * @param {string} guildID Guild ID. 47 | * @returns {EconomyUser} Economy user object. 48 | */ 49 | public create: UserFunction 50 | 51 | /** 52 | * Sets the default user object for a specified member. 53 | * @param {string} userID User ID. 54 | * @returns {boolean} If reset successfully: true; else: false. 55 | */ 56 | public reset: UserFunction 57 | } 58 | 59 | export = UserManager 60 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | 4 | parserOptions: { 5 | ecmaVersion: 2020, 6 | sourceType: 'module', 7 | }, 8 | 9 | extends: [ 10 | 'eslint:recommended' 11 | ], 12 | 13 | env: { 14 | es6: true, 15 | node: true, 16 | browser: true, 17 | amd: true 18 | }, 19 | 20 | globals: { 21 | $: true, 22 | require: true, 23 | process: true 24 | }, 25 | 26 | rules: { 27 | 'no-plusplus': 'off', 28 | 29 | 'implicit-arrow-linebreak': 'off', 30 | 'operator-linebreak': 'off', 31 | 'no-param-reassign': 'off', 32 | 'arrow-body-style': 'off', 33 | 34 | 'consistent-return': 'off', 35 | 'function-paren-newline': 'off', 36 | 'max-classes-per-file': 'off', 37 | 38 | 'semi': [ 39 | 'warn', 40 | 'never' 41 | ], 42 | 43 | indent: [ 44 | 'warn', 45 | 4 46 | ], 47 | 48 | 'max-len': [ 49 | 'warn', { 50 | 'code': 120 51 | } 52 | ], 53 | 54 | 'prefer-const': 'warn', 55 | 'camelcase': 'warn', 56 | 'eol-last': 'warn', 57 | 58 | 'dot-notation': 'warn', 59 | 'no-continue': 'warn', 60 | 'no-redeclare': 'warn', 61 | 62 | 'block-spacing': [ 63 | 'error', 64 | 'never' 65 | ], 66 | 67 | 'no-unneeded-ternary': 'error', 68 | 'no-spaced-func': 'error', 69 | 70 | 'object-curly-spacing': [ 71 | 'error', 72 | 'always' 73 | ], 74 | 75 | 'no-trailing-spaces': [ 76 | 'error', { 77 | 'ignoreComments': true, 78 | } 79 | ], 80 | 81 | 'quotes': [ 82 | 'error', 83 | 'single' 84 | ], 85 | 86 | 'no-return-await': [ 87 | 'error' 88 | ], 89 | }, 90 | } 91 | -------------------------------------------------------------------------------- /typings/interfaces/SettingsTypes.d.ts: -------------------------------------------------------------------------------- 1 | declare interface SettingsTypes { 2 | 3 | /** 4 | * Amount of money for Daily Reward. Default: 100. 5 | */ 6 | dailyAmount: number | [number, number] 7 | 8 | /** 9 | * Cooldown for Daily Command (in ms). Default: 24 hours (60000 * 60 * 24 ms) 10 | */ 11 | dailyCooldown: number 12 | 13 | /** 14 | * Amount of money for Work Reward. Default: [10, 50]. 15 | */ 16 | workAmount: number | [number, number] 17 | 18 | /** 19 | * Cooldown for Work Command (in ms). Default: 1 hour (60000 * 60 ms) 20 | */ 21 | workCooldown: number 22 | 23 | /** 24 | * Amount of money for Weekly Reward. Default: 1000. 25 | */ 26 | weeklyAmount: number | [number, number] 27 | 28 | /** 29 | * Amount of money for Monthly Reward. Default: 10000. 30 | */ 31 | monthlyAmount: number | [number, number] 32 | 33 | /** 34 | * Cooldown for Monthly Reward (in ms). Default: 1 month (2629746000 ms). 35 | */ 36 | monthlyCooldown: number | [number, number] 37 | 38 | /** 39 | * Amount of money for Monthly Reward. Default: 10000. 40 | */ 41 | hourlyAmount: number | [number, number] 42 | 43 | /** 44 | * Cooldown for Hourly Reward (in ms). Default: 1 hour (3600000 ms). 45 | */ 46 | hourlyCooldown: number | [number, number] 47 | 48 | /** 49 | * Cooldown for Weekly Command (in ms). Default: 7 days (60000 * 60 * 24 * 7 ms) 50 | */ 51 | weeklyCooldown: number 52 | 53 | /** 54 | * The region (example: 'ru' or 'en') to format the date and time. Default: 'en' 55 | */ 56 | dateLocale: string 57 | 58 | /** 59 | * If true, when someone buys the item, their balance will subtract by item price. Default: false. 60 | */ 61 | subtractOnBuy: boolean 62 | 63 | /** 64 | * If true, the module will save all the purchases history. Default: true. 65 | */ 66 | savePurchasesHistory: boolean 67 | } 68 | 69 | export = SettingsTypes 70 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/SettingsTypes.d.ts: -------------------------------------------------------------------------------- 1 | declare interface SettingsTypes { 2 | 3 | /** 4 | * Amount of money for Daily Reward. Default: 100. 5 | */ 6 | dailyAmount: number | [number, number] 7 | 8 | /** 9 | * Cooldown for Daily Command (in ms). Default: 24 hours (60000 * 60 * 24 ms) 10 | */ 11 | dailyCooldown: number 12 | 13 | /** 14 | * Amount of money for Work Reward. Default: [10, 50]. 15 | */ 16 | workAmount: number | [number, number] 17 | 18 | /** 19 | * Cooldown for Work Command (in ms). Default: 1 hour (60000 * 60 ms) 20 | */ 21 | workCooldown: number 22 | 23 | /** 24 | * Amount of money for Weekly Reward. Default: 1000. 25 | */ 26 | weeklyAmount: number | [number, number] 27 | 28 | /** 29 | * Amount of money for Monthly Reward. Default: 10000. 30 | */ 31 | monthlyAmount: number | [number, number] 32 | 33 | /** 34 | * Cooldown for Monthly Reward (in ms). Default: 1 month (2629746000 ms). 35 | */ 36 | monthlyCooldown: number | [number, number] 37 | 38 | /** 39 | * Amount of money for Monthly Reward. Default: 10000. 40 | */ 41 | hourlyAmount: number | [number, number] 42 | 43 | /** 44 | * Cooldown for Hourly Reward (in ms). Default: 1 hour (3600000 ms). 45 | */ 46 | hourlyCooldown: number | [number, number] 47 | 48 | /** 49 | * Cooldown for Weekly Command (in ms). Default: 7 days (60000 * 60 * 24 * 7 ms) 50 | */ 51 | weeklyCooldown: number 52 | 53 | /** 54 | * The region (example: 'ru' or 'en') to format the date and time. Default: 'en' 55 | */ 56 | dateLocale: string 57 | 58 | /** 59 | * If true, when someone buys the item, their balance will subtract by item price. Default: false. 60 | */ 61 | subtractOnBuy: boolean 62 | 63 | /** 64 | * If true, the module will save all the purchases history. Default: true. 65 | */ 66 | savePurchasesHistory: boolean 67 | } 68 | 69 | export = SettingsTypes 70 | -------------------------------------------------------------------------------- /mongodb/typings/classes/user/Bank.d.ts: -------------------------------------------------------------------------------- 1 | 2 | import Emitter from '../util/Emitter' 3 | import EconomyConfiguration from '../../interfaces/EconomyConfiguration' 4 | import DatabaseManager from '../../managers/DatabaseManager' 5 | 6 | declare class Bank extends Emitter { 7 | public constructor(memberID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager) 8 | 9 | /** 10 | * Sets the money amount on user's bank balance. 11 | * @param {number} amount Money amount 12 | * @param {string} [reason] The reason why you set the money. 13 | * @returns {Promise} Money amount 14 | */ 15 | public set(amount: number, reason?: string): Promise 16 | 17 | /** 18 | * Adds the money amount on user's bank balance. 19 | * @param {number} amount Money amount. 20 | * @param {string} [reason] The reason why you add the money. 21 | * @returns {Promise} Money amount. 22 | */ 23 | public add(amount: number, reason?: string): Promise 24 | 25 | /** 26 | * Subtracts the money amount on user's bank balance. 27 | * @param {number} amount Money amount. 28 | * @param {string} [reason] The reason why you subtract the money. 29 | * @returns {Promise} Money amount. 30 | */ 31 | public subtract(amount: number, reason?: string): Promise 32 | 33 | /** 34 | * Withdraws the specified amount of money. 35 | * @param {number} amount Money amount. 36 | * @param {string} [reason] The reason of the operation. 37 | * @returns {Promise} Money amount. 38 | */ 39 | public withdraw(amount: number, reason?: string): Promise 40 | 41 | /** 42 | * Fetches the user's bank balance. 43 | * @returns {Promise} User's bank balance. 44 | */ 45 | public fetch(): Promise 46 | 47 | /** 48 | * Fetches the user's bank balance. 49 | * 50 | * This method is an alias for 'EconomyUser.bank.fetch()' method. 51 | * @returns {Promise} User's bank balance. 52 | */ 53 | public get(): Promise 54 | } 55 | 56 | export = Bank -------------------------------------------------------------------------------- /typings/classes/user/Bank.d.ts: -------------------------------------------------------------------------------- 1 | 2 | import Emitter from '../util/Emitter' 3 | import EconomyConfiguration from '../../interfaces/EconomyConfiguration' 4 | import DatabaseManager from '../../managers/DatabaseManager' 5 | 6 | declare class Bank extends Emitter { 7 | 8 | /** 9 | * User bank balance class. 10 | * @param {string} memberID Member ID. 11 | * @param {string} guildID Guild ID. 12 | * @param {EconomyConfiguration} ecoOptions Economy configuration. 13 | * @param {DatabaseManager} database Database manager. 14 | */ 15 | public constructor( 16 | memberID: string, 17 | guildID: string, 18 | options: EconomyConfiguration, 19 | database: DatabaseManager 20 | ) 21 | 22 | /** 23 | * Sets the money amount on user's bank balance. 24 | * @param {number} amount Money amount 25 | * @param {string} [reason] The reason why you set the money. 26 | * @returns {number} Money amount 27 | */ 28 | public set(amount: number, reason?: string): number 29 | 30 | /** 31 | * Adds the money amount on user's bank balance. 32 | * @param {number} amount Money amount. 33 | * @param {string} [reason] The reason why you add the money. 34 | * @returns {number} Money amount. 35 | */ 36 | public add(amount: number, reason?: string): number 37 | 38 | /** 39 | * Subtracts the money amount on user's bank balance. 40 | * @param {number} amount Money amount. 41 | * @param {string} [reason] The reason why you subtract the money. 42 | * @returns {number} Money amount. 43 | */ 44 | public subtract(amount: number, reason?: string): number 45 | 46 | /** 47 | * Fetches the user's bank balance. 48 | * @returns {number} User's bank balance. 49 | */ 50 | public fetch(): number 51 | 52 | /** 53 | * Withdraws the specified amount of money. 54 | * @param {number} amount Money amount. 55 | * @param {string} [reason] The reason of the operation. 56 | * @returns {number} Money amount. 57 | */ 58 | public withdraw(amount: number, reason?: string): number 59 | 60 | /** 61 | * Fetches the user's bank balance. 62 | * 63 | * This method is an alias for 'EconomyUser.bank.fetch()' method. 64 | * @returns {number} User's bank balance. 65 | */ 66 | public get(): number 67 | } 68 | 69 | export = Bank -------------------------------------------------------------------------------- /mongodb/typings/managers/UtilsManager.d.ts: -------------------------------------------------------------------------------- 1 | import DatabaseManager from './DatabaseManager' 2 | import CacheManager from './CacheManager' 3 | 4 | import CheckerConfiguration from '../interfaces/CheckerConfiguration' 5 | 6 | import EconomyDatabase from '../interfaces/EconomyDatabase' 7 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 8 | 9 | import VersionData from '../interfaces/VersionData' 10 | 11 | 12 | /** 13 | * Utils manager methods class. 14 | */ 15 | declare class UtilsManager { 16 | public constructor(options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager) 17 | 18 | /** 19 | * Fetches the entire database. 20 | * @returns Database contents 21 | */ 22 | public all(): EconomyDatabase 23 | 24 | /** 25 | * Clears the storage file. 26 | * @returns {Promise} If cleared successfully: true; else: false 27 | */ 28 | public clearDatabase(): Promise 29 | 30 | /** 31 | * Fully removes the guild from database. 32 | * @param {string} guildID Guild ID 33 | * @returns {Promise} If cleared successfully: true; else: false 34 | */ 35 | public removeGuild(guildID: string): Promise 36 | 37 | /** 38 | * Removes the user from database. 39 | * @param {string} memberID Member ID 40 | * @param {string} guildID Guild ID 41 | * @returns {Promise} If cleared successfully: true; else: false 42 | */ 43 | public removeUser(memberID: string, guildID: string): Promise 44 | 45 | /** 46 | * Checks for the module updates. 47 | * @returns {Promise} Is the module updated, latest version and installed version. 48 | */ 49 | public checkUpdates(): Promise 50 | 51 | /** 52 | * Checks the Economy configuration, fixes the problems returns it. 53 | * @param {CheckerConfiguration} options Option checker options. 54 | * @returns {EconomyConfiguration} Fixed Economy configuration. 55 | */ 56 | public checkConfiguration(options?: CheckerConfiguration): EconomyConfiguration 57 | 58 | /** 59 | * Sets the default user object for the specified member. 60 | * @param {string} memberID Member ID. 61 | * @param {string} guildID Guild ID. 62 | * @returns {Promise} If reset successfully: true; else: false. 63 | */ 64 | public resetUser(memberID: string, guildID: string): Promise 65 | } 66 | 67 | export = UtilsManager -------------------------------------------------------------------------------- /typings/managers/FetchManager.d.ts: -------------------------------------------------------------------------------- 1 | import DatabaseManager from './DatabaseManager' 2 | 3 | import UserCooldownData from '../interfaces/UserCooldownData' 4 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 5 | import EconomyDatabase from '../interfaces/EconomyDatabase' 6 | 7 | import HistoryItem from '../classes/HistoryItem' 8 | import ShopItem from '../classes/ShopItem' 9 | import InventoryItem from '../classes/InventoryItem' 10 | 11 | /** 12 | * Fetch manager methods class. 13 | */ 14 | declare class FetchManager { 15 | public constructor(options: EconomyConfiguration, database: DatabaseManager) 16 | 17 | /** 18 | * Fetches the entire database. 19 | * @returns {object} Database contents. 20 | */ 21 | public fetchAll(): EconomyDatabase 22 | 23 | /** 24 | * Shows all items in the shop. 25 | * @param {string} guildID Guild ID 26 | * @returns {ShopItem[]} The shop array. 27 | */ 28 | public fetchShop(guildID: string): ShopItem[] 29 | 30 | /** 31 | * Fetches the user's cooldowns. 32 | * @param {string} memberID Member ID 33 | * @param {string} guildID Guild ID 34 | * @returns {UserCooldownData} User's cooldowns object. 35 | */ 36 | public fetchCooldowns(memberID: string, guildID: string): UserCooldownData 37 | 38 | /** 39 | * Fetches the user's purchases history. 40 | * @param {string} memberID Member ID 41 | * @param {string} guildID Guild ID 42 | * @returns {HistoryItem} User's purchases history. 43 | */ 44 | public fetchHistory(memberID: string, guildID: string): HistoryItem[] 45 | 46 | /** 47 | * Fetches the user's inventory. 48 | * @param {string} memberID Member ID 49 | * @param {string} guildID Guild ID 50 | * @returns {InventoryItem} User's inventory. 51 | */ 52 | public fetchInventory(memberID: string, guildID: string): InventoryItem[] 53 | 54 | /** 55 | * Fetches the user's bank balance. 56 | * @param {string} memberID Member ID 57 | * @param {string} guildID Guild ID 58 | * @returns {number} User's bank balance. 59 | */ 60 | public fetchBank(memberID: string, guildID: string): number 61 | 62 | /** 63 | * Fetches the user's balance. 64 | * @param {string} memberID Member ID 65 | * @param {string} guildID Guild ID 66 | * @returns {number} User's balance. 67 | */ 68 | public fetchBalance(memberID: string, guildID: string): number 69 | } 70 | 71 | export = FetchManager -------------------------------------------------------------------------------- /typings/managers/UtilsManager.d.ts: -------------------------------------------------------------------------------- 1 | import DatabaseManager from './DatabaseManager' 2 | 3 | import CheckerConfiguration from '../interfaces/CheckerConfiguration' 4 | 5 | import EconomyDatabase from '../interfaces/EconomyDatabase' 6 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 7 | 8 | import VersionData from '../interfaces/VersionData' 9 | 10 | 11 | /** 12 | * Utils manager methods class. 13 | */ 14 | declare class UtilsManager { 15 | public constructor(options: EconomyConfiguration, database: DatabaseManager) 16 | 17 | /** 18 | * Fetches the entire database. 19 | * @returns Database contents 20 | */ 21 | public all(): EconomyDatabase 22 | 23 | /** 24 | * Clears the storage file. 25 | * @returns {boolean} If cleared successfully: true; else: false 26 | */ 27 | public clearDatabase(): boolean 28 | 29 | /** 30 | * Fully removes the guild from database. 31 | * @param {string} guildID Guild ID 32 | * @returns {boolean} If cleared successfully: true; else: false 33 | */ 34 | public removeGuild(guildID: string): boolean 35 | 36 | /** 37 | * Removes the user from database. 38 | * @param {string} memberID Member ID 39 | * @param {string} guildID Guild ID 40 | * @returns {boolean} If cleared successfully: true; else: false 41 | */ 42 | public removeUser(memberID: string, guildID: string): boolean 43 | 44 | /** 45 | * Checks for the module updates. 46 | * @returns {Promise} Is the module updated, latest version and installed version. 47 | */ 48 | public checkUpdates(): Promise 49 | 50 | /** 51 | * Checks the Economy configuration, fixes the problems returns it. 52 | * @param {CheckerConfiguration} options Option checker options. 53 | * @returns {EconomyConfiguration} Fixed Economy configuration. 54 | */ 55 | public checkConfiguration(options?: CheckerConfiguration): EconomyConfiguration 56 | 57 | /** 58 | * Writes the data to file. 59 | * @param {string} path File path to write. 60 | * @param {T} data Any data to write 61 | * @returns {boolean} If successfully written: true; else: false. 62 | */ 63 | public write(path: string, data: T): boolean 64 | 65 | /** 66 | * Sets the default user object for the specified member. 67 | * @param {string} memberID Member ID. 68 | * @param {string} guildID Guild ID. 69 | * @returns {boolean} If reset successfully: true; else: false. 70 | */ 71 | public reset(memberID: string, guildID: string): boolean 72 | } 73 | 74 | export = UtilsManager -------------------------------------------------------------------------------- /typings/classes/user/Rewards.d.ts: -------------------------------------------------------------------------------- 1 | import RewardObject from '../../interfaces/RewardObject' 2 | import EconomyConfiguration from '../../interfaces/EconomyConfiguration' 3 | import DatabaseManager from '../../managers/DatabaseManager' 4 | 5 | import { RewardType } from '../../interfaces/RewardTypes' 6 | 7 | 8 | declare class Rewards { 9 | public constructor(memberID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager) 10 | 11 | /** 12 | * Adds a specified reward on user's balance. 13 | * @param reward Reward to give. 14 | * @param reason The reason why the money was added. 15 | * @returns Reward object. 16 | */ 17 | public receive< 18 | isRewardArray extends boolean = false 19 | >(reward: RewardType, reason?: string): RewardObject 20 | 21 | /** 22 | * Adds a daily reward on user's balance. 23 | * @param reason The reason why the money was added. Default: 'claimed the daily reward' 24 | * @returns Reward object. 25 | */ 26 | public getDaily< 27 | isRewardArray extends boolean = false 28 | >(reason?: string): RewardObject 29 | 30 | /** 31 | * Adds a work reward on user's balance. 32 | * @param reason The reason why the money was added. Default: 'claimed the work reward' 33 | * @returns Reward object. 34 | */ 35 | public getWork< 36 | isRewardArray extends boolean = true 37 | >(reason?: string): RewardObject 38 | 39 | /** 40 | * Adds a weekly reward on user's balance. 41 | * @param reason The reason why the money was added. Default: 'claimed the weekly reward' 42 | * @returns Reward object. 43 | */ 44 | public getWeekly< 45 | isRewardArray extends boolean = false 46 | >(reason?: string): RewardObject 47 | 48 | /** 49 | * Adds a monthly reward on user's balance 50 | * @param reason The reason why the money was added. Default: 'claimed the monthly reward' 51 | * @returns Reward object. 52 | */ 53 | public getMonthly< 54 | isRewardArray extends boolean = false 55 | >(memberID: string): RewardObject 56 | 57 | /** 58 | * Adds a hourly reward on user's balance 59 | * @param reason The reason why the money was added. Default: 'claimed the hourly reward' 60 | * @returns Reward object. 61 | */ 62 | public getHourly< 63 | isRewardArray extends boolean = false 64 | >(reason?: string): RewardObject 65 | } 66 | 67 | export = Rewards 68 | -------------------------------------------------------------------------------- /typings/classes/user/Inventory.d.ts: -------------------------------------------------------------------------------- 1 | import InventoryItem from '../InventoryItem' 2 | 3 | import EconomyConfiguration from '../../interfaces/EconomyConfiguration' 4 | import BaseManager from '../../managers/BaseManager' 5 | import DatabaseManager from '../../managers/DatabaseManager' 6 | 7 | 8 | declare class Inventory extends BaseManager> { 9 | public constructor(memberID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager) 10 | 11 | /** 12 | * Gets the item from user's inventory. 13 | * 14 | * This method is an alias for the `Inventory.findItem()` method. 15 | * @returns {InventoryItem} User's inventory item. 16 | */ 17 | public get(itemID: string | number): InventoryItem 18 | 19 | /** 20 | * Gets all the items in user's inventory. 21 | * 22 | * This method is an alias for 'EconomyUser.inventory.fetch' nethod. 23 | * @returns {InventoryItem[]} User's inventory array. 24 | */ 25 | public all(): InventoryItem[] 26 | 27 | /** 28 | * Uses the item: returns the item usage message and removes the item from user's inventory. 29 | * @param {string} itemID Item ID. 30 | * @param {any} [client] Discord Client. [Specify if the role will be given on a Discord server] 31 | * @returns {string} Item message or null if item not found. 32 | */ 33 | public use(itemID: string | number, client?: any): string 34 | 35 | /** 36 | * Adds the item from the shop to user's inventory. 37 | * @param {string} itemID Item ID. 38 | * @returns {boolean} If added successfully: true, else: false. 39 | */ 40 | public add(itemID: string | number): boolean 41 | 42 | /** 43 | * Removes the item from user's inventory. 44 | * @param {string} itemID Item ID. 45 | * @returns {boolean} If removed successfully: true, else: false. 46 | */ 47 | public removeItem(itemID: string | number): boolean 48 | 49 | /** 50 | * Clears the user's inventory. 51 | * @returns {boolean} If cleared: true, else: false. 52 | */ 53 | public clear(): boolean 54 | 55 | /** 56 | * Fetches the user's inventory. 57 | * @returns {InventoryItem[]} User's inventory array. 58 | */ 59 | public fetch(): InventoryItem[] 60 | 61 | /** 62 | * Gets the item from user's inventory. 63 | * @param {string} itemID Item ID. 64 | * @returns {InventoryItem} User's inventory item. 65 | */ 66 | public findItem(itemID: string | number): InventoryItem 67 | } 68 | 69 | export = Inventory -------------------------------------------------------------------------------- /mongodb/typings/classes/user/Rewards.d.ts: -------------------------------------------------------------------------------- 1 | import RewardObject from '../../interfaces/RewardObject' 2 | import { RewardType } from '../../interfaces/RewardTypes' 3 | 4 | import EconomyConfiguration from '../../interfaces/EconomyConfiguration' 5 | import DatabaseManager from '../../managers/DatabaseManager' 6 | 7 | 8 | declare class Rewards { 9 | public constructor(memberID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager) 10 | 11 | /** 12 | * Adds a specified reward on user's balance 13 | * @param reward Reward to give. 14 | * @param reason The reason why the money was added. 15 | * @returns Reward object. 16 | */ 17 | public receive< 18 | isRewardArray extends boolean = false 19 | >(reward: RewardType, reason?: string): Promise> 20 | 21 | /** 22 | * Adds a daily reward on user's balance. 23 | * @param reason The reason why the money was added. Default: 'claimed the daily reward' 24 | * @returns Reward object. 25 | */ 26 | public getDaily< 27 | isRewardArray extends boolean = false 28 | >(reason?: string): Promise> 29 | 30 | /** 31 | * Adds a work reward on user's balance. 32 | * @param reason The reason why the money was added. Default: 'claimed the work reward' 33 | * @returns Reward object. 34 | */ 35 | public getWork< 36 | isRewardArray extends boolean = true 37 | >(reason?: string): Promise> 38 | 39 | /** 40 | * Adds a weekly reward on user's balance. 41 | * @param reason The reason why the money was added. Default: 'claimed the weekly reward' 42 | * @returns Reward object. 43 | */ 44 | public getWeekly< 45 | isRewardArray extends boolean = false 46 | >(reason?: string): Promise> 47 | 48 | /** 49 | * Adds a monthly reward on user's balance 50 | * @param reason The reason why the money was added. Default: 'claimed the monthly reward' 51 | * @returns Reward object. 52 | */ 53 | public getMonthly< 54 | isRewardArray extends boolean = false 55 | >(memberID: string): Promise> 56 | 57 | /** 58 | * Adds a hourly reward on user's balance 59 | * @param reason The reason why the money was added. Default: 'claimed the hourly reward' 60 | * @returns Reward object. 61 | */ 62 | public getHourly< 63 | isRewardArray extends boolean = false 64 | >(reason?: string): Promise> 65 | } 66 | 67 | export = Rewards 68 | -------------------------------------------------------------------------------- /mongodb/typings/classes/user/Inventory.d.ts: -------------------------------------------------------------------------------- 1 | import InventoryItem from '../InventoryItem' 2 | 3 | import EconomyConfiguration from '../../interfaces/EconomyConfiguration' 4 | import BaseManager from '../../managers/BaseManager' 5 | import DatabaseManager from '../../managers/DatabaseManager' 6 | 7 | 8 | declare class Inventory extends BaseManager> { 9 | public constructor(memberID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager) 10 | 11 | /** 12 | * Gets the item from user's inventory. 13 | * 14 | * This method is an alias for the `Inventory.findItem()` method. 15 | * @returns {Promise} User's inventory item. 16 | */ 17 | public get(itemID: string | number): Promise> 18 | 19 | /** 20 | * Gets all the items in user's inventory. 21 | * @returns {Promise} User's inventory array. 22 | */ 23 | public all(): Promise[]> 24 | 25 | /** 26 | * Uses the item: returns the item usage message and removes the item from user's inventory. 27 | * @param {string} itemID Item ID. 28 | * @param {any} [client] Discord Client. [Specify if the role will be given on a Discord server] 29 | * @returns {Promise} Item message or null if item not found. 30 | */ 31 | public use(itemID: string | number, client?: any): Promise 32 | 33 | /** 34 | * Adds the item from the shop to user's inventory. 35 | * @param {string} itemID Item ID. 36 | * @returns {Promise} If added successfully: true, else: false. 37 | */ 38 | public add(itemID: string | number): Promise 39 | 40 | /** 41 | * Removes the item from user's inventory. 42 | * @param {string} itemID Item ID. 43 | * @returns {Promise} If removed successfully: true, else: false. 44 | */ 45 | public removeItem(itemID: string | number): Promise 46 | 47 | /** 48 | * Clears the user's inventory. 49 | * @returns {Promise} If cleared: true, else: false. 50 | */ 51 | public clear(): Promise 52 | 53 | /** 54 | * Fetches the user's inventory. 55 | * @returns {Promise} User's inventory array. 56 | */ 57 | public fetch(): Promise[]> 58 | 59 | /** 60 | * Gets the item from user's inventory. 61 | * @param {string} itemID Item ID. 62 | * @returns {InventoryItem} User's inventory item. 63 | */ 64 | public findItem(itemID: string | number): Promise> 65 | } 66 | 67 | export = Inventory -------------------------------------------------------------------------------- /EconomyItems.js: -------------------------------------------------------------------------------- 1 | // This file contains all the managers and classes Economy has (e.g. EconomyItems). 2 | // This file was generated automatically and it's not recommended to edit it yourself. 3 | 4 | // All of these items can be imported using: 5 | // `const { something } = require('discord-economy-super/EconomyItems')` 6 | 7 | // or in TypeScript (all the economy types and interfaces available): 8 | // `import { something } = from 'discord-economy-super/EconomyItems'` 9 | 10 | // Any of these items may be used in any way. Enjoy! 11 | 12 | // - shadowplay1 13 | 14 | 15 | module.exports = { 16 | Leaderboards: require('./src/classes/guild/Leaderboards'), 17 | Settings: require('./src/classes/guild/Settings'), 18 | Shop: require('./src/classes/guild/Shop'), 19 | Balance: require('./src/classes/user/Balance'), 20 | Bank: require('./src/classes/user/Bank'), 21 | Cooldowns: require('./src/classes/user/Cooldowns'), 22 | History: require('./src/classes/user/History'), 23 | Inventory: require('./src/classes/user/Inventory'), 24 | Items: require('./src/classes/user/Items'), 25 | Rewards: require('./src/classes/user/Rewards'), 26 | EconomyError: require('./src/classes/util/EconomyError'), 27 | Emitter: require('./src/classes/util/Emitter'), 28 | Logger: require('./src/classes/util/Logger'), 29 | Currency: require('./src/classes/Currency'), 30 | EconomyGuild: require('./src/classes/EconomyGuild'), 31 | EconomyUser: require('./src/classes/EconomyUser'), 32 | EmptyEconomyGuild: require('./src/classes/EmptyEconomyGuild'), 33 | EmptyEconomyUser: require('./src/classes/EmptyEconomyUser'), 34 | HistoryItem: require('./src/classes/HistoryItem'), 35 | InventoryItem: require('./src/classes/InventoryItem'), 36 | ShopItem: require('./src/classes/ShopItem'), 37 | BalanceManager: require('./src/managers/BalanceManager'), 38 | BankManager: require('./src/managers/BankManager'), 39 | BaseManager: require('./src/managers/BaseManager'), 40 | CooldownManager: require('./src/managers/CooldownManager'), 41 | CurrencyManager: require('./src/managers/CurrencyManager'), 42 | DatabaseManager: require('./src/managers/DatabaseManager'), 43 | FetchManager: require('./src/managers/FetchManager'), 44 | GuildManager: require('./src/managers/GuildManager'), 45 | HistoryManager: require('./src/managers/HistoryManager'), 46 | InventoryManager: require('./src/managers/InventoryManager'), 47 | RewardManager: require('./src/managers/RewardManager'), 48 | SettingsManager: require('./src/managers/SettingsManager'), 49 | ShopManager: require('./src/managers/ShopManager'), 50 | UserManager: require('./src/managers/UserManager'), 51 | UtilsManager: require('./src/managers/UtilsManager'), 52 | 53 | } 54 | -------------------------------------------------------------------------------- /typings/classes/guild/Settings.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../../interfaces/EconomyConfiguration' 2 | 3 | import SettingsTypes from '../../interfaces/SettingsTypes' 4 | import SettingValueType from '../../interfaces/SettingValueType' 5 | 6 | 7 | declare class Settings { 8 | public constructor(guildID: string, options: EconomyConfiguration) 9 | 10 | /** 11 | * Gets the specified setting from the database. 12 | * 13 | * Note: If the server don't have any setting specified, 14 | * the module will take the values from the 15 | * specified configuration or default configuration. 16 | * 17 | * @param {T} key The setting to fetch. 18 | * @returns {SettingValueType} The setting from the database. 19 | */ 20 | public get(key: T): SettingValueType 21 | 22 | /** 23 | * Changes the specified setting. 24 | * 25 | * Note: If the server don't have any setting specified, 26 | * the module will take the values from the 27 | * specified configuration or default configuration. 28 | * 29 | * @param {T} key The setting to change. 30 | * @param {SettingValueType} value The value to set. 31 | * @returns {SettingsTypes} The server settings object. 32 | */ 33 | public set(key: T, value: SettingValueType): SettingsTypes 34 | 35 | /** 36 | * Deletes the specified setting from the guild. 37 | * 38 | * Note: If the server don't have any setting specified, 39 | * the module will take the values from the 40 | * specified configuration or default configuration. 41 | * 42 | * @param {Settings} key The setting to delete. 43 | * @returns {SettingsTypes} The server settings object. 44 | */ 45 | public delete(key: keyof SettingsTypes): SettingsTypes 46 | 47 | /** 48 | * Deletes the specified setting from the guild. 49 | * 50 | * Note: If the server don't have any setting specified, 51 | * the module will take the values from the 52 | * specified configuration or default configuration. 53 | * 54 | * This method is an alias for `Settings.delete()` method. 55 | * 56 | * @param {Settings} key The setting to delete. 57 | * @returns {SettingsTypes} The server settings object. 58 | */ 59 | public remove(key: keyof SettingsTypes): SettingsTypes 60 | 61 | /** 62 | * Fetches the server's settings object. 63 | * @returns {SettingsTypes} The server settings object. 64 | */ 65 | public all(): SettingsTypes 66 | 67 | /** 68 | * Resets all the settings to setting that are in configuration. 69 | * @returns {SettingsTypes} The server settings object. 70 | */ 71 | public reset(): SettingsTypes 72 | } 73 | 74 | export = Settings -------------------------------------------------------------------------------- /typings/classes/user/History.d.ts: -------------------------------------------------------------------------------- 1 | import HistoryItem from '../HistoryItem' 2 | 3 | import EconomyConfiguration from '../../interfaces/EconomyConfiguration' 4 | import BaseManager from '../../managers/BaseManager' 5 | import DatabaseManager from '../../managers/DatabaseManager' 6 | 7 | 8 | declare class History extends BaseManager> { 9 | public constructor(memberID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager) 10 | 11 | /** 12 | * Gets all the items in user's purchases history. 13 | * 14 | * This method is an alias for the `History.all()` method. 15 | * @returns {HistoryItem} User's history item. 16 | */ 17 | public get(): HistoryItem[] 18 | 19 | /** 20 | * Gets all the items in user's purchases history. 21 | * @returns {HistoryItem[]} User's purchases history. 22 | */ 23 | public all(): HistoryItem[] 24 | 25 | /** 26 | * Adds the item from the shop to the purchases history. 27 | * @param {string} itemID Shop item ID. 28 | * 29 | * @param {Maybe} [currency=null] 30 | * The currency (ID, name or symbol) that was used for the purchase. 31 | * Can be omitted by specifying 'null' or ignoring this parameter. Default: null. 32 | * 33 | * @returns {boolean} If added: true, else: false. 34 | */ 35 | public add(itemID: string | number, currency?: Maybe): boolean 36 | 37 | /** 38 | * Removes the specified item from purchases history. 39 | * @param {string} id History item ID. 40 | * @returns {boolean} If removed: true, else: false. 41 | */ 42 | public remove(id: string): boolean 43 | 44 | /** 45 | * Removes the specified item from purchases history. 46 | * 47 | * This method is an alias for `EconomyUser.history.remove()` method. 48 | * @param {string} id History item ID. 49 | * @returns {boolean} If removed: true, else: false. 50 | */ 51 | public delete(id: string): boolean 52 | 53 | /** 54 | * Clears the user's purchases history. 55 | * @returns {boolean} If cleared: true, else: false. 56 | */ 57 | public clear(): boolean 58 | 59 | /** 60 | * Gets the specified item from history. 61 | * @param {string | number} id History item ID. 62 | * @returns {HistoryItem} Purchases history item. 63 | */ 64 | public findItem(id: string | number): HistoryItem 65 | 66 | /** 67 | * Gets the specified item from history. 68 | * @param {string | number} id History item ID. 69 | * @returns {HistoryItem} Purchases history item. 70 | */ 71 | public getItem(id: string | number): HistoryItem 72 | } 73 | 74 | export = History -------------------------------------------------------------------------------- /typings/interfaces/EconomyEvents.d.ts: -------------------------------------------------------------------------------- 1 | import BalanceData from './BalanceData' 2 | 3 | import ItemData from './ItemData' 4 | import EditedItemData from './EditedItemData' 5 | 6 | import ItemUseData from './ItemUseData' 7 | import ItemBuyData from './ItemBuyData' 8 | 9 | import Currency from '../classes/Currency' 10 | import Economy from '../Economy' 11 | 12 | 13 | /** 14 | * Economy events. 15 | */ 16 | declare interface EconomyEvents { 17 | 18 | /** 19 | * Emits when someone's set the money on the balance. 20 | */ 21 | balanceSet: BalanceData<'balanceSet'> 22 | 23 | /** 24 | * Emits when someone's added the money on the balance. 25 | */ 26 | balanceAdd: BalanceData<'balanceAdd'> 27 | 28 | /** 29 | * Emits when someone's subtracts the money from the balance. 30 | */ 31 | balanceSubtract: BalanceData<'balanceSubtract'> 32 | 33 | /** 34 | * Emits when someone's set the money on the bank balance. 35 | */ 36 | bankSet: BalanceData<'bankSet'> 37 | 38 | /** 39 | * Emits when someone's added the money on the bank balance. 40 | */ 41 | bankAdd: BalanceData<'bankAdd'> 42 | 43 | /** 44 | * Emits when someone's subtracted the money from the bank balance. 45 | */ 46 | bankSubtract: BalanceData<'balanceSubtract'> 47 | 48 | /** 49 | * Emits when someone's custom currency was set. 50 | */ 51 | customCurrencySet: BalanceData<'customCurrencySet'> & { 52 | currency: Currency 53 | } 54 | 55 | /** 56 | * Emits when someone's custom currency was added. 57 | */ 58 | customCurrencyAdd: BalanceData<'customCurrencyAdd'> & { 59 | currency: Currency 60 | } 61 | 62 | /** 63 | * Emits when someone's custom currency was subtracted. 64 | */ 65 | customCurrencySubtract: BalanceData<'customCurrencySubtract'> & { 66 | currency: Currency 67 | } 68 | 69 | /** 70 | * Emits when someone's added an item in the shop. 71 | */ 72 | shopItemAdd: ItemData 73 | 74 | /** 75 | * Emits when someone's cleared the shop. 76 | */ 77 | shopClear: boolean 78 | 79 | /** 80 | * Emits when someone's edited an item in the shop. 81 | */ 82 | shopItemEdit: EditedItemData 83 | 84 | /** 85 | * Emits when someone's bought an item from the shop. 86 | */ 87 | shopItemBuy: ItemBuyData 88 | 89 | /** 90 | * Emits when someone's used the item from their inventory. 91 | */ 92 | shopItemUse: ItemUseData 93 | 94 | /** 95 | * Emits when the module is ready. 96 | */ 97 | ready: Economy 98 | 99 | /** 100 | * Emits when the module is destroyed. 101 | */ 102 | destroy: void 103 | } 104 | 105 | export = EconomyEvents 106 | -------------------------------------------------------------------------------- /mongodb/typings/interfaces/EconomyEvents.d.ts: -------------------------------------------------------------------------------- 1 | import BalanceData from './BalanceData' 2 | 3 | import ItemData from './ItemData' 4 | import EditedItemData from './EditedItemData' 5 | 6 | import ItemUseData from './ItemUseData' 7 | import ItemBuyData from './ItemBuyData' 8 | 9 | import Currency from '../classes/Currency' 10 | import Economy from '../Economy' 11 | 12 | 13 | /** 14 | * Economy events. 15 | */ 16 | declare interface EconomyEvents { 17 | 18 | /** 19 | * Emits when someone's set the money on the balance. 20 | */ 21 | balanceSet: BalanceData<'balanceSet'> 22 | 23 | /** 24 | * Emits when someone's added the money on the balance. 25 | */ 26 | balanceAdd: BalanceData<'balanceAdd'> 27 | 28 | /** 29 | * Emits when someone's subtracts the money from the balance. 30 | */ 31 | balanceSubtract: BalanceData<'balanceSubtract'> 32 | 33 | /** 34 | * Emits when someone's set the money on the bank balance. 35 | */ 36 | bankSet: BalanceData<'bankSet'> 37 | 38 | /** 39 | * Emits when someone's added the money on the bank balance. 40 | */ 41 | bankAdd: BalanceData<'bankAdd'> 42 | 43 | /** 44 | * Emits when someone's subtracted the money from the bank balance. 45 | */ 46 | bankSubtract: BalanceData<'balanceSubtract'> 47 | 48 | /** 49 | * Emits when someone's custom currency was set 50 | */ 51 | customCurrencySet: BalanceData<'customCurrencySet'> & { 52 | currency: Currency 53 | } 54 | 55 | /** 56 | * Emits when someone's custom currency was added. 57 | */ 58 | customCurrencyAdd: BalanceData<'customCurrencyAdd'> & { 59 | currency: Currency 60 | } 61 | 62 | /** 63 | * Emits when someone's custom currency was subtracted. 64 | */ 65 | customCurrencySubtract: BalanceData<'customCurrencySubtract'> & { 66 | currency: Currency 67 | } 68 | 69 | /** 70 | * Emits when someone's added an item in the shop. 71 | */ 72 | shopItemAdd: ItemData 73 | 74 | /** 75 | * Emits when someone's cleared the shop. 76 | */ 77 | shopClear: boolean 78 | 79 | /** 80 | * Emits when someone's edited an item in the shop. 81 | */ 82 | shopItemEdit: EditedItemData 83 | 84 | /** 85 | * Emits when someone's bought an item from the shop. 86 | */ 87 | shopItemBuy: ItemBuyData 88 | 89 | /** 90 | * Emits when someone's used the item from their inventory. 91 | */ 92 | shopItemUse: ItemUseData 93 | 94 | /** 95 | * Emits when the module is ready. 96 | */ 97 | ready: Economy 98 | 99 | /** 100 | * Emits when the module is destroyed. 101 | */ 102 | destroy: void 103 | } 104 | 105 | export = EconomyEvents 106 | -------------------------------------------------------------------------------- /typings/classes/EconomyGuild.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 2 | 3 | import DatabaseManager from '../managers/DatabaseManager' 4 | import UtilsManager from '../managers/UtilsManager' 5 | 6 | import ShopManager from '../managers/ShopManager' 7 | import UserManager from '../managers/UserManager' 8 | 9 | import Shop from './guild/Shop' 10 | import Leaderboards from './guild/Leaderboards' 11 | 12 | import Settings from './guild/Settings' 13 | 14 | import EconomyUser from './EconomyUser' 15 | 16 | 17 | declare class EconomyGuild { 18 | 19 | /** 20 | * Economy guild class. 21 | * @param {string} id Guild ID. 22 | * @param {EconomyConfiguration} ecoOptions Economy configuration. 23 | * @param {any} guildObject Economy guild object. 24 | */ 25 | public constructor(id: string, ecoOptions: EconomyConfiguration, guildObject: any) 26 | 27 | 28 | /** 29 | * Guild user manager. 30 | */ 31 | public users: UserManager 32 | 33 | /** 34 | * Determine if the guild exists in the database. 35 | * @type {boolean} 36 | */ 37 | public exists: boolean 38 | 39 | /** 40 | * Guild ID. 41 | */ 42 | public id: string 43 | 44 | /** 45 | * Full path to a JSON file. Default: './storage.json' 46 | * @private 47 | */ 48 | private storagePath: string 49 | 50 | /** 51 | * Database Manager. 52 | * @private 53 | */ 54 | private database: DatabaseManager 55 | 56 | /** 57 | * Utils Manager. 58 | * @private 59 | */ 60 | private utils: UtilsManager 61 | 62 | /** 63 | * Shop Manager. 64 | * @private 65 | */ 66 | private _shop: ShopManager 67 | 68 | /** 69 | * Guild Shop. 70 | */ 71 | public shop: Shop 72 | 73 | /** 74 | * Guild Leaderboards. 75 | */ 76 | public leaderboards: Leaderboards 77 | 78 | /** 79 | * Guild Settings. 80 | */ 81 | public settings: Settings 82 | 83 | 84 | /** 85 | * Deletes the guild from database. 86 | * @returns {EconomyGuild} Deleted guild object. 87 | */ 88 | public delete(): EconomyGuild 89 | 90 | /** 91 | * Sets the default guild object for the specified member. 92 | * @returns {boolean} If reset successfully: true; else: false. 93 | */ 94 | public reset(): boolean 95 | 96 | /** 97 | * Creates an economy guild object in database. 98 | * @returns {boolean} If created successfully: true; else: false. 99 | */ 100 | public create(): boolean 101 | 102 | /** 103 | * Converts the economy guild to string. 104 | * @returns {string} String representation of economy guild. 105 | */ 106 | public toString(): string 107 | } 108 | 109 | export = EconomyGuild 110 | -------------------------------------------------------------------------------- /mongodb/typings/classes/user/History.d.ts: -------------------------------------------------------------------------------- 1 | import HistoryItem from '../HistoryItem' 2 | 3 | import EconomyConfiguration from '../../interfaces/EconomyConfiguration' 4 | import BaseManager from '../../managers/BaseManager' 5 | import DatabaseManager from '../../managers/DatabaseManager' 6 | 7 | 8 | declare class History extends BaseManager> { 9 | public constructor(memberID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager) 10 | 11 | /** 12 | * Gets all the items in user's purchases history. 13 | * 14 | * This method is an alias for the `History.all()` method. 15 | * @returns {Promise} User's history item. 16 | */ 17 | public get(): Promise[]> 18 | 19 | /** 20 | * Gets all the items in user's purchases history. 21 | * @returns {Promise} User's purchases history. 22 | */ 23 | public all(): Promise[]> 24 | 25 | /** 26 | * Adds the item from the shop to the purchases history. 27 | * @param {string} itemID Shop item ID. 28 | * 29 | * @param {Maybe} [currency=null] 30 | * The currency (ID, name or symbol) that was used for the purchase. 31 | * Can be omitted by specifying 'null' or ignoring this parameter. Default: null. 32 | * 33 | * @returns {Promise} If added: true, else: false. 34 | */ 35 | public add(itemID: string | number, currency?: Maybe): Promise 36 | 37 | /** 38 | * Removes the specified item from purchases history. 39 | * @param {string} id History item ID. 40 | * @returns {Promise} If removed: true, else: false. 41 | */ 42 | public remove(id: string): Promise 43 | 44 | /** 45 | * Removes the specified item from purchases history. 46 | * 47 | * This method is an alias for `EconomyUser.history.remove()` method. 48 | * @param {string} id History item ID. 49 | * @returns {Promise} If removed: true, else: false. 50 | */ 51 | public delete(id: string): Promise 52 | 53 | /** 54 | * Clears the user's purchases history. 55 | * @returns {Promise} If cleared: true, else: false. 56 | */ 57 | public clear(): Promise 58 | 59 | /** 60 | * Gets the specified item from history. 61 | * @param {string | number} id History item ID. 62 | * @returns {Promise} Purchases history item. 63 | */ 64 | public findItem(id: string | number): Promise> 65 | 66 | /** 67 | * Gets the specified item from history. 68 | * @param {string | number} id History item ID. 69 | * @returns {Promise} Purchases history item. 70 | */ 71 | public getItem(id: string | number): Promise> 72 | } 73 | 74 | export = History -------------------------------------------------------------------------------- /typings/managers/BankManager.d.ts: -------------------------------------------------------------------------------- 1 | import Emitter from '../classes/util/Emitter' 2 | 3 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 4 | import LeaderboardData from '../interfaces/LeaderboardData' 5 | 6 | /** 7 | * Bank balance manager methods class. 8 | * @extends {Emitter} 9 | */ 10 | declare class BankManager extends Emitter { 11 | public constructor(options: EconomyConfiguration) 12 | 13 | /** 14 | * Fetches the user's bank balance. 15 | * @param {string} memberID Member ID. 16 | * @param {string} guildID Guild ID. 17 | * @returns User's bank balance 18 | */ 19 | public fetch(memberID: string, guildID: string): number 20 | 21 | /** 22 | * Gets the user's bank balance. 23 | * 24 | * This method is an alias for the `BankManager.fetch()` method. 25 | * @param {string} memberID Member ID. 26 | * @param {string} guildID Guild ID. 27 | * @returns User's bank balance 28 | */ 29 | public get(memberID: string, guildID: string): number 30 | 31 | /** 32 | * Sets the money amount on user's bank balance. 33 | * @param {number} amount Amount of money that you want to set 34 | * @param {string} memberID Member ID. 35 | * @param {string} guildID Guild ID. 36 | * @param {string} [reason] The reason why you set the money 37 | * @returns Money amount 38 | */ 39 | public set(amount: number, memberID: string, guildID: string, reason?: string): number 40 | 41 | /** 42 | * Adds the money amount on user's bank balance. 43 | * @param {number} amount Amount of money that you want to add 44 | * @param {string} memberID Member ID. 45 | * @param {string} guildID Guild ID. 46 | * @param {string} [reason] The reason why you add the money 47 | * @returns Money amount 48 | */ 49 | public add(amount: number, memberID: string, guildID: string, reason?: string): number 50 | 51 | /** 52 | * Subtracts the money amount from user's bank balance. 53 | * @param {number} amount Amount of money that you want to subtract 54 | * @param {string} memberID Member ID. 55 | * @param {string} guildID Guild ID. 56 | * @param {string} [reason] The reason why you subtract the money 57 | * @returns Money amount 58 | */ 59 | public subtract(amount: number, memberID: string, guildID: string, reason?: string): number 60 | 61 | /** 62 | * Withdraws the specified amount of money. 63 | * @param {number} amount Money amount. 64 | * @param {string} memberID Member ID. 65 | * @param {string} guildID Guild ID. 66 | * @param {string} [reason] The reason of the operation. 67 | * @returns {number} Money amount. 68 | */ 69 | public withdraw(amount: number, memberID: string, guildID: string, reason?: string): number 70 | 71 | /** 72 | * Gets a bank balance leaderboard for your server 73 | * @param {string} guildID Guild ID. 74 | * @returns Sorted leaderboard array 75 | */ 76 | public leaderboard(guildID: string): LeaderboardData[] 77 | } 78 | 79 | export = BankManager -------------------------------------------------------------------------------- /mongodb/typings/cached/CachedItems.d.ts: -------------------------------------------------------------------------------- 1 | import CacheManager from '../managers/CacheManager' 2 | import DatabaseManager from '../managers/DatabaseManager' 3 | 4 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 5 | 6 | import CachedItem from './CachedItem' 7 | 8 | import EconomyGuild from '../classes/EconomyGuild' 9 | import EmptyEconomyGuild from '../classes/EmptyEconomyGuild' 10 | 11 | import EconomyUser from '../classes/EconomyUser' 12 | import EmptyEconomyUser from '../classes/EmptyEconomyUser' 13 | 14 | 15 | import CooldownItem from '../classes/CooldownItem' 16 | 17 | import BalanceItem from '../classes/BalanceItem' 18 | import BankBalanceItem from '../classes/BankBalanceItem' 19 | 20 | import ShopItem from '../classes/ShopItem' 21 | import InventoryItem from '../classes/InventoryItem' 22 | import HistoryItem from '../classes/HistoryItem' 23 | 24 | import Currency from '../classes/Currency' 25 | 26 | export class CachedGuilds extends CachedItem { 27 | public constructor(guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager) 28 | } 29 | 30 | export class CachedUsers extends CachedItem { 31 | public constructor(userID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager) 32 | } 33 | 34 | export class CachedCooldowns extends CachedItem { 35 | public constructor(userID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager) 36 | } 37 | 38 | export class CachedBalance extends CachedItem { 39 | public constructor(userID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager) 40 | } 41 | 42 | export class CachedBank extends CachedItem { 43 | public constructor(userID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager) 44 | } 45 | 46 | export class CachedCurrency extends CachedItem { 47 | public constructor(currencyID: number, guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager) 48 | } 49 | 50 | export class CachedShop extends CachedItem { 51 | public constructor(guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager) 52 | } 53 | 54 | export class CachedInventory extends CachedItem { 55 | public constructor(userID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager) 56 | } 57 | 58 | export class CachedHistory extends CachedItem { 59 | public constructor(userID: string, guildID: string, options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager) 60 | } 61 | -------------------------------------------------------------------------------- /mongodb/EconomyItems.js: -------------------------------------------------------------------------------- 1 | // This file contains all the managers and classes Economy has (e.g. EconomyItems). 2 | // This file was generated automatically and it's not recommended to edit it yourself. 3 | 4 | // All of these items can be imported using: 5 | // `const { something } = require('discord-economy-super/mongodb/EconomyItems')` 6 | 7 | // or in TypeScript (all the economy types and interfaces available): 8 | // `import { something } = from 'discord-economy-super/mongodb/EconomyItems'` 9 | 10 | // Any of these items may be used in any way. Enjoy! 11 | 12 | // - shadowplay1 13 | 14 | 15 | module.exports = { 16 | Leaderboards: require('./src/classes/guild/Leaderboards'), 17 | Settings: require('./src/classes/guild/Settings'), 18 | Shop: require('./src/classes/guild/Shop'), 19 | Balance: require('./src/classes/user/Balance'), 20 | Bank: require('./src/classes/user/Bank'), 21 | Cooldowns: require('./src/classes/user/Cooldowns'), 22 | History: require('./src/classes/user/History'), 23 | Inventory: require('./src/classes/user/Inventory'), 24 | Items: require('./src/classes/user/Items'), 25 | Rewards: require('./src/classes/user/Rewards'), 26 | EconomyError: require('./src/classes/util/EconomyError'), 27 | Emitter: require('./src/classes/util/Emitter'), 28 | Logger: require('./src/classes/util/Logger'), 29 | Currency: require('./src/classes/Currency'), 30 | EconomyGuild: require('./src/classes/EconomyGuild'), 31 | EconomyUser: require('./src/classes/EconomyUser'), 32 | EmptyEconomyGuild: require('./src/classes/EmptyEconomyGuild'), 33 | EmptyEconomyUser: require('./src/classes/EmptyEconomyUser'), 34 | HistoryItem: require('./src/classes/HistoryItem'), 35 | InventoryItem: require('./src/classes/InventoryItem'), 36 | ShopItem: require('./src/classes/ShopItem'), 37 | BalanceManager: require('./src/managers/BalanceManager'), 38 | BankManager: require('./src/managers/BankManager'), 39 | BaseManager: require('./src/managers/BaseManager'), 40 | CooldownManager: require('./src/managers/CooldownManager'), 41 | CurrencyManager: require('./src/managers/CurrencyManager'), 42 | DatabaseManager: require('./src/managers/DatabaseManager'), 43 | FetchManager: require('./src/managers/FetchManager'), 44 | GuildManager: require('./src/managers/GuildManager'), 45 | HistoryManager: require('./src/managers/HistoryManager'), 46 | InventoryManager: require('./src/managers/InventoryManager'), 47 | RewardManager: require('./src/managers/RewardManager'), 48 | SettingsManager: require('./src/managers/SettingsManager'), 49 | ShopManager: require('./src/managers/ShopManager'), 50 | UserManager: require('./src/managers/UserManager'), 51 | UtilsManager: require('./src/managers/UtilsManager'), 52 | BalanceItem: require('./src/classes/BalanceItem'), 53 | BankBalanceItem: require('./src/classes/BankBalanceItem'), 54 | CooldownItem: require('./src/classes/CooldownItem'), 55 | CachedItem: require('./src/cached/CachedItem'), 56 | CachedItems: require('./src/cached/CachedItems') 57 | } 58 | -------------------------------------------------------------------------------- /src/classes/util/EconomyError.js: -------------------------------------------------------------------------------- 1 | const errors = require('../../structures/errors') 2 | 3 | const errorCodes = [ 4 | 'INVALID_TYPE', 5 | 'UNKNOWN_ERROR', 6 | 'PARAMETER_NOT_SPECIFIED', 7 | 'ITEM_PROPERTY_INVALID', 8 | 'INVALID_INPUT', 9 | 'OLD_NODE_VERSION', 10 | 'NO_DISCORD_CLIENT', 11 | 'ROLE_NOT_FOUND', 12 | 'PURCHASES_HISTORY_DISABLED', 13 | 'SETTINGS_KEY_INVALID', 14 | 'READONLY_PROPERTY', 15 | 'INVALID_PROPERTY', 16 | 'CURRENCY_NOT_FOUND', 17 | 'INVALID_ERROR_CODE', 18 | 'MODULE_NOT_READY', 19 | 'STORAGE_FILE_ERROR' 20 | ] 21 | 22 | /** 23 | * EconomyError class. 24 | * @extends {Error} 25 | */ 26 | class EconomyError extends Error { 27 | 28 | /** 29 | * Creates an 'EconomyError' instance. 30 | * @param {string | Error} errorMessage Error message. 31 | * @param {'INVALID_TYPE' | 32 | * 'UNKNOWN_ERROR' | 33 | * 'PARAMETER_NOT_SPECIFIED' | 34 | * 'OLD_NODE_VERSION' | 35 | * 'ITEM_PROPERTY_INVALID' | 36 | * 'INVALID_INPUT' | 37 | * 'NO_DISCORD_CLIENT' | 38 | * 'ROLE_NOT_FOUND' | 39 | * 'PURCHASES_HISTORY_DISABLED' | 40 | * 'SETTINGS_KEY_INVALID' | 41 | * 'READONLY_PROPERTY' | 42 | * 'INVALID_PROPERTY' | 43 | * 'CURRENCY_NOT_FOUND' | 44 | * 'INVALID_ERROR_CODE' | 45 | * 'MODULE_NOT_READY' | 46 | * 'STORAGE_FILE_ERROR'} code Error code. 47 | */ 48 | constructor(errorMessage = '', code = '') { 49 | if (errorMessage instanceof Error == 'Error') { 50 | super(errorMessage.errorMessage) 51 | Error.captureStackTrace(this, this.constructor) 52 | } 53 | 54 | else if (typeof errorMessage == 'string') { 55 | super(errorMessage || 'Unknown Error.') 56 | } 57 | 58 | else { 59 | code = 'UNKNOWN_ERROR' 60 | super('Unknown Error.') 61 | } 62 | 63 | if (!errorMessage) { 64 | code = 'UNKNOWN_ERROR' 65 | } 66 | 67 | if (code && !errorCodes.includes(code)) { 68 | throw new EconomyError(errors.invalidErrorCode, 'INVALID_ERROR_CODE') 69 | } 70 | 71 | /** 72 | * Error code. 73 | * @type {'INVALID_TYPE' | 74 | * 'UNKNOWN_ERROR' | 75 | * 'PARAMETER_NOT_SPECIFIED' | 76 | * 'OLD_NODE_VERSION' | 77 | * 'ITEM_PROPERTY_INVALID' | 78 | * 'INVALID_INPUT' | 79 | * 'NO_DISCORD_CLIENT' | 80 | * 'ROLE_NOT_FOUND' | 81 | * 'PURCHASES_HISTORY_DISABLED' | 82 | * 'SETTINGS_KEY_INVALID' | 83 | * 'READONLY_PROPERTY' | 84 | * 'INVALID_PROPERTY' | 85 | * 'CURRENCY_NOT_FOUND' | 86 | * 'INVALID_ERROR_CODE' | 87 | * 'MODULE_NOT_READY' | 88 | * 'STORAGE_FILE_ERROR'} 89 | */ 90 | this.code = code 91 | 92 | /** 93 | * Error name. 94 | * @type {string} 95 | */ 96 | this.name = `EconomyError${code ? ` [${code}]` : ''}` 97 | 98 | } 99 | } 100 | 101 | /** 102 | * EconomyError class. 103 | * @type {EconomyError} 104 | */ 105 | module.exports = EconomyError 106 | -------------------------------------------------------------------------------- /typings/managers/SettingsManager.d.ts: -------------------------------------------------------------------------------- 1 | import DatabaseManager from './DatabaseManager' 2 | 3 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 4 | 5 | import SettingsTypes from '../interfaces/SettingsTypes' 6 | import SettingValueType from '../interfaces/SettingValueType' 7 | 8 | declare class SettingsManager { 9 | public constructor(options: EconomyConfiguration, database: DatabaseManager) 10 | 11 | /** 12 | * Gets the specified setting from the database. 13 | * 14 | * Note: If the server don't have any setting specified, 15 | * the module will take the values from the 16 | * specified configuration or default configuration. 17 | * 18 | * @param {T} key The setting to fetch. 19 | * @param {string} guildID Guild ID. 20 | * @returns {SettingValueType} The setting from the database. 21 | */ 22 | public get(key: T, guildID: string): SettingValueType 23 | 24 | /** 25 | * Changes the specified setting. 26 | * 27 | * Note: If the server don't have any setting specified, 28 | * the module will take the values from the 29 | * specified configuration or default configuration. 30 | * 31 | * @param {T} key The setting to change. 32 | * @param {SettingValueType} value The value to set. 33 | * @param {string} guildID Guild ID. 34 | * @returns {SettingsTypes} The server settings object. 35 | */ 36 | public set(key: T, value: SettingValueType, guildID: string): SettingsTypes 37 | 38 | /** 39 | * Deletes the specified setting. 40 | * 41 | * Note: If the server don't have any setting specified, 42 | * the module will take the values from the 43 | * specified configuration or default configuration. 44 | * 45 | * @param {keyof SettingsTypes} key The setting to delete. 46 | * @param {string} guildID Guild ID. 47 | * @returns {SettingsTypes} The server settings object. 48 | */ 49 | public delete(key: keyof SettingsTypes, guildID: string): SettingsTypes 50 | 51 | /** 52 | * Deletes the specified setting. 53 | * 54 | * Note: If the server don't have any setting specified, 55 | * the module will take the values from the 56 | * specified configuration or default configuration. 57 | * 58 | * This method is an alias for `SettingsManager.delete()` method. 59 | * 60 | * @param {keyof SettingsTypes} key The setting to delete. 61 | * @param {string} guildID Guild ID. 62 | * @returns {SettingsTypes} The server settings object. 63 | */ 64 | public remove(key: keyof SettingsTypes, guildID: string): SettingsTypes 65 | 66 | /** 67 | * Fetches the server's settings object. 68 | * @param {string} guildID Guild ID. 69 | * @returns {SettingsTypes} The server settings object. 70 | */ 71 | public all(guildID: string): SettingsTypes 72 | 73 | /** 74 | * Resets all the settings to setting that are in configuration. 75 | * @param {string} guildID Guild ID. 76 | * @returns {SettingsTypes} The server settings object. 77 | */ 78 | public reset(guildID: string): SettingsTypes 79 | } 80 | 81 | export = SettingsManager -------------------------------------------------------------------------------- /typings/classes/user/Cooldowns.d.ts: -------------------------------------------------------------------------------- 1 | import RewardCooldownData from '../../interfaces/RewardCooldownData' 2 | import { RewardType } from '../../interfaces/RewardTypes' 3 | 4 | import RawEconomyUser from '../../interfaces/RawEconomyUser' 5 | import EconomyConfiguration from '../../interfaces/EconomyConfiguration' 6 | import DatabaseManager from '../../managers/DatabaseManager' 7 | 8 | 9 | declare class Cooldowns { 10 | 11 | /** 12 | * Cooldowns class. 13 | * @param {RawEconomyUser} userObject User object from database. 14 | * @param {EconomyConfiguration} options Economy configuration. 15 | * @param {DatabaseManager} database Database Manager. 16 | */ 17 | public constructor( 18 | userObject: RawEconomyUser, 19 | options: EconomyConfiguration, 20 | database: DatabaseManager 21 | ) 22 | 23 | /** 24 | * Returns the cooldown of the specified type. 25 | * @param type Cooldown type. 26 | * @returns Cooldown object. 27 | */ 28 | public getCooldown(type: RewardType): RewardCooldownData 29 | 30 | /** 31 | * Gets user's daily cooldown. 32 | * @returns User's daily cooldown object. 33 | */ 34 | public getDaily(): RewardCooldownData 35 | 36 | /** 37 | * Gets user's work cooldown. 38 | * @returns User's work cooldown object. 39 | */ 40 | public getWork(): RewardCooldownData 41 | 42 | /** 43 | * Gets user's weekly cooldown. 44 | * @returns User's weekly cooldown object. 45 | */ 46 | public getWeekly(): RewardCooldownData 47 | 48 | /** 49 | * Gets user's monthly cooldown. 50 | * @returns User's monthly cooldown object. 51 | */ 52 | public getMonthly(): RewardCooldownData 53 | 54 | /** 55 | * Gets user's hourly cooldown. 56 | * @returns User's hourly cooldown object. 57 | */ 58 | public getHourly(): RewardCooldownData 59 | 60 | /** 61 | * Clears all the user's cooldowns. 62 | * @returns {boolean} If all cooldowns were cleared successfully: true, else: false. 63 | */ 64 | public clearAll(): boolean 65 | 66 | /** 67 | * Clears user's daily cooldown. 68 | * @returns {boolean} If cleared: true; else: false. 69 | */ 70 | public clearDaily(): boolean 71 | 72 | /** 73 | * Clears user's work cooldown. 74 | * @returns {boolean} If cleared: true; else: false. 75 | */ 76 | public clearWork(): boolean 77 | 78 | /** 79 | * Clears user's weekly cooldown. 80 | * @returns {boolean} If cleared: true; else: false. 81 | */ 82 | public clearWeekly(): boolean 83 | 84 | /** 85 | * Clears user's monthly cooldown. 86 | * @returns {boolean} If cleared: true; else: false. 87 | */ 88 | public clearMonthly(): boolean 89 | 90 | /** 91 | * Clears user's hourly cooldown. 92 | * @returns {boolean} If cleared: true; else: false. 93 | */ 94 | public clearHourly(): boolean 95 | 96 | /** 97 | * Gets all user's cooldowns 98 | * @returns User's cooldowns object. 99 | */ 100 | public getAll(): Record<'daily' | 'work' | 'weekly' | 'monthly' | 'hourly', RewardCooldownData> 101 | } 102 | 103 | export = Cooldowns -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Discord Economy Super 2 | 3 | [![Downloads](https://img.shields.io/npm/dt/discord-economy-super?style=for-the-badge)](https://www.npmjs.com/package/discord-economy-super) 4 | [![Stable Version](https://img.shields.io/npm/v/discord-economy-super?style=for-the-badge)](https://www.npmjs.com/package/discord-economy-super) 5 | [![Build Status](https://github.com/shadowplay1/discord-economy-super/workflows/build/badge.svg)](https://www.npmjs.com/package/discord-economy-super) 6 | 7 | Discord Economy Super - Easy and customizable economy module for your [Discord Bot](https://discord.js.org/#/). 8 | 9 | ## ❓ | Why? 10 |
    11 |
  • Clean TypeScript Defenitions 📘
  • 12 |
  • MongoDB Support 🍃
  • 13 |
  • Flexible and Customizable ⚙️
  • 14 |
  • Easy to use 👍
  • 15 |
  • Beginner Friendly 😄
  • 16 |
  • Shop/Inventory System 🛒
  • 17 |
  • Balance/Bank balance Systems 🏦
  • 18 |
  • Custom Currencies System 💵
  • 19 |
  • Custom Item Data 📝
  • 20 |
  • Multi-Server Setup 🔧
  • 21 |
22 | 23 | ## 📂 | Installation 24 | Note:
25 | Node.js v14.0.0 or newer is required.
26 | ```console 27 | $ npm i discord-economy-super 28 | $ yarn add discord-economy-super 29 | $ pnpm add discord-economy-super 30 | ``` 31 | 32 | ## [[Module Documentation]](https://des-docs.js.org) 33 | 34 | ## 🛠️ | Examples 35 | [MongoDB Examples](https://github.com/shadowplay1/discord-economy-super/tree/main/examples/mongodb) 36 | 37 | [JSON Examples](https://github.com/shadowplay1/discord-economy-super/tree/main/examples/json) 38 | 39 | ## 🤔 | Help 40 | If you don't understand something in the documentation or you are experiencing problems, feel free to join our Support Server. 41 | 42 | ## 🕘 | My Other Modules 43 | 48 | 49 | ## ❗ | Useful Links 50 | 58 |
59 | If you don't understand something in the documentation or you are experiencing problems, feel free to join our Support Server. 60 |
61 | Module Created by ShadowPlay. 62 | 63 | # ❤️ Thanks for choosing Discord Economy Super ❤️ -------------------------------------------------------------------------------- /mongodb/typings/interfaces/EconomyConfiguration.d.ts: -------------------------------------------------------------------------------- 1 | import { IMongoConnectionOptions } from 'quick-mongo-super/typings/src/interfaces/QuickMongo' 2 | 3 | import CheckerConfiguration from './CheckerConfiguration' 4 | import ErrorHandlerConfiguration from './ErrorHandlerConfiguration' 5 | import UpdaterOptions from './UpdaterOptions' 6 | 7 | /** 8 | * Economy configuration. 9 | */ 10 | declare interface EconomyConfiguration { 11 | 12 | /** 13 | * Connection info object. 14 | */ 15 | connection?: IMongoConnectionOptions 16 | 17 | /** 18 | * Cooldown for Daily Command (in ms). Default: 24 hours (60000 * 60 * 24 ms) 19 | */ 20 | dailyCooldown?: number 21 | 22 | /** 23 | * Cooldown for Work Command (in ms). Default: 1 hour (60000 * 60 ms) 24 | */ 25 | workCooldown?: number 26 | 27 | /** 28 | * Cooldown for Weekly Command (in ms). Default: 7 days (60000 * 60 * 24 * 7 ms) 29 | */ 30 | weeklyCooldown?: number 31 | 32 | /** 33 | * Amount of money for Daily Reward. Default: 100. 34 | */ 35 | dailyAmount?: number | [number, number] 36 | 37 | /** 38 | * Amount of money for Work Reward. Default: [10, 50]. 39 | */ 40 | workAmount?: number | [number, number] 41 | 42 | /** 43 | * Amount of money for Monthly Reward. Default: 10000. 44 | */ 45 | monthlyAmount?: number | [number, number] 46 | 47 | /** 48 | * Cooldown for Monthly Reward (in ms). Default: 1 month (2629746000 ms). 49 | */ 50 | monthlyCooldown?: number | [number, number] 51 | 52 | /** 53 | * Amount of money for Monthly Reward. Default: 10000. 54 | */ 55 | hourlyAmount?: number | [number, number] 56 | 57 | /** 58 | * Cooldown for Hourly Reward (in ms). Default: 1 hour (3600000 ms). 59 | */ 60 | hourlyCooldown?: number | [number, number] 61 | 62 | /** 63 | * If true, the module will save all the purchases history. 64 | */ 65 | savePurchasesHistory?: boolean 66 | 67 | 68 | /** 69 | * If true, when someone buys the item, their balance will subtract by item price. 70 | */ 71 | subtractOnBuy?: boolean 72 | 73 | /** 74 | * Amount of money for Weekly Reward. Default: 1000. 75 | */ 76 | weeklyAmount?: number | [number, number] 77 | 78 | /** 79 | * Percent of the item's price it will be sold for. Default: 75. 80 | */ 81 | sellingItemPercent?: number 82 | 83 | /** 84 | * If true, the deprecation warnings will be sent in the console. 85 | */ 86 | deprecationWarnings?: boolean 87 | 88 | /** 89 | * The region (example: 'ru'; 'en') to format date and time. Default: 'en'. 90 | */ 91 | dateLocale?: string 92 | 93 | /** 94 | * Update checker configuration. 95 | */ 96 | updater?: UpdaterOptions 97 | 98 | /** 99 | * Error handler configuration. 100 | */ 101 | errorHandler?: ErrorHandlerConfiguration 102 | 103 | /** 104 | * Configuration for an 'Economy.utils.checkConfiguration' method. 105 | */ 106 | optionsChecker?: CheckerConfiguration 107 | 108 | /** 109 | * Enables or disables the debug mode. 110 | */ 111 | debug?: boolean 112 | } 113 | 114 | export = EconomyConfiguration -------------------------------------------------------------------------------- /typings/managers/RewardManager.d.ts: -------------------------------------------------------------------------------- 1 | import RewardObject from '../interfaces/RewardObject' 2 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 3 | 4 | import { RewardType } from '../interfaces/RewardTypes' 5 | 6 | 7 | /** 8 | * Reward manager methods class. 9 | */ 10 | declare class RewardManager { 11 | public constructor(options: EconomyConfiguration) 12 | 13 | /** 14 | * Adds a specified reward on user's balance. 15 | * @param reward Reward to give. 16 | * @param memberID Member ID. 17 | * @param guildID Guild ID. 18 | * @param reason The reason why the money was added. 19 | * @returns Reward object. 20 | */ 21 | public receive< 22 | isRewardArray extends boolean = false 23 | >(reward: RewardType, memberID: string, guildID: string, reason?: string): RewardObject 24 | 25 | /** 26 | * Adds a daily reward on user's balance 27 | * @param {string} memberID Member ID. 28 | * @param {string} guildID Guild ID. 29 | * @param {string} [reason] The reason why the money was added. Default: 'claimed the daily reward' 30 | * @returns Reward object. 31 | */ 32 | public getDaily< 33 | isRewardArray extends boolean = false 34 | >(memberID: string, guildID: string, reason?: string): RewardObject 35 | 36 | /** 37 | * Adds a work reward on user's balance 38 | * @param {string} memberID Member ID. 39 | * @param {string} guildID Guild ID. 40 | * @param {string} [reason] The reason why the money was added. Default: 'claimed the work reward' 41 | * @returns Reward object. 42 | */ 43 | public getWork< 44 | isRewardArray extends boolean = true 45 | >(memberID: string, guildID: string, reason?: string): RewardObject 46 | 47 | /** 48 | * Adds a weekly reward on user's balance 49 | * @param {string} memberID Member ID. 50 | * @param {string} guildID Guild ID. 51 | * @param {string} [reason] The reason why the money was added. Default: 'claimed the weekly reward' 52 | * @returns Reward object. 53 | */ 54 | public getWeekly< 55 | isRewardArray extends boolean = false 56 | >(memberID: string, guildID: string, reason?: string): RewardObject 57 | 58 | /** 59 | * Adds a monthly reward on user's balance 60 | * @param {string} memberID Member ID. 61 | * @param {string} guildID Guild ID. 62 | * @param {string} [reason] The reason why the money was added. Default: 'claimed the monthly reward' 63 | * @returns Reward object. 64 | */ 65 | public getMonthly< 66 | isRewardArray extends boolean = false 67 | >(memberID: string, guildID: string, reason?: string): RewardObject 68 | 69 | /** 70 | * Adds a hourly reward on user's balance 71 | * @param {string} memberID Member ID. 72 | * @param {string} guildID Guild ID. 73 | * @param {string} [reason] The reason why the money was added. Default: 'claimed the hourly reward' 74 | * @returns Reward object. 75 | */ 76 | public getHourly< 77 | isRewardArray extends boolean = false 78 | >(memberID: string, guildID: string, reason?: string): RewardObject 79 | } 80 | 81 | export = RewardManager -------------------------------------------------------------------------------- /mongodb/typings/classes/EconomyGuild.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 2 | import RawEconomyUser from '../interfaces/RawEconomyUser' 3 | 4 | import DatabaseManager from '../managers/DatabaseManager' 5 | import CacheManager from '../managers/CacheManager' 6 | 7 | import UtilsManager from '../managers/UtilsManager' 8 | 9 | import ShopManager from '../managers/ShopManager' 10 | import UserManager from '../managers/UserManager' 11 | 12 | import Shop from './guild/Shop' 13 | import Leaderboards from './guild/Leaderboards' 14 | 15 | import Settings from './guild/Settings' 16 | 17 | import EconomyUser from './EconomyUser' 18 | import Currency from './Currency' 19 | 20 | 21 | declare class EconomyGuild { 22 | 23 | /** 24 | * Economy guild class. 25 | * @param {string} id Guild ID. 26 | * @param {EconomyConfiguration} ecoOptions Economy configuration. 27 | * @param {any} guildObject Economy guild object. 28 | * @param {DatabaseManager} database Database manager. 29 | * @param {CacheManager} cache Cache manager. 30 | */ 31 | public constructor( 32 | id: string, 33 | ecoOptions: EconomyConfiguration, 34 | guildObject: { 35 | [userID: string]: RawEconomyUser 36 | }, 37 | database: DatabaseManager, 38 | cache: CacheManager 39 | ) 40 | 41 | 42 | /** 43 | * Guild user manager. 44 | */ 45 | public users: UserManager 46 | 47 | /** 48 | * Guild ID. 49 | */ 50 | public id: string 51 | 52 | /** 53 | * Determine if the guild exists in the database. 54 | */ 55 | public exists: boolean 56 | 57 | /** 58 | * Database Manager. 59 | * @private 60 | */ 61 | private database: DatabaseManager 62 | 63 | /** 64 | * Utils Manager. 65 | * @private 66 | */ 67 | private utils: UtilsManager 68 | 69 | /** 70 | * Shop Manager. 71 | * @private 72 | */ 73 | private _shop: ShopManager 74 | 75 | /** 76 | * Guild Shop. 77 | */ 78 | public shop: Shop 79 | 80 | /** 81 | * Guild currencies array. 82 | * @type {Currency[]} 83 | */ 84 | public currencies: Currency[] 85 | 86 | /** 87 | * Guild Leaderboards. 88 | */ 89 | public leaderboards: Leaderboards 90 | 91 | /** 92 | * Guild Settings. 93 | */ 94 | public settings: Settings 95 | 96 | 97 | /** 98 | * Deletes the guild from database. 99 | * @returns {Promise} Deleted guild object. 100 | */ 101 | public delete(): Promise 102 | 103 | /** 104 | * Sets the default guild object for the specified member. 105 | * @returns {Promise} If reset successfully: true; else: false. 106 | */ 107 | public reset(): Promise 108 | 109 | /** 110 | * Creates an economy guild object in database. 111 | * @returns {Promise} If created successfully: true; else: false. 112 | */ 113 | public create(): Promise 114 | 115 | /** 116 | * Converts the economy guild to string. 117 | * @returns {string} String representation of economy guild. 118 | */ 119 | public toString(): string 120 | } 121 | 122 | export = EconomyGuild 123 | -------------------------------------------------------------------------------- /mongodb/typings/classes/user/Cooldowns.d.ts: -------------------------------------------------------------------------------- 1 | import DatabaseManager from '../../managers/DatabaseManager' 2 | import CacheManager from '../../managers/CacheManager' 3 | 4 | import RewardCooldownData from '../../interfaces/RewardCooldownData' 5 | import { RewardType } from '../../interfaces/RewardTypes' 6 | 7 | import RawEconomyUser from '../../interfaces/RawEconomyUser' 8 | import EconomyConfiguration from '../../interfaces/EconomyConfiguration' 9 | 10 | declare class Cooldowns { 11 | 12 | /** 13 | * Cooldowns class. 14 | * @param userObject User object from database. 15 | */ 16 | public constructor( 17 | userObject: RawEconomyUser, 18 | options: EconomyConfiguration, 19 | database: DatabaseManager, 20 | cache: CacheManager 21 | ) 22 | 23 | /** 24 | * Returns the cooldown of the specified type. 25 | * @param type Cooldown type. 26 | * @returns Cooldown object. 27 | */ 28 | public getCooldown(type: RewardType): Promise 29 | 30 | /** 31 | * Gets user's daily cooldown. 32 | * @returns User's daily cooldown object. 33 | */ 34 | public getDaily(): Promise 35 | 36 | /** 37 | * Gets user's work cooldown. 38 | * @returns User's work cooldown object. 39 | */ 40 | public getWork(): Promise 41 | 42 | /** 43 | * Gets user's weekly cooldown. 44 | * @returns User's weekly cooldown object. 45 | */ 46 | public getWeekly(): Promise 47 | 48 | /** 49 | * Gets user's monthly cooldown. 50 | * @returns User's monthly cooldown object. 51 | */ 52 | public getMonthly(): Promise 53 | 54 | /** 55 | * Gets user's hourly cooldown. 56 | * @returns User's hourly cooldown object. 57 | */ 58 | public getHourly(): Promise 59 | 60 | /** 61 | * Clears all the user's cooldowns. 62 | * @returns {Promise} If all cooldowns were cleared successfully: true, else: false. 63 | */ 64 | public clearAll(): Promise 65 | 66 | /** 67 | * Clears user's daily cooldown. 68 | * @returns {Promise} If cleared: true; else: false. 69 | */ 70 | public clearDaily(): Promise 71 | 72 | /** 73 | * Clears user's work cooldown. 74 | * @returns {Promise} If cleared: true; else: false. 75 | */ 76 | public clearWork(): Promise 77 | 78 | /** 79 | * Clears user's weekly cooldown. 80 | * @returns {Promise} If cleared: true; else: false. 81 | */ 82 | public clearWeekly(): Promise 83 | 84 | /** 85 | * Clears user's monthly cooldown. 86 | * @returns {Promise} If cleared: true; else: false. 87 | */ 88 | public clearMonthly(): Promise 89 | 90 | /** 91 | * Clears user's hourly cooldown. 92 | * @returns {Promise} If cleared: true; else: false. 93 | */ 94 | public clearHourly(): Promise 95 | 96 | /** 97 | * Gets all user's cooldowns 98 | * @returns User's cooldowns object. 99 | */ 100 | public getAll(): Promise> 101 | } 102 | 103 | export = Cooldowns -------------------------------------------------------------------------------- /mongodb/typings/managers/BankManager.d.ts: -------------------------------------------------------------------------------- 1 | import DatabaseManager from './DatabaseManager' 2 | import CacheManager from './CacheManager' 3 | 4 | import Emitter from '../classes/util/Emitter' 5 | 6 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 7 | import LeaderboardData from '../interfaces/LeaderboardData' 8 | 9 | 10 | /** 11 | * Bank balance manager methods class. 12 | * @extends {Emitter} 13 | */ 14 | declare class BankManager extends Emitter { 15 | public constructor(options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager) 16 | 17 | /** 18 | * Fetches the user's bank balance. 19 | * @param {string} memberID Member ID. 20 | * @param {string} guildID Guild ID. 21 | * @returns {Promise} User's bank balance. 22 | */ 23 | public fetch(memberID: string, guildID: string): Promise 24 | 25 | /** 26 | * Gets the user's bank balance. 27 | * 28 | * This method is an alias for the `BankManager.fetch()` method. 29 | * @param {string} memberID Member ID. 30 | * @param {string} guildID Guild ID. 31 | * @returns {Promise} User's bank balance. 32 | */ 33 | public get(memberID: string, guildID: string): Promise 34 | 35 | /** 36 | * Sets the money amount on user's bank balance. 37 | * @param {number} amount Amount of money that you want to set. 38 | * @param {string} memberID Member ID. 39 | * @param {string} guildID Guild ID. 40 | * @param {string} [reason] The reason why you set the money. 41 | * @returns {Promise} Money amount. 42 | */ 43 | public set(amount: number, memberID: string, guildID: string, reason?: string): Promise 44 | 45 | /** 46 | * Adds the money amount on user's bank balance. 47 | * @param {number} amount Amount of money that you want to add. 48 | * @param {string} memberID Member ID. 49 | * @param {string} guildID Guild ID. 50 | * @param {string} [reason] The reason why you add the money. 51 | * @returns {Promise} Money amount. 52 | */ 53 | public add(amount: number, memberID: string, guildID: string, reason?: string): Promise 54 | 55 | /** 56 | * Subtracts the money amount from user's bank balance. 57 | * @param {number} amount Amount of money that you want to subtract. 58 | * @param {string} memberID Member ID. 59 | * @param {string} guildID Guild ID. 60 | * @param {string} [reason] The reason why you subtract the money. 61 | * @returns {Promise} Money amount. 62 | */ 63 | public subtract(amount: number, memberID: string, guildID: string, reason?: string): Promise 64 | 65 | /** 66 | * Withdraws the specified amount of money. 67 | * @param {number} amount Money amount. 68 | * @param {string} memberID Member ID. 69 | * @param {string} guildID Guild ID. 70 | * @param {string} [reason] The reason of the operation. 71 | * @returns {Promise} Money amount. 72 | */ 73 | public withdraw(amount: number, memberID: string, guildID: string, reason?: string): Promise 74 | 75 | /** 76 | * Gets a bank balance leaderboard for specified guild. 77 | * @param {string} guildID Guild ID. 78 | * @returns {Promise} Sorted leaderboard array. 79 | */ 80 | public leaderboard(guildID: string): Promise 81 | } 82 | 83 | export = BankManager -------------------------------------------------------------------------------- /mongodb/typings/classes/guild/Settings.d.ts: -------------------------------------------------------------------------------- 1 | import EconomyConfiguration from '../../interfaces/EconomyConfiguration' 2 | 3 | import SettingsTypes from '../../interfaces/SettingsTypes' 4 | import SettingValueType from '../../interfaces/SettingValueType' 5 | 6 | import DatabaseManager from '../../managers/DatabaseManager' 7 | 8 | 9 | declare class Settings { 10 | public constructor(guildID: string, options: EconomyConfiguration, database: DatabaseManager) 11 | 12 | /** 13 | * Gets the specified setting from the database. 14 | * 15 | * Note: If the server don't have any setting specified, 16 | * the module will take the values from the 17 | * specified configuration or default configuration. 18 | * 19 | * @param {T} key The setting to fetch. 20 | * @returns {SettingValueType} The setting from the database. 21 | */ 22 | public get(key: T): Promise> 23 | 24 | /** 25 | * Changes the specified setting. 26 | * 27 | * Note: If the server don't have any setting specified, 28 | * the module will take the values from the 29 | * specified configuration or default configuration. 30 | * 31 | * @param {T} key The setting to change. 32 | * @param {SettingValueType} value The value to set. 33 | * @returns {SettingsTypes} The server settings object. 34 | */ 35 | public set(key: T, value: SettingValueType): Promise 36 | 37 | /** 38 | * Removes the specified setting. 39 | * 40 | * Note: If the server don't have any setting specified, 41 | * the module will take the values from the 42 | * specified configuration or default configuration. 43 | * 44 | * @param {keyof SettingsTypes} key The setting to remove. 45 | * @returns {SettingsTypes} The server settings object. 46 | */ 47 | public remove(key: keyof SettingsTypes): Promise 48 | 49 | /** 50 | * Deletes the specified setting from the guild. 51 | * 52 | * Note: If the server don't have any setting specified, 53 | * the module will take the values from the 54 | * specified configuration or default configuration. 55 | * 56 | * @param {Settings} key The setting to delete. 57 | * @returns {Promise} The server settings object. 58 | */ 59 | public delete(key: keyof SettingsTypes): Promise 60 | 61 | /** 62 | * Deletes the specified setting from the guild. 63 | * 64 | * Note: If the server don't have any setting specified, 65 | * the module will take the values from the 66 | * specified configuration or default configuration. 67 | * 68 | * This method is an alias for `Settings.delete()` method. 69 | * 70 | * @param {Settings} key The setting to delete. 71 | * @returns {Promise} The server settings object. 72 | */ 73 | public remove(key: keyof SettingsTypes): Promise 74 | 75 | /** 76 | * Fetches the server's settings object. 77 | * @returns {SettingsTypes} The server settings object. 78 | */ 79 | public all(): Promise 80 | 81 | /** 82 | * Resets all the settings to setting that are in configuration. 83 | * @returns {SettingsTypes} The server settings object. 84 | */ 85 | public reset(): Promise 86 | } 87 | 88 | export = Settings -------------------------------------------------------------------------------- /mongodb/typings/managers/SettingsManager.d.ts: -------------------------------------------------------------------------------- 1 | import DatabaseManager from './DatabaseManager' 2 | import CacheManager from './CacheManager' 3 | 4 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 5 | 6 | import SettingsTypes from '../interfaces/SettingsTypes' 7 | import SettingValueType from '../interfaces/SettingValueType' 8 | 9 | /** 10 | * 11 | */ 12 | declare class SettingsManager { 13 | public constructor(options: EconomyConfiguration, database: DatabaseManager, cache: CacheManager) 14 | 15 | /** 16 | * Gets the specified setting from the database. 17 | * 18 | * Note: If the server don't have any setting specified, 19 | * the module will take the values from the 20 | * specified configuration or default configuration. 21 | * 22 | * @param {T} key The setting to fetch. 23 | * @param {string} guildID Guild ID. 24 | * @returns {Promise>} The setting from the database. 25 | */ 26 | public get(key: T, guildID: string): Promise> 27 | 28 | /** 29 | * Changes the specified setting. 30 | * 31 | * Note: If the server don't have any setting specified, 32 | * the module will take the values from the 33 | * specified configuration or default configuration. 34 | * 35 | * @param {T} key The setting to change. 36 | * @param {SettingValueType} value The value to set. 37 | * @param {string} guildID Guild ID. 38 | * @returns {Promise} The server settings object. 39 | */ 40 | public set(key: T, value: SettingValueType, guildID: string): Promise 41 | 42 | /** 43 | * Deletes the specified setting. 44 | * 45 | * Note: If the server don't have any setting specified, 46 | * the module will take the values from the 47 | * specified configuration or default configuration. 48 | * 49 | * @param {keyof SettingsTypes} key The setting to delete. 50 | * @param {string} guildID Guild ID. 51 | * @returns {Promise} The server settings object. 52 | */ 53 | public delete(key: keyof SettingsTypes, guildID: string): Promise 54 | 55 | /** 56 | * Deletes the specified setting. 57 | * 58 | * Note: If the server don't have any setting specified, 59 | * the module will take the values from the 60 | * specified configuration or default configuration. 61 | * 62 | * This method is an alias for `SettingsManager.delete()` method. 63 | * 64 | * @param {keyof SettingsTypes} key The setting to delete. 65 | * @param {string} guildID Guild ID. 66 | * @returns {Promise} The server settings object. 67 | */ 68 | public remove(key: keyof SettingsTypes, guildID: string): Promise 69 | 70 | /** 71 | * Fetches the server's settings object. 72 | * @param {string} guildID Guild ID. 73 | * @returns {Promise} The server settings object. 74 | */ 75 | public all(guildID: string): Promise 76 | 77 | /** 78 | * Resets all the settings to setting that are in configuration. 79 | * @param {string} guildID Guild ID. 80 | * @returns {Promise} The server settings object. 81 | */ 82 | public reset(guildID: string): Promise 83 | } 84 | 85 | export = SettingsManager -------------------------------------------------------------------------------- /typings/managers/HistoryManager.d.ts: -------------------------------------------------------------------------------- 1 | import DatabaseManager from './DatabaseManager' 2 | 3 | import EconomyConfiguration from '../interfaces/EconomyConfiguration' 4 | import HistoryItem from '../classes/HistoryItem' 5 | import Maybe from '../interfaces/Maybe' 6 | 7 | /** 8 | * History manager methods class. 9 | */ 10 | declare class HistoryManager { 11 | public constructor(options: EconomyConfiguration, database: DatabaseManager) 12 | 13 | /** 14 | * Shows the user's purchase history. 15 | * @param {string} memberID Member ID 16 | * @param {string} guildID Guild ID 17 | * @returns {HistoryItem[]} User's purchase history. 18 | */ 19 | public fetch(memberID: string, guildID: string): HistoryItem[] 20 | 21 | /** 22 | * Shows the user's purchase history. 23 | * 24 | * This method is an alias for `HistoryManager.fetch()` method. 25 | * @param {string} memberID Member ID 26 | * @param {string} guildID Guild ID 27 | * @returns {HistoryItem[]} User's purchase history. 28 | */ 29 | public get(memberID: string, guildID: string): HistoryItem[] 30 | 31 | /** 32 | * Clears the user's purchases history. 33 | * @param {string} memberID Member ID. 34 | * @param {string} guildID Guild ID. 35 | * @returns {boolean} If cleared: true, else: false. 36 | */ 37 | public clear(memberID: string, guildID: string): boolean 38 | 39 | /** 40 | * Adds the item from the shop to the purchases history. 41 | * @param {string} itemID Item ID or name. 42 | * @param {string} memberID Member ID. 43 | * @param {string} guildID Guild ID. 44 | * @param {number} [quantity=1] Quantity of the items. Default: 1. 45 | * 46 | * @param {Maybe} [currency=null] 47 | * The currency (ID, name or symbol) that was used for the purchase. 48 | * Can be omitted by specifying 'null' or ignoring this parameter. Default: null. 49 | * 50 | * @returns {boolean} If added: true, else: false. 51 | */ 52 | public add(itemID: string | number, memberID: string, guildID: string, quantity?: number, currency?: Maybe): boolean 53 | 54 | /** 55 | * Removes the specified item from history. 56 | * @param {string} id History item ID. 57 | * @param {string} memberID Member ID. 58 | * @param {string} guildID Guild ID. 59 | * @returns {boolean} If removed: true, else: false. 60 | */ 61 | public remove(id: string, memberID: string, guildID: string): boolean 62 | 63 | /** 64 | * Gets the specified item from history. 65 | * @param {string} id History item ID. 66 | * @param {string} memberID Member ID. 67 | * @param {string} guildID Guild ID. 68 | * @returns {HistoryItem} If removed: true, else: false. 69 | */ 70 | public findItem(id: string, memberID: string, guildID: string): HistoryItem 71 | 72 | /** 73 | * Gets the specified item from history. 74 | * 75 | * This method is an alias for the `HistoryManager.findItem()` method. 76 | * @param {string} id History item ID. 77 | * @param {string} memberID Member ID. 78 | * @param {string} guildID Guild ID. 79 | * @returns {HistoryItem} If removed: true, else: false. 80 | */ 81 | public getItem(id: string, memberID: string, guildID: string): HistoryItem 82 | } 83 | 84 | export = HistoryManager --------------------------------------------------------------------------------