aboutsummaryrefslogtreecommitdiff
path: root/src/arguments/discordEmoji.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/arguments/discordEmoji.ts')
-rw-r--r--src/arguments/discordEmoji.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/arguments/discordEmoji.ts b/src/arguments/discordEmoji.ts
new file mode 100644
index 0000000..9884c98
--- /dev/null
+++ b/src/arguments/discordEmoji.ts
@@ -0,0 +1,17 @@
+import { Snowflake } from 'discord-api-types';
+import { BushArgumentTypeCaster } from '../lib';
+
+export const discordEmojiTypeCaster: BushArgumentTypeCaster = (
+ _,
+ phrase
+): { name: string; id: Snowflake; animated: boolean } | null => {
+ console.log(phrase);
+ if (!phrase) return null;
+ const validEmoji = client.consts.regex.discordEmoji.test(phrase);
+ console.log(validEmoji);
+ if (!validEmoji) return null;
+ const emoji = phrase.replace(/[<>]/g, '').split(':');
+ const animated = emoji[0] === 'a';
+ console.log(emoji);
+ return { name: emoji[1], id: emoji[2], animated };
+};