aboutsummaryrefslogtreecommitdiff
path: root/src/commands/info/color.ts
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/commands/info/color.ts
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/commands/info/color.ts')
-rw-r--r--src/commands/info/color.ts33
1 files changed, 7 insertions, 26 deletions
diff --git a/src/commands/info/color.ts b/src/commands/info/color.ts
index a74c3f3..f60e28a 100644
--- a/src/commands/info/color.ts
+++ b/src/commands/info/color.ts
@@ -1,25 +1,9 @@
-import {
- AllowedMentions,
- BushCommand,
- type ArgType,
- type BushArgumentTypeCaster,
- type BushGuildMember,
- type BushMessage,
- type BushRole,
- type BushSlashMessage
-} from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
-import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits, Role } from 'discord.js';
+import { ApplicationCommandOptionType, EmbedBuilder, GuildMember, PermissionFlagsBits, Role } from 'discord.js';
import tinycolor from 'tinycolor2';
-
assert(tinycolor);
-const isValidTinyColor: BushArgumentTypeCaster<string | null> = (_message, phase) => {
- // if the phase is a number it converts it to hex incase it could be representing a color in decimal
- const newPhase = isNaN(phase as any) ? phase : `#${Number(phase).toString(16)}`;
- return tinycolor(newPhase).isValid() ? newPhase : null;
-};
-
export default class ColorCommand extends BushCommand {
public constructor() {
super('color', {
@@ -32,7 +16,7 @@ export default class ColorCommand extends BushCommand {
{
id: 'color',
description: 'The color string, role, or member to find the color of.',
- type: util.arg.union(isValidTinyColor as any, 'role', 'member'),
+ type: util.arg.union('tinyColor', 'role', 'member'),
readableType: 'color|role|member',
match: 'restContent',
prompt: 'What color code, role, or user would you like to find the color of?',
@@ -50,15 +34,12 @@ export default class ColorCommand extends BushCommand {
return color.substring(4, color.length - 5);
}
- public override async exec(
- message: BushMessage | BushSlashMessage,
- args: { color: string | ArgType<'role'> | ArgType<'member'> }
- ) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { color: ArgType<'tinyColor' | 'role' | 'member'> }) {
const _color = message.util.isSlashMessage(message)
- ? ((await util.arg.cast(util.arg.union(isValidTinyColor, 'role', 'member'), message, args.color as string)) as
+ ? ((await util.arg.cast(util.arg.union('tinyColor', 'role', 'member'), message, args.color as string)) as
| string
- | BushRole
- | BushGuildMember)
+ | Role
+ | GuildMember)
: args.color;
const color =