aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-03 17:43:03 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-03 17:43:03 -0400
commite8da6cf4fe2f8ab80167360c6c63a3c701eef101 (patch)
treed9e0776bbfeec49148b593ff938c3f81105a8db9 /src
parent86cb31c8ec889177393814139dabd49722474cc6 (diff)
downloadtanzanite-e8da6cf4fe2f8ab80167360c6c63a3c701eef101.tar.gz
tanzanite-e8da6cf4fe2f8ab80167360c6c63a3c701eef101.tar.bz2
tanzanite-e8da6cf4fe2f8ab80167360c6c63a3c701eef101.zip
add pm2 metrics and fix abbreviatednumber type caster
Diffstat (limited to 'src')
-rw-r--r--src/arguments/abbreviatedNumber.ts7
-rw-r--r--src/lib/extensions/discord-akairo/BushClient.ts6
-rw-r--r--src/tasks/customMetrics.ts14
3 files changed, 26 insertions, 1 deletions
diff --git a/src/arguments/abbreviatedNumber.ts b/src/arguments/abbreviatedNumber.ts
index 9da7063..99f6df7 100644
--- a/src/arguments/abbreviatedNumber.ts
+++ b/src/arguments/abbreviatedNumber.ts
@@ -2,5 +2,10 @@ import { BushArgumentTypeCaster } from '@lib';
import numeral = require('numeral');
export const abbreviatedNumberTypeCaster: BushArgumentTypeCaster = (_, phrase): number | null => {
- return numeral(phrase?.toLowerCase()).value();
+ if (!phrase) return null;
+ const num = numeral(phrase?.toLowerCase()).value();
+
+ if (!num || isNaN(num)) return null;
+
+ return num;
};
diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts
index ab66f60..e89ff0a 100644
--- a/src/lib/extensions/discord-akairo/BushClient.ts
+++ b/src/lib/extensions/discord-akairo/BushClient.ts
@@ -1,3 +1,4 @@
+import io from '@pm2/io';
import chalk from 'chalk';
import { AkairoClient, ContextMenuCommandHandler } from 'discord-akairo';
import {
@@ -137,6 +138,11 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
public declare user: If<Ready, BushClientUser>;
public declare users: BushUserManager;
+ public metrics = {
+ guilds: io.metric({ name: 'guilds', id: 'bushbot/guilds' }),
+ users: io.metric({ name: 'users', id: 'bushbot/users' })
+ };
+
public config: Config;
public listenerHandler: BushListenerHandler;
public inhibitorHandler: BushInhibitorHandler;
diff --git a/src/tasks/customMetrics.ts b/src/tasks/customMetrics.ts
new file mode 100644
index 0000000..2d8a9ca
--- /dev/null
+++ b/src/tasks/customMetrics.ts
@@ -0,0 +1,14 @@
+import { BushTask } from '@lib';
+
+export default class RemoveExpiredPunishmentsTask extends BushTask {
+ public constructor() {
+ super('removeExpiredPunishments', {
+ delay: 10_000, // 10 seconds
+ runOnStart: true
+ });
+ }
+ public override async exec(): Promise<void> {
+ client.metrics.guilds.set(client.guilds.cache.size);
+ client.metrics.users.set(client.users.cache.size);
+ }
+}