diff options
Diffstat (limited to 'src/tasks/stats/memberCount.ts')
-rw-r--r-- | src/tasks/stats/memberCount.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/tasks/stats/memberCount.ts b/src/tasks/stats/memberCount.ts new file mode 100644 index 0000000..9c31c5b --- /dev/null +++ b/src/tasks/stats/memberCount.ts @@ -0,0 +1,28 @@ +import { BushTask, MemberCount, Time } from '#lib'; +import assert from 'assert/strict'; + +export default class MemberCountTask extends BushTask { + public constructor() { + super('memberCount', { + delay: Time.Minute, + runOnStart: true + }); + } + + public override async exec() { + if (!this.client.config.isProduction) return; + + const res = await Promise.allSettled( + this.client.guilds.cache + .filter((g) => g.memberCount >= 100) + .map((g) => MemberCount.create({ guildId: g.id, memberCount: g.memberCount })) + ); + + res + .filter((r) => r.status === 'rejected') + .forEach((r) => { + assert(r.status === 'rejected'); + void this.client.console.error('memberCount', r.status); + }); + } +} |