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