diff options
Diffstat (limited to 'src/arguments/discordEmoji.ts')
-rw-r--r-- | src/arguments/discordEmoji.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/arguments/discordEmoji.ts b/src/arguments/discordEmoji.ts new file mode 100644 index 0000000..47e734d --- /dev/null +++ b/src/arguments/discordEmoji.ts @@ -0,0 +1,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 }; +}; |