aboutsummaryrefslogtreecommitdiff
path: root/src/arguments/globalUser.ts
blob: 4324aa9a72e225e75bf56f071408222634167aa5 (plain)
1
2
3
4
5
6
7
import type { BushArgumentTypeCaster } from '#lib';
import type { User } from 'discord.js';

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