aboutsummaryrefslogtreecommitdiff
path: root/src/arguments/roleWithDuration.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-11-01 15:40:31 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-11-01 15:40:31 -0400
commit13894f2beffc776a56ac03868613b4313dfb57bf (patch)
tree028c229b42c2a74a3c511386f594385d3ed77dd5 /src/arguments/roleWithDuration.ts
parent914c4d3cb7f02a0c74b677e67a47fb66a65fb724 (diff)
downloadtanzanite-13894f2beffc776a56ac03868613b4313dfb57bf.tar.gz
tanzanite-13894f2beffc776a56ac03868613b4313dfb57bf.tar.bz2
tanzanite-13894f2beffc776a56ac03868613b4313dfb57bf.zip
convert to esm
Diffstat (limited to 'src/arguments/roleWithDuration.ts')
-rw-r--r--src/arguments/roleWithDuration.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/arguments/roleWithDuration.ts b/src/arguments/roleWithDuration.ts
new file mode 100644
index 0000000..455ad76
--- /dev/null
+++ b/src/arguments/roleWithDuration.ts
@@ -0,0 +1,14 @@
+import { type BushArgumentTypeCaster } from '#lib';
+
+export const roleWithDurationTypeCaster: BushArgumentTypeCaster = async (
+ message,
+ phrase
+): Promise<{ duration: number | null; role: string | null } | null> => {
+ // eslint-disable-next-line prefer-const
+ let { duration, contentWithoutTime } = client.util.parseDuration(phrase);
+ if (contentWithoutTime === null || contentWithoutTime === undefined) return null;
+ contentWithoutTime = contentWithoutTime.trim();
+ const role = await util.arg.cast('role', message, contentWithoutTime);
+ if (!role) return null;
+ return { duration, role };
+};