misc.color: case for multiple colornames colors with the same name
This commit is contained in:
parent
5248ef1f75
commit
64a15df40c
1 changed files with 8 additions and 1 deletions
|
@ -645,7 +645,14 @@ color.callback = async function (msg, line, args, {truerandom}) {
|
|||
}
|
||||
|
||||
if (!color.isValid) {
|
||||
const colornamesHex = colornamesRaw.match(new RegExp(`^([0-9a-f]{6}),${line},`, "im"))?.[1];
|
||||
const search = `^([0-9a-f]{6}),${line},`;
|
||||
const colornamesMatches = colornamesRaw.match(new RegExp(search, "img"));
|
||||
if (colornamesMatches.length > 1) {
|
||||
const hexes = colornamesMatches.map((m) => m.split(",")[0]);
|
||||
return `Got ${colornamesMatches.length} matches for \`${safeString(line)}\`\n- ${hexes.join("\n- ")}`;
|
||||
}
|
||||
|
||||
const colornamesHex = colornamesRaw.match(new RegExp(search, "im"))?.[1];
|
||||
if (colornamesHex) {
|
||||
color = tinycolor(colornamesHex);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue