aboutsummaryrefslogtreecommitdiff
path: root/src/arguments/globalUser.ts
blob: 69d3e892618582db30ba62d8d01fb7c1efdebfdd (plain)
1
2
3
4
5
6
7
8
import { type BushArgumentTypeCaster, type BushUser } from '#lib';

// resolve non-cached users
export const globalUser: BushArgumentTypeCaster<Promise<BushUser | null>> = async (_, phrase) => {
	return client.users.cache.has(phrase)
		? client.users.cache.get(`${phrase}`) ?? null
		: await client.users.fetch(`${phrase}`).catch(() => null);
};