blob: 999ac1cd6b2ec5b66bdcdb1e8827c3467a03d19c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import { type BushArgumentTypeCaster } from '#lib';
import { Role } from 'discord.js';
export const roleWithDuration: BushArgumentTypeCaster = async (message, phrase): Promise<RoleWithDuration | 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 };
};
export interface RoleWithDuration {
duration: number | null;
role: Role | null;
}
|