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

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