diff options
Diffstat (limited to 'src/tasks/feature')
-rw-r--r-- | src/tasks/feature/handleReminders.ts | 5 | ||||
-rw-r--r-- | src/tasks/feature/removeExpiredPunishements.ts | 2 | ||||
-rw-r--r-- | src/tasks/feature/updateStats.d.ts | 10 | ||||
-rw-r--r-- | src/tasks/feature/updateStats.js | 22 | ||||
-rw-r--r-- | src/tasks/feature/updateStats.js.map | 1 | ||||
-rw-r--r-- | src/tasks/feature/updateStats.ts | 7 |
6 files changed, 36 insertions, 11 deletions
diff --git a/src/tasks/feature/handleReminders.ts b/src/tasks/feature/handleReminders.ts index 1e44083..a9f5658 100644 --- a/src/tasks/feature/handleReminders.ts +++ b/src/tasks/feature/handleReminders.ts @@ -1,5 +1,5 @@ import { BushTask, dateDelta, format, Reminder, Time } from '#lib'; -const { Op } = (await import('sequelize')).default; +import { Op } from 'sequelize'; export default class HandlerRemindersTask extends BushTask { public constructor() { @@ -29,8 +29,7 @@ export default class HandlerRemindersTask extends BushTask { void this.client.users .send( entry.user, - `The reminder you set ${dateDelta(entry.created)} ago has expired: ${format.bold(entry.content)} -${entry.messageUrl}` + `The reminder you set ${dateDelta(entry.created)} ago has expired: ${format.bold(entry.content)}\n${entry.messageUrl}` ) .catch(() => false); void entry.update({ notified: true }); diff --git a/src/tasks/feature/removeExpiredPunishements.ts b/src/tasks/feature/removeExpiredPunishements.ts index c21454b..30b8eba 100644 --- a/src/tasks/feature/removeExpiredPunishements.ts +++ b/src/tasks/feature/removeExpiredPunishements.ts @@ -1,6 +1,6 @@ import { ActivePunishment, ActivePunishmentType, BushTask, Time } from '#lib'; import assert from 'assert/strict'; -const { Op } = (await import('sequelize')).default; +import { Op } from 'sequelize'; export default class RemoveExpiredPunishmentsTask extends BushTask { public constructor() { diff --git a/src/tasks/feature/updateStats.d.ts b/src/tasks/feature/updateStats.d.ts new file mode 100644 index 0000000..1274267 --- /dev/null +++ b/src/tasks/feature/updateStats.d.ts @@ -0,0 +1,10 @@ +import { BushTask } from '#lib'; +import { Client } from 'discord.js'; +export default class UpdateStatsTask extends BushTask { + constructor(); + exec(): Promise<void>; + static init(client: Client): Promise<{ + commandsUsed: bigint; + slashCommandsUsed: bigint; + }>; +} diff --git a/src/tasks/feature/updateStats.js b/src/tasks/feature/updateStats.js new file mode 100644 index 0000000..18a9a7c --- /dev/null +++ b/src/tasks/feature/updateStats.js @@ -0,0 +1,22 @@ +import { BushTask, Stat, Time } from '#lib'; +import { Client } from 'discord.js'; +export default class UpdateStatsTask extends BushTask { + constructor() { + super('updateStats', { + delay: 10 * 60000, + runOnStart: true + }); + } + async exec() { + const row = (await Stat.findByPk(this.client.config.environment)) ?? + (await Stat.create({ environment: this.client.config.environment })); + row.commandsUsed = this.client.stats.commandsUsed; + row.slashCommandsUsed = this.client.stats.slashCommandsUsed; + await row.save(); + } + static async init(client) { + const temp = (await Stat.findByPk(client.config.environment)) ?? (await Stat.create({ environment: client.config.environment })); + return { commandsUsed: temp.commandsUsed, slashCommandsUsed: temp.slashCommandsUsed }; + } +} +//# sourceMappingURL=updateStats.js.map
\ No newline at end of file diff --git a/src/tasks/feature/updateStats.js.map b/src/tasks/feature/updateStats.js.map new file mode 100644 index 0000000..01cd260 --- /dev/null +++ b/src/tasks/feature/updateStats.js.map @@ -0,0 +1 @@ +{"version":3,"file":"updateStats.js","sourceRoot":"","sources":["updateStats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,QAAQ;IACpD;QACC,KAAK,CAAC,aAAa,EAAE;YACpB,KAAK,EAAE,EAAE,QAAc;YACvB,UAAU,EAAE,IAAI;SAChB,CAAC,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,IAAI;QAChB,MAAM,GAAG,GACR,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YACrD,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QACtE,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC;QAClD,GAAG,CAAC,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC;QAC5D,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAClB,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAc;QACtC,MAAM,IAAI,GACT,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QACrH,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACvF,CAAC;CACD"}
\ No newline at end of file diff --git a/src/tasks/feature/updateStats.ts b/src/tasks/feature/updateStats.ts index 0d0e661..77b7c30 100644 --- a/src/tasks/feature/updateStats.ts +++ b/src/tasks/feature/updateStats.ts @@ -1,5 +1,4 @@ import { BushTask, Stat, Time } from '#lib'; -import { Client } from 'discord.js'; export default class UpdateStatsTask extends BushTask { public constructor() { @@ -17,10 +16,4 @@ export default class UpdateStatsTask extends BushTask { row.slashCommandsUsed = this.client.stats.slashCommandsUsed; await row.save(); } - - public static async init(client: Client): Promise<{ commandsUsed: bigint; slashCommandsUsed: bigint }> { - const temp = - (await Stat.findByPk(client.config.environment)) ?? (await Stat.create({ environment: client.config.environment })); - return { commandsUsed: temp.commandsUsed, slashCommandsUsed: temp.slashCommandsUsed }; - } } |