From b5250cc573080be50cd627042f0d89f9da9205a6 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Wed, 31 Jul 2024 22:19:06 -0600 Subject: [PATCH] misc.color: i hate my own command parser --- src/modules/misc.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modules/misc.js b/src/modules/misc.js index baea6be..dc8d219 100644 --- a/src/modules/misc.js +++ b/src/modules/misc.js @@ -636,16 +636,17 @@ const color = new Command("color"); color.category = CATEGORY; color.helpText = "Show information on a color or get a random color"; color.callback = async function (msg, line, args, {truerandom, first}) { - let color = tinycolor(line), + const query = args.join(" "); + let color = tinycolor(query), random = false; - if (!line || line == "") { + if (!query || query == "") { color = truerandom ? tinycolor(Math.floor(Math.random() * 0xffffff)) : randomColor(); random = true; } if (!color.isValid) { - const search = `^([0-9a-f]{6}),${line},`; + const search = `^([0-9a-f]{6}),${query},`; if (!first) { const colornamesMatches = colornamesRaw.match(new RegExp(search, "img")); if (colornamesMatches.length > 1) { @@ -662,7 +663,7 @@ color.callback = async function (msg, line, args, {truerandom, first}) { text: `Picked #${random} for embed color \u2022 Use \`--first\` or the \`first\` option to bypass this`, }, fields: [ - {name: `Got ${colornamesMatches.length} matches for \`${safeString(line)}\``, value: left, inline: true}, + {name: `Got ${colornamesMatches.length} matches for \`${safeString(query)}\``, value: left, inline: true}, {name: "\u200b", value: right, inline: true}, ], },