aboutsummaryrefslogtreecommitdiff
path: root/src/tasks/memberCount.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-04-24 23:04:49 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-04-24 23:04:49 -0400
commit40f9581991e12082a2708fa8fdd454c080f67a4b (patch)
tree99160efeb7eff8835099c6adfd4c6bf0a1dd6342 /src/tasks/memberCount.ts
parent5c9ec9e5c5529bae1da0573c9d4edf84ffd986d4 (diff)
downloadtanzanite-40f9581991e12082a2708fa8fdd454c080f67a4b.tar.gz
tanzanite-40f9581991e12082a2708fa8fdd454c080f67a4b.tar.bz2
tanzanite-40f9581991e12082a2708fa8fdd454c080f67a4b.zip
add member ship tracking because I want to make graph
Diffstat (limited to 'src/tasks/memberCount.ts')
-rw-r--r--src/tasks/memberCount.ts26
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);
+ });
+ }
+}