aboutsummaryrefslogtreecommitdiff
path: root/src/arguments
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-14 12:47:57 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-14 12:47:57 -0400
commit661e4c9935aeb8760dafc7ced4bbec6cc356a033 (patch)
treebb4c12bdef067d203f100e13e05ccb705b299834 /src/arguments
parenteaf592b72eb5b1d66aa2bde5151a8947570a506c (diff)
downloadtanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.tar.gz
tanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.tar.bz2
tanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.zip
remove the war crimes that I previously committed
- Remove custom typings and replace with declaration merging - Fix the typings for args - Replace all discord-api-types imports with discord.js imports - Fix discord.js breaking changes
Diffstat (limited to 'src/arguments')
-rw-r--r--src/arguments/abbreviatedNumber.ts2
-rw-r--r--src/arguments/contentWithDuration.ts2
-rw-r--r--src/arguments/discordEmoji.ts2
-rw-r--r--src/arguments/duration.ts2
-rw-r--r--src/arguments/durationSeconds.ts2
-rw-r--r--src/arguments/globalUser.ts5
-rw-r--r--src/arguments/messageLink.ts4
-rw-r--r--src/arguments/permission.ts2
-rw-r--r--src/arguments/roleWithDuration.ts4
-rw-r--r--src/arguments/snowflake.ts4
-rw-r--r--src/arguments/tinyColor.ts10
11 files changed, 25 insertions, 14 deletions
diff --git a/src/arguments/abbreviatedNumber.ts b/src/arguments/abbreviatedNumber.ts
index 43d2938..eba9214 100644
--- a/src/arguments/abbreviatedNumber.ts
+++ b/src/arguments/abbreviatedNumber.ts
@@ -1,4 +1,4 @@
-import { type BushArgumentTypeCaster } from '#lib';
+import type { BushArgumentTypeCaster } from '#lib';
import assert from 'assert';
import numeral from 'numeral';
assert(typeof numeral === 'function');
diff --git a/src/arguments/contentWithDuration.ts b/src/arguments/contentWithDuration.ts
index cd8549b..e92997a 100644
--- a/src/arguments/contentWithDuration.ts
+++ b/src/arguments/contentWithDuration.ts
@@ -1,4 +1,4 @@
-import { type BushArgumentTypeCaster, type ParsedDuration } from '#lib';
+import type { BushArgumentTypeCaster, ParsedDuration } from '#lib';
export const contentWithDuration: BushArgumentTypeCaster<Promise<ParsedDuration>> = async (_, phrase) => {
return client.util.parseDuration(phrase);
diff --git a/src/arguments/discordEmoji.ts b/src/arguments/discordEmoji.ts
index 3edf123..57710e4 100644
--- a/src/arguments/discordEmoji.ts
+++ b/src/arguments/discordEmoji.ts
@@ -1,5 +1,5 @@
import type { BushArgumentTypeCaster } from '#lib';
-import type { Snowflake } from 'discord-api-types/v10';
+import type { Snowflake } from 'discord.js';
export const discordEmoji: BushArgumentTypeCaster<DiscordEmojiInfo | null> = (_, phrase) => {
if (!phrase) return null;
diff --git a/src/arguments/duration.ts b/src/arguments/duration.ts
index 58593ef..ffd9159 100644
--- a/src/arguments/duration.ts
+++ b/src/arguments/duration.ts
@@ -1,4 +1,4 @@
-import { type BushArgumentTypeCaster } from '#lib';
+import type { BushArgumentTypeCaster } from '#lib';
export const duration: BushArgumentTypeCaster<number | null> = (_, phrase) => {
return client.util.parseDuration(phrase).duration;
diff --git a/src/arguments/durationSeconds.ts b/src/arguments/durationSeconds.ts
index 74d136f..432fd8c 100644
--- a/src/arguments/durationSeconds.ts
+++ b/src/arguments/durationSeconds.ts
@@ -1,4 +1,4 @@
-import { type BushArgumentTypeCaster } from '#lib';
+import type { BushArgumentTypeCaster } from '#lib';
export const durationSeconds: BushArgumentTypeCaster<number | null> = (_, phrase) => {
phrase += 's';
diff --git a/src/arguments/globalUser.ts b/src/arguments/globalUser.ts
index 08350d2..df4f5d9 100644
--- a/src/arguments/globalUser.ts
+++ b/src/arguments/globalUser.ts
@@ -1,6 +1,7 @@
-import { type BushArgumentTypeCaster, type BushUser } from '#lib';
+import type { BushArgumentTypeCaster } from '#lib';
+import type { User } from 'discord.js';
// resolve non-cached users
-export const globalUser: BushArgumentTypeCaster<Promise<BushUser | null>> = async (_, phrase) => {
+export const globalUser: BushArgumentTypeCaster<Promise<User | null>> = async (_, phrase) => {
return client.users.resolve(phrase) ?? (await client.users.fetch(`${phrase}`).catch(() => null));
};
diff --git a/src/arguments/messageLink.ts b/src/arguments/messageLink.ts
index 5c91a4b..457410e 100644
--- a/src/arguments/messageLink.ts
+++ b/src/arguments/messageLink.ts
@@ -1,5 +1,5 @@
-import { type BushArgumentTypeCaster } from '#lib';
-import { type Message } from 'discord.js';
+import type { BushArgumentTypeCaster } from '#lib';
+import type { Message } from 'discord.js';
export const messageLink: BushArgumentTypeCaster<Promise<Message | null>> = async (_, phrase) => {
const match = new RegExp(client.consts.regex.messageLink).exec(phrase);
diff --git a/src/arguments/permission.ts b/src/arguments/permission.ts
index cf4c42c..98bfe74 100644
--- a/src/arguments/permission.ts
+++ b/src/arguments/permission.ts
@@ -1,4 +1,4 @@
-import { type BushArgumentTypeCaster } from '#lib';
+import type { BushArgumentTypeCaster } from '#lib';
import { PermissionFlagsBits, type PermissionsString } from 'discord.js';
export const permission: BushArgumentTypeCaster<PermissionsString | null> = (_, phrase) => {
diff --git a/src/arguments/roleWithDuration.ts b/src/arguments/roleWithDuration.ts
index 5f1da98..e338b79 100644
--- a/src/arguments/roleWithDuration.ts
+++ b/src/arguments/roleWithDuration.ts
@@ -1,5 +1,5 @@
-import { type BushArgumentTypeCaster } from '#lib';
-import { type Role } from 'discord.js';
+import type { BushArgumentTypeCaster } from '#lib';
+import type { Role } from 'discord.js';
export const roleWithDuration: BushArgumentTypeCaster<Promise<RoleWithDuration | null>> = async (message, phrase) => {
// eslint-disable-next-line prefer-const
diff --git a/src/arguments/snowflake.ts b/src/arguments/snowflake.ts
index 15896ae..dc83909 100644
--- a/src/arguments/snowflake.ts
+++ b/src/arguments/snowflake.ts
@@ -1,5 +1,5 @@
-import { type BushArgumentTypeCaster } from '#lib';
-import { type Snowflake } from 'discord.js';
+import type { BushArgumentTypeCaster } from '#lib';
+import type { Snowflake } from 'discord.js';
export const snowflake: BushArgumentTypeCaster<Snowflake | null> = (_, phrase) => {
if (!phrase) return null;
diff --git a/src/arguments/tinyColor.ts b/src/arguments/tinyColor.ts
new file mode 100644
index 0000000..8d01928
--- /dev/null
+++ b/src/arguments/tinyColor.ts
@@ -0,0 +1,10 @@
+import type { BushArgumentTypeCaster } from '#lib';
+import assert from 'assert';
+import tinycolorModule from 'tinycolor2';
+assert(tinycolorModule);
+
+export const tinyColor: BushArgumentTypeCaster<string | null> = (_message, phrase) => {
+ // if the phase is a number it converts it to hex incase it could be representing a color in decimal
+ const newPhase = isNaN(phrase as any) ? phrase : `#${Number(phrase).toString(16)}`;
+ return tinycolorModule(newPhase).isValid() ? newPhase : null;
+};