aboutsummaryrefslogtreecommitdiff
path: root/src/arguments
diff options
context:
space:
mode:
Diffstat (limited to 'src/arguments')
-rw-r--r--src/arguments/abbreviatedNumber.ts13
-rw-r--r--src/arguments/contentWithDuration.ts5
-rw-r--r--src/arguments/discordEmoji.ts14
-rw-r--r--src/arguments/duration.ts5
-rw-r--r--src/arguments/durationSeconds.ts6
-rw-r--r--src/arguments/globalUser.ts7
-rw-r--r--src/arguments/index.ts10
-rw-r--r--src/arguments/messageLink.ts20
-rw-r--r--src/arguments/permission.ts12
-rw-r--r--src/arguments/roleWithDuration.ts17
-rw-r--r--src/arguments/snowflake.ts8
-rw-r--r--src/arguments/tinyColor.ts10
12 files changed, 0 insertions, 127 deletions
diff --git a/src/arguments/abbreviatedNumber.ts b/src/arguments/abbreviatedNumber.ts
deleted file mode 100644
index a7d8ce5..0000000
--- a/src/arguments/abbreviatedNumber.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import type { BushArgumentTypeCaster } from '#lib';
-import assert from 'assert/strict';
-import numeral from 'numeral';
-assert(typeof numeral === 'function');
-
-export const abbreviatedNumber: BushArgumentTypeCaster<number | null> = (_, phrase) => {
- if (!phrase) return null;
- const num = numeral(phrase?.toLowerCase()).value();
-
- if (typeof num !== 'number' || isNaN(num)) return null;
-
- return num;
-};
diff --git a/src/arguments/contentWithDuration.ts b/src/arguments/contentWithDuration.ts
deleted file mode 100644
index 0efba39..0000000
--- a/src/arguments/contentWithDuration.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { parseDuration, type BushArgumentTypeCaster, type ParsedDuration } from '#lib';
-
-export const contentWithDuration: BushArgumentTypeCaster<Promise<ParsedDuration>> = async (_, phrase) => {
- return parseDuration(phrase);
-};
diff --git a/src/arguments/discordEmoji.ts b/src/arguments/discordEmoji.ts
deleted file mode 100644
index 92d6502..0000000
--- a/src/arguments/discordEmoji.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { regex, type BushArgumentTypeCaster } from '#lib';
-import type { Snowflake } from 'discord.js';
-
-export const discordEmoji: BushArgumentTypeCaster<DiscordEmojiInfo | null> = (_, phrase) => {
- if (!phrase) return null;
- const validEmoji: RegExpExecArray | null = regex.discordEmoji.exec(phrase);
- if (!validEmoji || !validEmoji.groups) return null;
- return { name: validEmoji.groups.name, id: validEmoji.groups.id };
-};
-
-export interface DiscordEmojiInfo {
- name: string;
- id: Snowflake;
-}
diff --git a/src/arguments/duration.ts b/src/arguments/duration.ts
deleted file mode 100644
index 09dd3d5..0000000
--- a/src/arguments/duration.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { parseDuration, type BushArgumentTypeCaster } from '#lib';
-
-export const duration: BushArgumentTypeCaster<number | null> = (_, phrase) => {
- return parseDuration(phrase).duration;
-};
diff --git a/src/arguments/durationSeconds.ts b/src/arguments/durationSeconds.ts
deleted file mode 100644
index d8d6749..0000000
--- a/src/arguments/durationSeconds.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { parseDuration, type BushArgumentTypeCaster } from '#lib';
-
-export const durationSeconds: BushArgumentTypeCaster<number | null> = (_, phrase) => {
- phrase += 's';
- return parseDuration(phrase).duration;
-};
diff --git a/src/arguments/globalUser.ts b/src/arguments/globalUser.ts
deleted file mode 100644
index 4324aa9..0000000
--- a/src/arguments/globalUser.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import type { BushArgumentTypeCaster } from '#lib';
-import type { User } from 'discord.js';
-
-// resolve non-cached users
-export const globalUser: BushArgumentTypeCaster<Promise<User | null>> = async (message, phrase) => {
- return message.client.users.resolve(phrase) ?? (await message.client.users.fetch(`${phrase}`).catch(() => null));
-};
diff --git a/src/arguments/index.ts b/src/arguments/index.ts
deleted file mode 100644
index eebf0a2..0000000
--- a/src/arguments/index.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export * from './abbreviatedNumber.js';
-export * from './contentWithDuration.js';
-export * from './discordEmoji.js';
-export * from './duration.js';
-export * from './durationSeconds.js';
-export * from './globalUser.js';
-export * from './messageLink.js';
-export * from './permission.js';
-export * from './roleWithDuration.js';
-export * from './snowflake.js';
diff --git a/src/arguments/messageLink.ts b/src/arguments/messageLink.ts
deleted file mode 100644
index c95e42d..0000000
--- a/src/arguments/messageLink.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { BushArgumentTypeCaster, regex } from '#lib';
-import type { Message } from 'discord.js';
-
-export const messageLink: BushArgumentTypeCaster<Promise<Message | null>> = async (message, phrase) => {
- const match = new RegExp(regex.messageLink).exec(phrase);
- if (!match || !match.groups) return null;
-
- const { guild_id, channel_id, message_id } = match.groups;
-
- if (!guild_id || !channel_id || message_id) return null;
-
- const guild = message.client.guilds.cache.get(guild_id);
- if (!guild) return null;
-
- const channel = guild.channels.cache.get(channel_id);
- if (!channel || (!channel.isTextBased() && !channel.isThread())) return null;
-
- const msg = await channel.messages.fetch(message_id).catch(() => null);
- return msg;
-};
diff --git a/src/arguments/permission.ts b/src/arguments/permission.ts
deleted file mode 100644
index 98bfe74..0000000
--- a/src/arguments/permission.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import type { BushArgumentTypeCaster } from '#lib';
-import { PermissionFlagsBits, type PermissionsString } from 'discord.js';
-
-export const permission: BushArgumentTypeCaster<PermissionsString | null> = (_, phrase) => {
- if (!phrase) return null;
- phrase = phrase.toUpperCase().replace(/ /g, '_');
- if (!(phrase in PermissionFlagsBits)) {
- return null;
- } else {
- return phrase as PermissionsString;
- }
-};
diff --git a/src/arguments/roleWithDuration.ts b/src/arguments/roleWithDuration.ts
deleted file mode 100644
index b97f205..0000000
--- a/src/arguments/roleWithDuration.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { Arg, BushArgumentTypeCaster, parseDuration } from '#lib';
-import type { Role } from 'discord.js';
-
-export const roleWithDuration: BushArgumentTypeCaster<Promise<RoleWithDuration | null>> = async (message, phrase) => {
- // eslint-disable-next-line prefer-const
- let { duration, content } = parseDuration(phrase);
- if (content === null || content === undefined) return null;
- content = content.trim();
- const role = await Arg.cast('role', message, content);
- if (!role) return null;
- return { duration, role };
-};
-
-export interface RoleWithDuration {
- duration: number | null;
- role: Role | null;
-}
diff --git a/src/arguments/snowflake.ts b/src/arguments/snowflake.ts
deleted file mode 100644
index b98a20f..0000000
--- a/src/arguments/snowflake.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { BushArgumentTypeCaster, regex } from '#lib';
-import type { Snowflake } from 'discord.js';
-
-export const snowflake: BushArgumentTypeCaster<Snowflake | null> = (_, phrase) => {
- if (!phrase) return null;
- if (regex.snowflake.test(phrase)) return phrase;
- return null;
-};
diff --git a/src/arguments/tinyColor.ts b/src/arguments/tinyColor.ts
deleted file mode 100644
index 148c078..0000000
--- a/src/arguments/tinyColor.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import type { BushArgumentTypeCaster } from '#lib';
-import assert from 'assert/strict';
-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;
-};