From 3ec020e406fcd1fab550370a097afd97b028a78d Mon Sep 17 00:00:00 2001 From: MagicalsDev <102973864+MagicalsDev@users.noreply.github.com> Date: Tue, 5 Apr 2022 19:50:10 +0400 Subject: [PATCH 1/4] Update index.d.ts --- index.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 82ea277..0d38c71 100644 --- a/index.d.ts +++ b/index.d.ts @@ -69,6 +69,12 @@ declare module "quick.eco" { BEG: number; MONTHLY: number; SEARCH: number; + SEARCHALT: number; + FISH: number; + HUNT: number; + DIG: number; + POSTMEME: number; + CULTIVATE: number; // Bonus } export interface Leaderboard { @@ -137,4 +143,4 @@ declare module "quick.eco" { } export const version: string; -} \ No newline at end of file +} From 469e11788a77fd434c53b85ec784ff5a240e5540 Mon Sep 17 00:00:00 2001 From: MagicalsDev <102973864+MagicalsDev@users.noreply.github.com> Date: Tue, 5 Apr 2022 19:55:39 +0400 Subject: [PATCH 2/4] Update index.d.ts --- index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.d.ts b/index.d.ts index 0d38c71..9f73ece 100644 --- a/index.d.ts +++ b/index.d.ts @@ -124,6 +124,12 @@ declare module "quick.eco" { public search(userID: string, guildID: string | false, amount: number, ops: TimeBasedRewardOptions): Promise public custom(userID: string, guildID: string | false, amount: number, ops: CustomRewardOptions): Promise public beg(userID: string, guildID: string | false, amount: number, ops: TimeBasedRewardOptions): Promise + public fish(userID: string, guildID: string | false, amount: number, ops: TimeBasedRewardOptions): Promise + public hunt(userID: string, guildID: string | false, amount: number, ops: TimeBasedRewardOptions): Promise + public dig(userID: string, guildID: string | false, amount: number, ops: TimeBasedRewardOptions): Promise + public postmeme(userID: string, guildID: string | false, amount: number, ops: TimeBasedRewardOptions): Promise + public cultivate(userID: string, guildID: string | false, amount: number, ops: TimeBasedRewardOptions): Promise + public searchalt(userID: string, guildID: string | false, amount: number, ops: TimeBasedRewardOptions): Promise public fetchMoney(userID: string, guildID: string | false): Promise; public reset(): Promise; private __checkManager(): void; From c86efbf7372163a46b1ff927aa46ac7b3f7011fa Mon Sep 17 00:00:00 2001 From: MagicalsDev <102973864+MagicalsDev@users.noreply.github.com> Date: Tue, 5 Apr 2022 19:57:21 +0400 Subject: [PATCH 3/4] Update Eco.js --- src/Eco.js | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) diff --git a/src/Eco.js b/src/Eco.js index 70edc15..1a303ac 100644 --- a/src/Eco.js +++ b/src/Eco.js @@ -462,6 +462,174 @@ class EconomyManager { return { cooldown: false, time: null, amount: newAmount }; } + /** + * Fish reward + * @param {string} userID User id + * @param {string} guildID Guild id + * @param {number} amount Custom Amount + * @param {object} ops Options + * @param {number[]} [ops.range] Amount range + * @param {number} [ops.timeout] Timeout + * @returns {Promise} + */ + async fish(userID, guildID = false, amount, ops = { range: [], timeout: 0 }) { + this.__checkManager(); + + if (!userID || typeof userID !== "string") throw new Error("User id was not provided!"); + if (!amount) amount = Util.random(ops && ops.range[0] || 1, ops && ops.range[1] || 70); + + const key = Util.makeKey(userID, guildID, "fish"); + const cooldownRaw = await this._get(key); + const cooldown = Util.onCooldown(ops.timeout || Util.COOLDOWN.FISH, cooldownRaw ? cooldownRaw.data : 0); + + if (cooldown) return { cooldown: true, time: Util.getCooldown(ops.timeout || Util.COOLDOWN.FISH, cooldownRaw ? cooldownRaw.data : 0) }; + + const newAmount = await this.addMoney(userID, guildID, amount); + await this._set(key, Date.now()); + + return { cooldown: false, time: null, amount: newAmount }; + } + + /** + * Hunt reward + * @param {string} userID User id + * @param {string} guildID Guild id + * @param {number} amount Custom Amount + * @param {object} ops Options + * @param {number[]} [ops.range] Amount range + * @param {number} [ops.timeout] Timeout + * @returns {Promise} + */ + async hunt(userID, guildID = false, amount, ops = { range: [], timeout: 0 }) { + this.__checkManager(); + + if (!userID || typeof userID !== "string") throw new Error("User id was not provided!"); + if (!amount) amount = Util.random(ops && ops.range[0] || 1, ops && ops.range[1] || 70); + + const key = Util.makeKey(userID, guildID, "hunt"); + const cooldownRaw = await this._get(key); + const cooldown = Util.onCooldown(ops.timeout || Util.COOLDOWN.HUNT, cooldownRaw ? cooldownRaw.data : 0); + + if (cooldown) return { cooldown: true, time: Util.getCooldown(ops.timeout || Util.COOLDOWN.HUNT, cooldownRaw ? cooldownRaw.data : 0) }; + + const newAmount = await this.addMoney(userID, guildID, amount); + await this._set(key, Date.now()); + + return { cooldown: false, time: null, amount: newAmount }; + } + + /** + * Dig reward + * @param {string} userID User id + * @param {string} guildID Guild id + * @param {number} amount Custom Amount + * @param {object} ops Options + * @param {number[]} [ops.range] Amount range + * @param {number} [ops.timeout] Timeout + * @returns {Promise} + */ + async dig(userID, guildID = false, amount, ops = { range: [], timeout: 0 }) { + this.__checkManager(); + + if (!userID || typeof userID !== "string") throw new Error("User id was not provided!"); + if (!amount) amount = Util.random(ops && ops.range[0] || 1, ops && ops.range[1] || 70); + + const key = Util.makeKey(userID, guildID, "dig"); + const cooldownRaw = await this._get(key); + const cooldown = Util.onCooldown(ops.timeout || Util.COOLDOWN.DIG, cooldownRaw ? cooldownRaw.data : 0); + + if (cooldown) return { cooldown: true, time: Util.getCooldown(ops.timeout || Util.COOLDOWN.DIG, cooldownRaw ? cooldownRaw.data : 0) }; + + const newAmount = await this.addMoney(userID, guildID, amount); + await this._set(key, Date.now()); + + return { cooldown: false, time: null, amount: newAmount }; + } + + /** + * Postmeme reward + * @param {string} userID User id + * @param {string} guildID Guild id + * @param {number} amount Custom Amount + * @param {object} ops Options + * @param {number[]} [ops.range] Amount range + * @param {number} [ops.timeout] Timeout + * @returns {Promise} + */ + async postmeme(userID, guildID = false, amount, ops = { range: [], timeout: 0 }) { + this.__checkManager(); + + if (!userID || typeof userID !== "string") throw new Error("User id was not provided!"); + if (!amount) amount = Util.random(ops && ops.range[0] || 1, ops && ops.range[1] || 70); + + const key = Util.makeKey(userID, guildID, "postmeme"); + const cooldownRaw = await this._get(key); + const cooldown = Util.onCooldown(ops.timeout || Util.COOLDOWN.POSTMEME, cooldownRaw ? cooldownRaw.data : 0); + + if (cooldown) return { cooldown: true, time: Util.getCooldown(ops.timeout || Util.COOLDOWN.POSTMEME, cooldownRaw ? cooldownRaw.data : 0) }; + + const newAmount = await this.addMoney(userID, guildID, amount); + await this._set(key, Date.now()); + + return { cooldown: false, time: null, amount: newAmount }; + } + + /** + * Cultivate reward + * @param {string} userID User id + * @param {string} guildID Guild id + * @param {number} amount Custom Amount + * @param {object} ops Options + * @param {number[]} [ops.range] Amount range + * @param {number} [ops.timeout] Timeout + * @returns {Promise} + */ + async cultivate(userID, guildID = false, amount, ops = { range: [], timeout: 0 }) { + this.__checkManager(); + + if (!userID || typeof userID !== "string") throw new Error("User id was not provided!"); + if (!amount) amount = Util.random(ops && ops.range[0] || 1, ops && ops.range[1] || 70); + + const key = Util.makeKey(userID, guildID, "cultivate"); + const cooldownRaw = await this._get(key); + const cooldown = Util.onCooldown(ops.timeout || Util.COOLDOWN.CULTIVATE, cooldownRaw ? cooldownRaw.data : 0); + + if (cooldown) return { cooldown: true, time: Util.getCooldown(ops.timeout || Util.COOLDOWN.CULTIVATE, cooldownRaw ? cooldownRaw.data : 0) }; + + const newAmount = await this.addMoney(userID, guildID, amount); + await this._set(key, Date.now()); + + return { cooldown: false, time: null, amount: newAmount }; + } + + /** + * Searchalt reward + * @param {string} userID User id + * @param {string} guildID Guild id + * @param {number} amount Custom Amount + * @param {object} ops Options + * @param {number[]} [ops.range] Amount range + * @param {number} [ops.timeout] Timeout + * @returns {Promise} + */ + async searchalt(userID, guildID = false, amount, ops = { range: [], timeout: 0 }) { + this.__checkManager(); + + if (!userID || typeof userID !== "string") throw new Error("User id was not provided!"); + if (!amount) amount = Util.random(ops.range[0] || 1, ops.range[1] || 70); + + const key = Util.makeKey(userID, guildID, "searchalt"); + const cooldownRaw = await this._get(key); + const cooldown = Util.onCooldown(ops.timeout || Util.COOLDOWN.SEARCHALT, cooldownRaw ? cooldownRaw.data : 0); + if (cooldown) return { cooldown: true, time: Util.getCooldown(ops.timeout || Util.COOLDOWN.SEARCHALT, cooldownRaw ? cooldownRaw.data : 0) }; + + const newAmount = await this.addMoney(userID, guildID, amount); + await this._set(key, Date.now()); + + return { cooldown: false, time: null, amount: newAmount }; + } + + /** From 8d599ea6bb70bf0f3f0188d1e08b5c647370aa3d Mon Sep 17 00:00:00 2001 From: MagicalsDev <102973864+MagicalsDev@users.noreply.github.com> Date: Tue, 5 Apr 2022 19:58:58 +0400 Subject: [PATCH 4/4] Update Util.js --- src/Util.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Util.js b/src/Util.js index 8e220f1..9532325 100644 --- a/src/Util.js +++ b/src/Util.js @@ -135,6 +135,12 @@ class Util { * @property {number} BEG Cooldown for beg * @property {number} MONTHLY Cooldown for monthly * @property {number} SEARCH Cooldown for search + * @property {number} SEARCHALT Cooldown for search alternative + * @property {number} FISH Cooldown for fish + * @property {number} HUNT Cooldown for hunt + * @property {number} DIG Cooldown for dig + * @property {number} POSTMEME Cooldown for postmeme + * @property {number} CULTIVATE Cooldown for cultivate */ /** @@ -148,7 +154,13 @@ class Util { WORK: 2700000, BEG: 60000, MONTHLY: 2628000000, - SEARCH: 300000 + SEARCH: 300000, + SEARCHALT: 45000, + FISH: 50000, + HUNT: 45000, + DIG: 30000, + POSTMEME: 60000, + CULTIVATE: 55000 // Bonus }; } @@ -218,4 +230,4 @@ class Util { } }; -module.exports = Util; \ No newline at end of file +module.exports = Util;