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

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