aboutsummaryrefslogtreecommitdiff
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
parent86cb31c8ec889177393814139dabd49722474cc6 (diff)
downloadtanzanite-e8da6cf4fe2f8ab80167360c6c63a3c701eef101.tar.gz
tanzanite-e8da6cf4fe2f8ab80167360c6c63a3c701eef101.tar.bz2
tanzanite-e8da6cf4fe2f8ab80167360c6c63a3c701eef101.zip
add pm2 metrics and fix abbreviatednumber type caster
-rw-r--r--package.json1
-rw-r--r--src/arguments/abbreviatedNumber.ts7
-rw-r--r--src/lib/extensions/discord-akairo/BushClient.ts6
-rw-r--r--src/tasks/customMetrics.ts14
-rw-r--r--yarn.lock217
5 files changed, 240 insertions, 5 deletions
diff --git a/package.json b/package.json
index e3395fe..5f1f5d3 100644
--- a/package.json
+++ b/package.json
@@ -48,6 +48,7 @@
"dependencies": {
"@discordjs/builders": "^0.6.0",
"@discordjs/voice": "^0.6.0",
+ "@pm2/io": "^5.0.0",
"canvas": "^2.8.0",
"chalk": "^4.1.1",
"common-tags": "^1.8.0",
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);
+ }
+}
diff --git a/yarn.lock b/yarn.lock
index 17fb661..cc0ecc0 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -206,6 +206,60 @@ __metadata:
languageName: node
linkType: hard
+"@opencensus/core@npm:0.0.9":
+ version: 0.0.9
+ resolution: "@opencensus/core@npm:0.0.9"
+ dependencies:
+ continuation-local-storage: ^3.2.1
+ log-driver: ^1.2.7
+ semver: ^5.5.0
+ shimmer: ^1.2.0
+ uuid: ^3.2.1
+ checksum: 37af50394cbf759a835182eedf9fbf328232916bdd2174e75221cf9f29393621d0d05eaf24bb61b89b50c740bc4f625e5c8f891e2db627ce6dbf1888d98857e5
+ languageName: node
+ linkType: hard
+
+"@opencensus/core@npm:^0.0.8":
+ version: 0.0.8
+ resolution: "@opencensus/core@npm:0.0.8"
+ dependencies:
+ continuation-local-storage: ^3.2.1
+ log-driver: ^1.2.7
+ semver: ^5.5.0
+ shimmer: ^1.2.0
+ uuid: ^3.2.1
+ checksum: b4ad6c9a4963407195ab9c2f2751888b1462807c547bd9a7ceb561c473073aacc17555afa9e37cbda01805be5e954085284629e502ed5d3fe7b3c628d9ec2882
+ languageName: node
+ linkType: hard
+
+"@opencensus/propagation-b3@npm:0.0.8":
+ version: 0.0.8
+ resolution: "@opencensus/propagation-b3@npm:0.0.8"
+ dependencies:
+ "@opencensus/core": ^0.0.8
+ uuid: ^3.2.1
+ checksum: c480bd181062ac15f23d5c833a1b1760f2734e013ab7d0bc3fc24d7d1f8330f38f426a56df6d1baf1384727b3dbc1f9ba2851caaac2125500327117fbafa8f70
+ languageName: node
+ linkType: hard
+
+"@pm2/io@npm:^5.0.0":
+ version: 5.0.0
+ resolution: "@pm2/io@npm:5.0.0"
+ dependencies:
+ "@opencensus/core": 0.0.9
+ "@opencensus/propagation-b3": 0.0.8
+ async: ~2.6.1
+ debug: ~4.3.1
+ eventemitter2: ^6.3.1
+ require-in-the-middle: ^5.0.0
+ semver: 6.3.0
+ shimmer: ^1.2.0
+ signal-exit: ^3.0.3
+ tslib: 1.9.3
+ checksum: f912096e823003de941a539d1098243cdc39b896704dea176e75a1d4fb0e0573b552c0a30e5198c2415fee9e1d8365ce0a8e78257eb85a8bfb994f1fb8153af1
+ languageName: node
+ linkType: hard
+
"@sapphire/async-queue@npm:^1.1.4":
version: 1.1.4
resolution: "@sapphire/async-queue@npm:1.1.4"
@@ -713,6 +767,25 @@ __metadata:
languageName: node
linkType: hard
+"async-listener@npm:^0.6.0":
+ version: 0.6.10
+ resolution: "async-listener@npm:0.6.10"
+ dependencies:
+ semver: ^5.3.0
+ shimmer: ^1.1.0
+ checksum: f64cb835ad1a07d4ee800df6c1532f2a4f99e1c2a11da8e83c1bd4452bc01729a85552377bc120f144abc17be6c0bd0f740ebedfdf4b79ebd18844a51e307326
+ languageName: node
+ linkType: hard
+
+"async@npm:~2.6.1":
+ version: 2.6.3
+ resolution: "async@npm:2.6.3"
+ dependencies:
+ lodash: ^4.17.14
+ checksum: 5e5561ff8fca807e88738533d620488ac03a5c43fce6c937451f7e35f943d33ad06c24af3f681a48cca3d2b0002b3118faff0a128dc89438a9bf0226f712c499
+ languageName: node
+ linkType: hard
+
"asynckit@npm:^0.4.0":
version: 0.4.0
resolution: "asynckit@npm:0.4.0"
@@ -766,6 +839,7 @@ __metadata:
dependencies:
"@discordjs/builders": ^0.6.0
"@discordjs/voice": ^0.6.0
+ "@pm2/io": ^5.0.0
"@types/common-tags": ^1.8.0
"@types/express": ^4.17.12
"@types/humanize-duration": ^3
@@ -1009,6 +1083,16 @@ __metadata:
languageName: node
linkType: hard
+"continuation-local-storage@npm:^3.2.1":
+ version: 3.2.1
+ resolution: "continuation-local-storage@npm:3.2.1"
+ dependencies:
+ async-listener: ^0.6.0
+ emitter-listener: ^1.1.1
+ checksum: 5ac1dcf354563a7121fc1653676ed8dda93565c469698dd7454c3485d9e2c3ca61347d754d02179d13d9e51665d23fffe6bf9e53e89a1865a0c5530384258c2f
+ languageName: node
+ linkType: hard
+
"core-util-is@npm:~1.0.0":
version: 1.0.3
resolution: "core-util-is@npm:1.0.3"
@@ -1027,7 +1111,7 @@ __metadata:
languageName: node
linkType: hard
-"debug@npm:4, debug@npm:^4.0.1, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.1":
+"debug@npm:4, debug@npm:^4.0.1, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.1, debug@npm:~4.3.1":
version: 4.3.2
resolution: "debug@npm:4.3.2"
dependencies:
@@ -1190,6 +1274,15 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
+"emitter-listener@npm:^1.1.1":
+ version: 1.1.2
+ resolution: "emitter-listener@npm:1.1.2"
+ dependencies:
+ shimmer: ^1.2.0
+ checksum: 05166bad42a27e51a765ebac3b7d26ac111564fc2d36443cd819f95ef88ea1b9ba6f2895becbcea36f8009890a2a8cb7c36eb9e776d4978e370bd33cb0a181e8
+ languageName: node
+ linkType: hard
+
"emoji-regex@npm:^8.0.0":
version: 8.0.0
resolution: "emoji-regex@npm:8.0.0"
@@ -1433,6 +1526,13 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
+"eventemitter2@npm:^6.3.1":
+ version: 6.4.4
+ resolution: "eventemitter2@npm:6.4.4"
+ checksum: b5e707039973d5a770bc4c64255604df66df3a1f63389dccb7118af163b9f790ca7596463d7868426339301ad9de5ef1c3f4a9c7ac3b93874c5ca792916dede1
+ languageName: node
+ linkType: hard
+
"events-intercept@npm:^2.0.0":
version: 2.0.0
resolution: "events-intercept@npm:2.0.0"
@@ -1552,6 +1652,13 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
+"function-bind@npm:^1.1.1":
+ version: 1.1.1
+ resolution: "function-bind@npm:1.1.1"
+ checksum: b32fbaebb3f8ec4969f033073b43f5c8befbb58f1a79e12f1d7490358150359ebd92f49e72ff0144f65f2c48ea2a605bff2d07965f548f6474fd8efd95bf361a
+ languageName: node
+ linkType: hard
+
"functional-red-black-tree@npm:^1.0.1":
version: 1.0.1
resolution: "functional-red-black-tree@npm:1.0.1"
@@ -1684,6 +1791,15 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
+"has@npm:^1.0.3":
+ version: 1.0.3
+ resolution: "has@npm:1.0.3"
+ dependencies:
+ function-bind: ^1.1.1
+ checksum: b9ad53d53be4af90ce5d1c38331e712522417d017d5ef1ebd0507e07c2fbad8686fffb8e12ddecd4c39ca9b9b47431afbb975b8abf7f3c3b82c98e9aad052792
+ languageName: node
+ linkType: hard
+
"http-cache-semantics@npm:^4.0.0, http-cache-semantics@npm:^4.1.0":
version: 4.1.0
resolution: "http-cache-semantics@npm:4.1.0"
@@ -1823,6 +1939,15 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
+"is-core-module@npm:^2.2.0":
+ version: 2.6.0
+ resolution: "is-core-module@npm:2.6.0"
+ dependencies:
+ has: ^1.0.3
+ checksum: 183b3b96fed19822b13959876b0317e61fc2cb5ebcbc21639904c81f7ae328af57f8e18cc4750a9c4abebd686130c70d34a89521e57dbe002edfa4614507ce18
+ languageName: node
+ linkType: hard
+
"is-extglob@npm:^2.1.1":
version: 2.1.1
resolution: "is-extglob@npm:2.1.1"
@@ -2009,13 +2134,20 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
-"lodash@npm:^4.17.20, lodash@npm:^4.17.21":
+"lodash@npm:^4.17.14, lodash@npm:^4.17.20, lodash@npm:^4.17.21":
version: 4.17.21
resolution: "lodash@npm:4.17.21"
checksum: eb835a2e51d381e561e508ce932ea50a8e5a68f4ebdd771ea240d3048244a8d13658acbd502cd4829768c56f2e16bdd4340b9ea141297d472517b83868e677f7
languageName: node
linkType: hard
+"log-driver@npm:^1.2.7":
+ version: 1.2.7
+ resolution: "log-driver@npm:1.2.7"
+ checksum: 14949119f830d897f52a0f83b058d8af3d13b9d21deedcc341c65c523091d4f95b0c151798b0bb988ed2712f487d9d44c302cd95b177708a80ac8e47a6a28a16
+ languageName: node
+ linkType: hard
+
"lowercase-keys@npm:^2.0.0":
version: 2.0.0
resolution: "lowercase-keys@npm:2.0.0"
@@ -2239,6 +2371,13 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
+"module-details-from-path@npm:^1.0.3":
+ version: 1.0.3
+ resolution: "module-details-from-path@npm:1.0.3"
+ checksum: 378a8a26013889aa3086bfb0776b7860c5bb957336253e1ba5d779c2f239a218930b145ca76e52c1dd7c8079d52b2af64b8eec30822f81ffdb0dfa27d6fe6f33
+ languageName: node
+ linkType: hard
+
"moment-timezone@npm:^0.5.31":
version: 0.5.33
resolution: "moment-timezone@npm:0.5.33"
@@ -2446,6 +2585,13 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
+"path-parse@npm:^1.0.6":
+ version: 1.0.7
+ resolution: "path-parse@npm:1.0.7"
+ checksum: 49abf3d81115642938a8700ec580da6e830dde670be21893c62f4e10bd7dd4c3742ddc603fe24f898cba7eb0c6bc1777f8d9ac14185d34540c6d4d80cd9cae8a
+ languageName: node
+ linkType: hard
+
"path-type@npm:^4.0.0":
version: 4.0.0
resolution: "path-type@npm:4.0.0"
@@ -2717,6 +2863,17 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
+"require-in-the-middle@npm:^5.0.0":
+ version: 5.1.0
+ resolution: "require-in-the-middle@npm:5.1.0"
+ dependencies:
+ debug: ^4.1.1
+ module-details-from-path: ^1.0.3
+ resolve: ^1.12.0
+ checksum: 375f2e4b822c3fac5d65613082d93d5f9451cdbfb1cdfaf757febe2983aac3525ea5b8f95a10f2ee8304e6328d304d3c885830e255209d359faf66e5a3aa62e8
+ languageName: node
+ linkType: hard
+
"resolve-alpn@npm:^1.0.0":
version: 1.2.1
resolution: "resolve-alpn@npm:1.2.1"
@@ -2731,6 +2888,26 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
+resolve@^1.12.0:
+ version: 1.20.0
+ resolution: "resolve@npm:1.20.0"
+ dependencies:
+ is-core-module: ^2.2.0
+ path-parse: ^1.0.6
+ checksum: 40cf70b2cde00ef57f99daf2dc63c6a56d6c14a1b7fc51735d06a6f0a3b97cb67b4fb7ef6c747b4e13a7baba83b0ef625d7c4ce92a483cd5af923c3b65fd16fe
+ languageName: node
+ linkType: hard
+
+"resolve@patch:resolve@^1.12.0#~builtin<compat/resolve>":
+ version: 1.20.0
+ resolution: "resolve@patch:resolve@npm%3A1.20.0#~builtin<compat/resolve>::version=1.20.0&hash=00b1ff"
+ dependencies:
+ is-core-module: ^2.2.0
+ path-parse: ^1.0.6
+ checksum: bed00be983cd20a8af0e7840664f655c4b269786dbd9595c5f156cd9d8a0050e65cdbbbdafc30ee9b6245b230c78a2c8ab6447a52545b582f476c29adb188cc5
+ languageName: node
+ linkType: hard
+
"responselike@npm:^2.0.0":
version: 2.0.0
resolution: "responselike@npm:2.0.0"
@@ -2811,7 +2988,7 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
-"semver@npm:^6.0.0":
+"semver@npm:6.3.0, semver@npm:^6.0.0":
version: 6.3.0
resolution: "semver@npm:6.3.0"
bin:
@@ -2820,6 +2997,15 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
+"semver@npm:^5.3.0, semver@npm:^5.5.0":
+ version: 5.7.1
+ resolution: "semver@npm:5.7.1"
+ bin:
+ semver: ./bin/semver
+ checksum: 57fd0acfd0bac382ee87cd52cd0aaa5af086a7dc8d60379dfe65fea491fb2489b6016400813930ecd61fd0952dae75c115287a1b16c234b1550887117744dfaf
+ languageName: node
+ linkType: hard
+
"semver@npm:^7.2.1, semver@npm:^7.3.2, semver@npm:^7.3.4, semver@npm:^7.3.5":
version: 7.3.5
resolution: "semver@npm:7.3.5"
@@ -2895,7 +3081,14 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
-"signal-exit@npm:^3.0.0":
+"shimmer@npm:^1.1.0, shimmer@npm:^1.2.0":
+ version: 1.2.1
+ resolution: "shimmer@npm:1.2.1"
+ checksum: aa0d6252ad1c682a4fdfda69e541be987f7a265ac7b00b1208e5e48cc68dc55f293955346ea4c71a169b7324b82c70f8400b3d3d2d60b2a7519f0a3522423250
+ languageName: node
+ linkType: hard
+
+"signal-exit@npm:^3.0.0, signal-exit@npm:^3.0.3":
version: 3.0.3
resolution: "signal-exit@npm:3.0.3"
checksum: f0169d3f1263d06df32ca072b0bf33b34c6f8f0341a7a1621558a2444dfbe8f5fec76b35537fcc6f0bc4944bdb5336fe0bdcf41a5422c4e45a1dba3f45475e6c
@@ -3196,6 +3389,13 @@ discord.js@NotEnoughUpdates/discord.js:
languageName: node
linkType: hard
+"tslib@npm:1.9.3":
+ version: 1.9.3
+ resolution: "tslib@npm:1.9.3"
+ checksum: 56ef6325adb72c6477fb48256304507a2c475d69d7ead4644d61f5685fac2a275a38cf217c556e63fc3c177e729426d730e2c2e71c8042dc6cc57338a849edb2
+ languageName: node
+ linkType: hard
+
"tslib@npm:^1.8.1":
version: 1.14.1
resolution: "tslib@npm:1.14.1"
@@ -3312,6 +3512,15 @@ typescript@^4.4.2:
languageName: node
linkType: hard
+"uuid@npm:^3.2.1":
+ version: 3.4.0
+ resolution: "uuid@npm:3.4.0"
+ bin:
+ uuid: ./bin/uuid
+ checksum: 58de2feed61c59060b40f8203c0e4ed7fd6f99d42534a499f1741218a1dd0c129f4aa1de797bcf822c8ea5da7e4137aa3673431a96dae729047f7aca7b27866f
+ languageName: node
+ linkType: hard
+
"uuid@npm:^8.1.0, uuid@npm:^8.3.2":
version: 8.3.2
resolution: "uuid@npm:8.3.2"