From 661e4c9935aeb8760dafc7ced4bbec6cc356a033 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Tue, 14 Jun 2022 12:47:57 -0400 Subject: 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 --- src/arguments/abbreviatedNumber.ts | 2 +- src/arguments/contentWithDuration.ts | 2 +- src/arguments/discordEmoji.ts | 2 +- src/arguments/duration.ts | 2 +- src/arguments/durationSeconds.ts | 2 +- src/arguments/globalUser.ts | 5 +++-- src/arguments/messageLink.ts | 4 ++-- src/arguments/permission.ts | 2 +- src/arguments/roleWithDuration.ts | 4 ++-- src/arguments/snowflake.ts | 4 ++-- src/arguments/tinyColor.ts | 10 ++++++++++ 11 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 src/arguments/tinyColor.ts (limited to 'src/arguments') 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> = 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 = (_, 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 = (_, 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 = (_, 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> = async (_, phrase) => { +export const globalUser: BushArgumentTypeCaster> = 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> = 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 = (_, 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> = 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 = (_, 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 = (_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; +}; -- cgit