misc.color: i hate my own command parser
This commit is contained in:
parent
c53c545c48
commit
b5250cc573
1 changed files with 5 additions and 4 deletions
|
@ -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},
|
||||
],
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue