aboutsummaryrefslogtreecommitdiff
path: root/src/arguments/globalUser.ts
blob: 89e83248f3a94ebc3353537bab6a0e13c948a80b (plain)
1
2
3
4
5
6
7
8
import { BushUser, type BushArgumentTypeCaster } 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);
};