diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-26 16:12:06 +0000 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-26 16:12:06 +0000 |
commit | 00ad00734ddb2c2fce8de8efcc010181c9ce1821 (patch) | |
tree | e6b79047fd2cfbef4733cfbd488ee4cb47d600d5 /src/tasks | |
parent | 1d6e64d5c43e4398e7c0488f114acba2c8a55164 (diff) | |
download | tanzanite-00ad00734ddb2c2fce8de8efcc010181c9ce1821.tar.gz tanzanite-00ad00734ddb2c2fce8de8efcc010181c9ce1821.tar.bz2 tanzanite-00ad00734ddb2c2fce8de8efcc010181c9ce1821.zip |
feat: use Time enum
Diffstat (limited to 'src/tasks')
-rw-r--r-- | src/tasks/cpuUsage.ts | 6 | ||||
-rw-r--r-- | src/tasks/handleReminders.ts | 6 | ||||
-rw-r--r-- | src/tasks/removeExpiredPunishements.ts | 6 | ||||
-rw-r--r-- | src/tasks/updateCache.ts | 3 | ||||
-rw-r--r-- | src/tasks/updateHighlightCache.ts | 15 | ||||
-rw-r--r-- | src/tasks/updatePriceItemCache.ts | 4 | ||||
-rw-r--r-- | src/tasks/updateStats.ts | 4 |
7 files changed, 30 insertions, 14 deletions
diff --git a/src/tasks/cpuUsage.ts b/src/tasks/cpuUsage.ts index 9985e48..e5cfc00 100644 --- a/src/tasks/cpuUsage.ts +++ b/src/tasks/cpuUsage.ts @@ -1,16 +1,16 @@ -import { BushTask } from '#lib'; +import { BushTask, Time } from '#lib'; import osu from 'node-os-utils'; export default class CpuUsageTask extends BushTask { public constructor() { super('cpuUsage', { - delay: 60_000, // 1 minute + delay: Time.Minute, runOnStart: true }); } public override async exec() { - const cpu = await osu.cpu.usage(client.stats.cpu === undefined ? 100 : 60_000); + const cpu = await osu.cpu.usage(client.stats.cpu === undefined ? 100 * Time.Millisecond : Time.Minute); client.stats.cpu = cpu; } } diff --git a/src/tasks/handleReminders.ts b/src/tasks/handleReminders.ts index d1af480..e281903 100644 --- a/src/tasks/handleReminders.ts +++ b/src/tasks/handleReminders.ts @@ -1,10 +1,10 @@ -import { BushTask, Reminder } from '#lib'; +import { BushTask, Reminder, Time } from '#lib'; const { Op } = (await import('sequelize')).default; export default class HandlerRemindersTask extends BushTask { public constructor() { super('handlerReminders', { - delay: 30_000, // 30 seconds + delay: 30 * Time.Second, runOnStart: true }); } @@ -13,7 +13,7 @@ export default class HandlerRemindersTask extends BushTask { const expiredEntries = await Reminder.findAll({ where: { expires: { - [Op.lt]: new Date(Date.now() + 30_000) // Find all rows with an expiry date before 30 seconds from now + [Op.lt]: new Date(Date.now() + 30 * Time.Second) // Find all rows with an expiry date before 30 seconds from now }, notified: false } diff --git a/src/tasks/removeExpiredPunishements.ts b/src/tasks/removeExpiredPunishements.ts index 904e614..b1ca042 100644 --- a/src/tasks/removeExpiredPunishements.ts +++ b/src/tasks/removeExpiredPunishements.ts @@ -1,11 +1,11 @@ -import { ActivePunishment, ActivePunishmentType, BushTask, type BushGuild, type BushUser } from '#lib'; +import { ActivePunishment, ActivePunishmentType, BushTask, Time, type BushGuild, type BushUser } from '#lib'; import assert from 'assert'; const { Op } = (await import('sequelize')).default; export default class RemoveExpiredPunishmentsTask extends BushTask { public constructor() { super('removeExpiredPunishments', { - delay: 15_000, // 15 seconds + delay: 15 * Time.Second, runOnStart: true }); } @@ -14,7 +14,7 @@ export default class RemoveExpiredPunishmentsTask extends BushTask { const expiredEntries = await ActivePunishment.findAll({ where: { expires: { - [Op.lt]: new Date(Date.now() + 15_000) // Find all rows with an expiry date before 15 seconds from now + [Op.lt]: new Date(Date.now() + 15 * Time.Second) // Find all rows with an expiry date before 15 seconds from now } } }); diff --git a/src/tasks/updateCache.ts b/src/tasks/updateCache.ts index 9084c1c..3794f76 100644 --- a/src/tasks/updateCache.ts +++ b/src/tasks/updateCache.ts @@ -1,3 +1,4 @@ +import { Time } from '#constants'; import { Global, Guild, Shared, type BushClient } from '#lib'; import { BushTask } from '../lib/extensions/discord-akairo/BushTask.js'; import config from './../config/options.js'; @@ -5,7 +6,7 @@ import config from './../config/options.js'; export default class UpdateCacheTask extends BushTask { public constructor() { super('updateCache', { - delay: 300_000, // 5 minutes + delay: 5 * Time.Minute, runOnStart: false // done in preinit task }); } diff --git a/src/tasks/updateHighlightCache.ts b/src/tasks/updateHighlightCache.ts new file mode 100644 index 0000000..22289ce --- /dev/null +++ b/src/tasks/updateHighlightCache.ts @@ -0,0 +1,15 @@ +import { Time } from '#constants'; +import { BushTask } from '../lib/extensions/discord-akairo/BushTask.js'; + +export default class UpdateHighlightCacheTask extends BushTask { + public constructor() { + super('updateHighlightCache', { + delay: 5 * Time.Minute, + runOnStart: false + }); + } + + public override async exec() { + return client.highlightManager.syncCache(); + } +} diff --git a/src/tasks/updatePriceItemCache.ts b/src/tasks/updatePriceItemCache.ts index 096354b..6414eb0 100644 --- a/src/tasks/updatePriceItemCache.ts +++ b/src/tasks/updatePriceItemCache.ts @@ -1,11 +1,11 @@ -import { BushTask } from '#lib'; +import { BushTask, Time } from '#lib'; import got from 'got'; import PriceCommand, { AuctionAverages, Bazaar, LowestBIN } from '../commands/utilities/price.js'; export default class UpdatePriceItemCache extends BushTask { public constructor() { super('updatePriceItemCache', { - delay: 600_000, // 10 minutes + delay: 10 * Time.Minute, runOnStart: true }); } diff --git a/src/tasks/updateStats.ts b/src/tasks/updateStats.ts index bf8d2ed..15ebe96 100644 --- a/src/tasks/updateStats.ts +++ b/src/tasks/updateStats.ts @@ -1,9 +1,9 @@ -import { BushTask, Stat } from '#lib'; +import { BushTask, Stat, Time } from '#lib'; export default class UpdateStatsTask extends BushTask { public constructor() { super('updateStats', { - delay: 600_000, // 10 minutes + delay: 10 * Time.Minute, runOnStart: true }); } |