aboutsummaryrefslogtreecommitdiff
path: root/src/arguments/roleWithDuration.ts
diff options
context:
space:
mode:
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 };
+};