aboutsummaryrefslogtreecommitdiff
path: root/src/arguments
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-08-20 12:29:20 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-08-20 12:29:20 -0400
commit7048fb1d6d24a26d4e0fdadc2f75bd0717fa80f9 (patch)
tree3b66ea2934c577c0e827ba279cf32b514389236c /src/arguments
parentbfb467c3bed23479673b82eba61c05d60acf42d7 (diff)
downloadtanzanite-7048fb1d6d24a26d4e0fdadc2f75bd0717fa80f9.tar.gz
tanzanite-7048fb1d6d24a26d4e0fdadc2f75bd0717fa80f9.tar.bz2
tanzanite-7048fb1d6d24a26d4e0fdadc2f75bd0717fa80f9.zip
more pain
Diffstat (limited to 'src/arguments')
-rw-r--r--src/arguments/contentWithDuration.ts6
-rw-r--r--src/arguments/discordEmoji.ts17
-rw-r--r--src/arguments/duration.ts4
-rw-r--r--src/arguments/snowflake.ts8
4 files changed, 30 insertions, 5 deletions
diff --git a/src/arguments/contentWithDuration.ts b/src/arguments/contentWithDuration.ts
index 314b761..38b3fa4 100644
--- a/src/arguments/contentWithDuration.ts
+++ b/src/arguments/contentWithDuration.ts
@@ -1,8 +1,8 @@
-import { BushArgumentTypeCaster, BushMessage } from '@lib';
+import { BushArgumentTypeCaster } from '@lib';
export const contentWithDurationTypeCaster: BushArgumentTypeCaster = async (
- _message: BushMessage,
- phrase: string
+ _,
+ phrase
): Promise<{ duration: number; contentWithoutTime: string | null }> => {
return client.util.parseDuration(phrase);
};
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 };
+};
diff --git a/src/arguments/duration.ts b/src/arguments/duration.ts
index ce181e8..6e76034 100644
--- a/src/arguments/duration.ts
+++ b/src/arguments/duration.ts
@@ -1,5 +1,5 @@
-import { BushArgumentTypeCaster, BushMessage } from '@lib';
+import { BushArgumentTypeCaster } from '@lib';
-export const durationTypeCaster: BushArgumentTypeCaster = (_message: BushMessage, phrase): number => {
+export const durationTypeCaster: BushArgumentTypeCaster = (_, phrase): number => {
return client.util.parseDuration(phrase).duration;
};
diff --git a/src/arguments/snowflake.ts b/src/arguments/snowflake.ts
new file mode 100644
index 0000000..0e6136f
--- /dev/null
+++ b/src/arguments/snowflake.ts
@@ -0,0 +1,8 @@
+import { Snowflake } from 'discord.js';
+import { BushArgumentTypeCaster } from '../lib';
+
+export const snowflakeTypeCaster: BushArgumentTypeCaster = (_, phrase): Snowflake | null => {
+ if (!phrase) return null;
+ if (client.consts.regex.snowflake.test(phrase)) return phrase;
+ return null;
+};