diff --git a/.husky/pre-commit b/.husky/pre-commit index e6d6262..0977290 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -7,6 +7,6 @@ cleanup() { } cleanup && npm run build -bash scripts/minify.sh +# bash scripts/minify.sh git add . diff --git a/src/lib/managers/DatabaseManager.ts b/src/lib/managers/DatabaseManager.ts index 14fbd00..9e2aeea 100644 --- a/src/lib/managers/DatabaseManager.ts +++ b/src/lib/managers/DatabaseManager.ts @@ -3,11 +3,14 @@ import { Giveaways } from '../../Giveaways' import { Database } from '../../types/configurations' import { IDatabaseGuild } from '../../types/databaseStructure.interface' import { DatabaseType } from '../../types/databaseType.enum' + import { ExtractPromisedType } from '../../types/misc/utils' +import { IDebugResult } from '../../types/debug.interface' import { GiveawaysError, GiveawaysErrorCodes, errorMessages } from '../util/classes/GiveawaysError' import { JSONParser } from '../util/classes/JSONParser' import { Logger } from '../util/classes/Logger' + import { CacheManager } from './CacheManager' /** @@ -146,7 +149,7 @@ export class DatabaseManager>> { + ): Promise>>> { try { const callbackResult = await toDebug() @@ -154,13 +157,19 @@ export class DatabaseManager} The data from the database. + * @returns {Promise>} The data from the database. * * @template V The type of data being set. * @template R The type of data being returned. */ - public async set(key: TKey, value: V, sendDebugLog: boolean = true): Promise { + public async set(key: TKey, value: V, sendDebugLog: boolean = true): Promise> { return this._debug('set', key, async (): Promise => { this._cache.set(key, value) @@ -373,9 +382,9 @@ export class DatabaseManager} `true` if added successfully, `false` otherwise. + * @returns {Promise>} `true` if added successfully, `false` otherwise. */ - public async add(key: TKey, numberToAdd: number): Promise { + public async add(key: TKey, numberToAdd: number): Promise> { return this._debug('add', key, async (): Promise => { const targetNumber = this._cache.get(key) @@ -433,9 +442,9 @@ export class DatabaseManager} `true` if subtracted successfully, `false` otherwise. + * @returns {Promise>} `true` if subtracted successfully, `false` otherwise. */ - public async subtract(key: TKey, numberToSubtract: number): Promise { + public async subtract(key: TKey, numberToSubtract: number): Promise> { return this._debug('subtract', key, async (): Promise => { const targetNumber = this._cache.get(key) @@ -492,9 +501,9 @@ export class DatabaseManager} `true` if deleted successfully, `false` otherwise. + * @returns {Promise>} `true` if deleted successfully, `false` otherwise. */ - public async delete(key: TKey): Promise { + public async delete(key: TKey): Promise> { return this._debug('delete', key, async (): Promise => { this._cache.delete(key) @@ -526,11 +535,11 @@ export class DatabaseManager} `true` if pushed successfully, `false` otherwise. + * @returns {Promise>} `true` if pushed successfully, `false` otherwise. * * @template V The type of data being pushed. */ - public async push(key: TKey, value: V): Promise { + public async push(key: TKey, value: V): Promise> { return this._debug('push', key, async (): Promise => { const targetArray = this._cache.get(key) || [] @@ -601,11 +610,11 @@ export class DatabaseManager} `true` if pulled successfully, `false` otherwise. + * @returns {Promise>} `true` if pulled successfully, `false` otherwise. * * @template V The type of data being pulled. */ - public async pull(key: TKey, index: number, newValue: V): Promise { + public async pull(key: TKey, index: number, newValue: V): Promise> { return this._debug('pull', key, async (): Promise => { const targetArray = this._cache.get(key) || [] @@ -672,9 +681,9 @@ export class DatabaseManager} `true` if popped successfully, `false` otherwise. + * @returns {Promise>} `true` if popped successfully, `false` otherwise. */ - public async pop(key: TKey, index: number): Promise { + public async pop(key: TKey, index: number): Promise> { return this._debug('pop', key, async (): Promise => { const targetArray = this._cache.get(key) || []