aboutsummaryrefslogtreecommitdiff
path: root/src/arguments/discordEmoji.ts
blob: 47e734d733e5281a2c9d976e0f02e3c442a8909d (plain)
1
2
3
4
5
6
7
8
9
import { Snowflake } from 'discord-api-types';
import { BushArgumentTypeCaster } from '../lib';

export const discordEmojiTypeCaster: BushArgumentTypeCaster = (_, phrase): { name: string; id: Snowflake } | null => {
	if (!phrase) return null;
	const validEmoji: RegExpExecArray | null = client.consts.regex.discordEmoji.exec(phrase);
	if (!validEmoji || !validEmoji.groups) return null;
	return { name: validEmoji.groups.name, id: validEmoji.groups.id };
};