aboutsummaryrefslogtreecommitdiff
path: root/src/arguments/globalUser.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/arguments/globalUser.ts')
-rw-r--r--src/arguments/globalUser.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/arguments/globalUser.ts b/src/arguments/globalUser.ts
new file mode 100644
index 0000000..3a71732
--- /dev/null
+++ b/src/arguments/globalUser.ts
@@ -0,0 +1,8 @@
+import { BushArgumentTypeCaster, BushUser } from '@lib';
+
+// resolve non-cached users
+export const globalUserTypeCaster: BushArgumentTypeCaster = async (_, phrase): Promise<BushUser | null> => {
+ return client.users.cache.has(phrase)
+ ? client.users.cache.get(`${phrase}`) ?? null
+ : await client.users.fetch(`${phrase}`).catch(() => null);
+};